P.isModified = function() {
if(this.__undoQueue.length > 0){ return "*";}
return "-";
}
P.renderModelineContent = function(rc) {
var ml = String.buffer("--", this.isModified(), "- <b>",
this.name.htmlEscape(), "</b> (", rc.row + \
1, ",", rc.col, ") ");
The only problem is that the undoQueue has length if you do a
navigation keystroke. I would think that it would only have size if
an edit action occurred. One interesting thing to do is to change the
code to:
P.isModified = function() {
return this.__undoQueue.length; }
the length of the undoQueue jumps around quite a bit and is not always
what I would expect.
Also, is there a way to get the number of lines in a buffer, and what
the current "mode" is (i.e. javascript, css etc). I'd like to add
those to the modeline.
thanks,
-joe
The problem with the undoQueue is that everything that has been undoed
will be pushed back to the undoQueue as soon as a command which is not
"undo" is executed (so that you can undo the undo, like in Emacs). So
when you undo, changes get pushed to the __redoQueue; as soon as
undoQueue becomes empty, your isModified function will return false,
but redoQueue has data which will be pushed back to the undoQueue as
soon as you move the cursor, for instance. So I'm not sure that this
is the right solution...
I gotta run and will be offline for a few days.. Please post if you
figure out something. Patches welcome :-)
Cheers,
-Mihai
> --
> www.ymacs.com - AJAX code editor
--
Mihai Bazon,
http://mihai.bazon.net/blog
Ok, I'll dig into it a bit.
>
> I gotta run and will be offline for a few days.. Please post if you
> figure out something. Patches welcome :-)
Vacation I hope. If so, have a good one!
Oh, your sig says ymacs.COM which should prob be ymacs.ORG.
-joe
I know of a cheat, but it's pretty ugly... upon keystroke (and
perhaps throw out navigation keys) do a crc32 calc on the buffer and
see if it matches the original. using this:
http://noteslog.com/post/crc32-for-javascript/# my pc does 100 crc32
answers per second on 10K byte strings on google chrome.
maybe it's too hackish.
-joe
P.isModified = function() {
if (this.__code === this.__origCode) { return "-"; }
return "*";
}
and in P.setCode() I added:
this.__origCode = code;
The nice thing about this approach is if you modify the buffer and
then modify it in such a way that it gets back to its original state
(not necessarily using undo), the buffer will show as unmodified.
This is a better state of affairs then regular emacs which will still
show the buffer modified even if you modified it back to its original
state (something that has always mildly annoyed me).
also, now we have a string for "revert buffer"...
what do you think?
thanks,
-joe