Skip to content

Commit

Permalink
Add getHistory and setHistory methods
Browse files Browse the repository at this point in the history
  • Loading branch information
marijnh committed Jul 12, 2012
1 parent 2c7e711 commit 905db45
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions doc/manual.html
Expand Up @@ -541,6 +541,15 @@ <h2 id="api">Programming API</h2>
undo and redo operations.</dd>
<dt id="clearHistory"><code>clearHistory()</code></dt>
<dd>Clears the editor's undo history.</dd>
<dt id="getHistory"><code>getHistory() → object</code></dt>
<dd>Get a (JSON-serializeable) representation of the undo history.</dd>
<dt id="setHistory"><code>setHistory(object)</code></dt>
<dd>Replace the editor's undo history with the one provided,
which must be a value as returned
by <a href="#getHistory"><code>getHistory</code></a>. Note that
this will have entirely undefined results if the editor content
isn't also the same as it was when <code>getHistory</code> was
called.</dd>

<dt id="indentLine"><code>indentLine(line, dir)</code></dt>
<dd>Reset the given line's indentation to the indentation
Expand Down
9 changes: 9 additions & 0 deletions lib/codemirror.js
Expand Up @@ -199,6 +199,15 @@ var CodeMirror = (function() {
indentSelection: operation(indentSelected),
historySize: function() {return {undo: history.done.length, redo: history.undone.length};},
clearHistory: function() {history = new History();},
setHistory: function(histData) {
history = new History();
history.done = histData.done;
history.undone = histData.undone;
},
getHistory: function() {
history.time = 0;
return {done: history.done.concat([]), undone: history.undone.concat([])};
},
matchBrackets: operation(function(){matchBrackets(true);}),
getTokenAt: operation(function(pos) {
pos = clipPos(pos);
Expand Down

0 comments on commit 905db45

Please sign in to comment.