diff options
author | supriya <supriya@dragbox.(none)> | 2012-06-15 17:20:25 +0530 |
---|---|---|
committer | supriya <supriya@dragbox.(none)> | 2012-06-15 17:20:25 +0530 |
commit | 3cdc89682bc24634ae672acf090aa83a4ee2fd89 (patch) | |
tree | 2b459073283f704a644e636d3006a21bcf961ded /gstudio/static/gstudio/js | |
parent | 1f9318d1d158bd31e75469386cb03f5ae5208464 (diff) | |
download | gnowsys-3cdc89682bc24634ae672acf090aa83a4ee2fd89.tar.gz |
wrap added to gnowmacs & save button is working
Diffstat (limited to 'gstudio/static/gstudio/js')
30 files changed, 67 insertions, 9941 deletions
diff --git a/gstudio/static/gstudio/js/Gnowmacs/src/js/.#editorload.js b/gstudio/static/gstudio/js/Gnowmacs/src/js/.#editorload.js deleted file mode 120000 index 76cdbc5..0000000 --- a/gstudio/static/gstudio/js/Gnowmacs/src/js/.#editorload.js +++ /dev/null @@ -1 +0,0 @@ -supriya@dragbox.4544:1338183693
\ No newline at end of file diff --git a/gstudio/static/gstudio/js/Gnowmacs/src/js/.#savetext.js b/gstudio/static/gstudio/js/Gnowmacs/src/js/.#savetext.js deleted file mode 120000 index 22b842f..0000000 --- a/gstudio/static/gstudio/js/Gnowmacs/src/js/.#savetext.js +++ /dev/null @@ -1 +0,0 @@ -supriya@dragbox.2387:1336633521
\ No newline at end of file diff --git a/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/all-wcprops b/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/all-wcprops deleted file mode 100644 index de6e46b..0000000 --- a/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/all-wcprops +++ /dev/null @@ -1,149 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 37 -/svn/labcode/!svn/ver/56/Ymacs/src/js -END -ymacs-frame.js -K 25 -svn:wc:ra_dav:version-url -V 52 -/svn/labcode/!svn/ver/56/Ymacs/src/js/ymacs-frame.js -END -ymacs-regexp.js -K 25 -svn:wc:ra_dav:version-url -V 52 -/svn/labcode/!svn/ver/2/Ymacs/src/js/ymacs-regexp.js -END -ymacs-mode-js.js -K 25 -svn:wc:ra_dav:version-url -V 53 -/svn/labcode/!svn/ver/2/Ymacs/src/js/ymacs-mode-js.js -END -ymacs-exception.js -K 25 -svn:wc:ra_dav:version-url -V 55 -/svn/labcode/!svn/ver/2/Ymacs/src/js/ymacs-exception.js -END -ymacs-commands-utils.js -K 25 -svn:wc:ra_dav:version-url -V 60 -/svn/labcode/!svn/ver/2/Ymacs/src/js/ymacs-commands-utils.js -END -ymacs-keyboard.js -K 25 -svn:wc:ra_dav:version-url -V 54 -/svn/labcode/!svn/ver/2/Ymacs/src/js/ymacs-keyboard.js -END -ymacs-commands.js -K 25 -svn:wc:ra_dav:version-url -V 55 -/svn/labcode/!svn/ver/56/Ymacs/src/js/ymacs-commands.js -END -ymacs-keymap-isearch.js -K 25 -svn:wc:ra_dav:version-url -V 60 -/svn/labcode/!svn/ver/2/Ymacs/src/js/ymacs-keymap-isearch.js -END -ymacs.js -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/labcode/!svn/ver/51/Ymacs/src/js/ymacs.js -END -gnowmacs.js -K 25 -svn:wc:ra_dav:version-url -V 49 -/svn/labcode/!svn/ver/51/Ymacs/src/js/gnowmacs.js -END -ymacs-mode-markdown.js -K 25 -svn:wc:ra_dav:version-url -V 59 -/svn/labcode/!svn/ver/2/Ymacs/src/js/ymacs-mode-markdown.js -END -ymacs-buffer.js -K 25 -svn:wc:ra_dav:version-url -V 52 -/svn/labcode/!svn/ver/2/Ymacs/src/js/ymacs-buffer.js -END -ymacs-mode-css.js -K 25 -svn:wc:ra_dav:version-url -V 54 -/svn/labcode/!svn/ver/2/Ymacs/src/js/ymacs-mode-css.js -END -ymacs-tokenizer.js -K 25 -svn:wc:ra_dav:version-url -V 56 -/svn/labcode/!svn/ver/51/Ymacs/src/js/ymacs-tokenizer.js -END -ymacs-keymap-emacs.js -K 25 -svn:wc:ra_dav:version-url -V 59 -/svn/labcode/!svn/ver/51/Ymacs/src/js/ymacs-keymap-emacs.js -END -ymacs-interactive.js -K 25 -svn:wc:ra_dav:version-url -V 57 -/svn/labcode/!svn/ver/2/Ymacs/src/js/ymacs-interactive.js -END -gnowmoz.html -K 25 -svn:wc:ra_dav:version-url -V 49 -/svn/labcode/!svn/ver/2/Ymacs/src/js/gnowmoz.html -END -ymacs-marker.js -K 25 -svn:wc:ra_dav:version-url -V 52 -/svn/labcode/!svn/ver/2/Ymacs/src/js/ymacs-marker.js -END -ymacs-mode-paren-match.js -K 25 -svn:wc:ra_dav:version-url -V 62 -/svn/labcode/!svn/ver/2/Ymacs/src/js/ymacs-mode-paren-match.js -END -ymacs-mode-xml.js -K 25 -svn:wc:ra_dav:version-url -V 54 -/svn/labcode/!svn/ver/2/Ymacs/src/js/ymacs-mode-xml.js -END -ymacs-textprop.js -K 25 -svn:wc:ra_dav:version-url -V 54 -/svn/labcode/!svn/ver/2/Ymacs/src/js/ymacs-textprop.js -END -ymacs-minibuffer.js -K 25 -svn:wc:ra_dav:version-url -V 56 -/svn/labcode/!svn/ver/2/Ymacs/src/js/ymacs-minibuffer.js -END -ymacs-keymap.js -K 25 -svn:wc:ra_dav:version-url -V 52 -/svn/labcode/!svn/ver/2/Ymacs/src/js/ymacs-keymap.js -END -ymacs-mode-lisp.js -K 25 -svn:wc:ra_dav:version-url -V 55 -/svn/labcode/!svn/ver/2/Ymacs/src/js/ymacs-mode-lisp.js -END diff --git a/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/entries b/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/entries deleted file mode 100644 index f240c44..0000000 --- a/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/entries +++ /dev/null @@ -1,844 +0,0 @@ -10 - -dir -60 -https://svn.gnowledge.org/svn/labcode/Ymacs/src/js -https://svn.gnowledge.org/svn/labcode - - - -2011-07-04T13:18:15.544880Z -56 -sndt2011 - - - - - - - - - - - - - - -15bf0492-30b5-4620-9f24-ebed40bad4e9 - -ymacs-frame.js -file - - - - -2012-01-23T13:07:10.493354Z -5ed2cc2361ad9c42a97908abb74ebf7e -2011-07-04T13:18:15.544880Z -56 -sndt2011 - - - - - - - - - - - - - - - - - - - - - -29678 - -ymacs-regexp.js -file - - - - -2012-01-23T13:07:10.493354Z -2fce9bea79401ba94d305c4ea70d28c2 -2011-04-12T10:49:38.890806Z -2 -sndt2011 - - - - - - - - - - - - - - - - - - - - - -4579 - -ymacs-mode-js.js -file - - - - -2012-01-23T13:07:10.493354Z -96a16055c49d7c1018e00fc3458bd8e0 -2011-04-12T10:49:38.890806Z -2 -sndt2011 - - - - - - - - - - - - - - - - - - - - - -19781 - -ymacs-exception.js -file - - - - -2012-01-23T13:07:10.493354Z -6bdf528e2365965debcdd385776b6654 -2011-04-12T10:49:38.890806Z -2 -sndt2011 - - - - - - - - - - - - - - - - - - - - - -1778 - -ymacs-commands-utils.js -file - - - - -2012-01-23T13:07:10.493354Z -1550ac489247bfadb2f82ca481d7ea82 -2011-04-12T10:49:38.890806Z -2 -sndt2011 - - - - - - - - - - - - - - - - - - - - - -6924 - -ymacs-keyboard.js -file - - - - -2012-01-23T13:07:10.493354Z -aafe1644d74cdadfc1981798c831a7d8 -2011-04-12T10:49:38.890806Z -2 -sndt2011 - - - - - - - - - - - - - - - - - - - - - -4025 - -ymacs-commands.js -file - - - - -2012-01-23T13:07:10.493354Z -722253cc4ce0092e0efe74f24fcb0e43 -2011-07-04T13:18:15.544880Z -56 -sndt2011 - - - - - - - - - - - - - - - - - - - - - -60351 - -ymacs-keymap-isearch.js -file - - - - -2012-01-23T13:07:10.493354Z -79bc67c8ab57bc84d73900400fb508a7 -2011-04-12T10:49:38.890806Z -2 -sndt2011 - - - - - - - - - - - - - - - - - - - - - -8603 - -ymacs.js -file - - - - -2012-01-23T13:07:10.493354Z -0b839bd5d69a92cbde47c20453bf8215 -2011-06-29T11:25:20.046232Z -51 -sndt2011 - - - - - - - - - - - - - - - - - - - - - -21453 - -gnowmacs.js -file - - - - -2012-01-23T13:07:10.493354Z -b499c721fadefaccd92df487619fbb14 -2011-06-29T11:25:20.046232Z -51 -sndt2011 - - - - - - - - - - - - - - - - - - - - - -12608 - -ymacs-mode-markdown.js -file - - - - -2012-01-23T13:07:10.493354Z -2f403e0c6c30cd6fb80a5e2e928ddf5b -2011-04-12T10:49:38.890806Z -2 -sndt2011 - - - - - - - - - - - - - - - - - - - - - -3741 - -ymacs-buffer.js -file - - - - -2012-01-23T13:07:10.493354Z -41fbb9ce94f505c47688e6f8a7331613 -2011-04-12T10:49:38.890806Z -2 -sndt2011 - - - - - - - - - - - - - - - - - - - - - -42762 - -ymacs-mode-css.js -file - - - - -2012-01-23T13:07:10.493354Z -0036f7c58e013e824960b1ce8a973b89 -2011-04-12T10:49:38.890806Z -2 -sndt2011 - - - - - - - - - - - - - - - - - - - - - -11214 - -ymacs-tokenizer.js -file - - - - -2012-01-23T13:07:10.493354Z -78f31630e293e4eaad6dd207ca2621e0 -2011-06-29T11:25:20.046232Z -51 -sndt2011 - - - - - - - - - - - - - - - - - - - - - -12442 - -ymacs-keymap-emacs.js -file - - - - -2012-01-23T13:07:10.493354Z -f72ee282d04ce2e9b631fbb865e32d6b -2011-06-29T11:25:20.046232Z -51 -sndt2011 - - - - - - - - - - - - - - - - - - - - - -14759 - -ymacs-interactive.js -file - - - - -2012-01-23T13:07:10.493354Z -796e38ee63e912813e326cab98cd2020 -2011-04-12T10:49:38.890806Z -2 -sndt2011 - - - - - - - - - - - - - - - - - - - - - -10933 - -gnowmoz.html -file - - - - -2012-01-23T13:07:10.493354Z -aafcff8e156382d178dc64dd5a306515 -2011-04-12T10:49:38.890806Z -2 -sndt2011 - - - - - - - - - - - - - - - - - - - - - -11409 - -ymacs-marker.js -file - - - - -2012-01-23T13:07:10.493354Z -afa98ce75b65cad4757cd6c86c2a5f69 -2011-04-12T10:49:38.890806Z -2 -sndt2011 - - - - - - - - - - - - - - - - - - - - - -4050 - -ymacs-mode-paren-match.js -file - - - - -2012-01-23T13:07:10.493354Z -7d81f6ee6801b386db66f7cfa81eb5e0 -2011-04-12T10:49:38.890806Z -2 -sndt2011 - - - - - - - - - - - - - - - - - - - - - -14679 - -ymacs-mode-xml.js -file - - - - -2012-01-23T13:07:10.493354Z -6dcb936c73b5fe24479b065d80de8755 -2011-04-12T10:49:38.890806Z -2 -sndt2011 - - - - - - - - - - - - - - - - - - - - - -20046 - -ymacs-textprop.js -file - - - - -2012-01-23T13:07:10.497354Z -a50dd6040857ea0ddc45de8175544fbb -2011-04-12T10:49:38.890806Z -2 -sndt2011 - - - - - - - - - - - - - - - - - - - - - -7437 - -ymacs-minibuffer.js -file - - - - -2012-01-23T13:07:10.497354Z -6a9c387990e489ef6ff0ebdbfcb78b68 -2011-04-12T10:49:38.890806Z -2 -sndt2011 - - - - - - - - - - - - - - - - - - - - - -19677 - -ymacs-keymap.js -file - - - - -2012-01-23T13:07:10.497354Z -a5e9c330425cf8c639b929076ad9e66e -2011-04-12T10:49:38.890806Z -2 -sndt2011 - - - - - - - - - - - - - - - - - - - - - -6856 - -ymacs-mode-lisp.js -file - - - - -2012-01-23T13:07:10.497354Z -9bced0959eba036e3b05cd01010b25ed -2011-04-12T10:49:38.890806Z -2 -sndt2011 - - - - - - - - - - - - - - - - - - - - - -19965 - diff --git a/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/gnowmacs.js.svn-base b/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/gnowmacs.js.svn-base deleted file mode 100644 index 86945dd..0000000 --- a/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/gnowmacs.js.svn-base +++ /dev/null @@ -1,345 +0,0 @@ -// This file is part of Gnowmacs for GNOWSYS: Gnowledge Networking -// and Organizing System. - -// Gnowmacs is free software; you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation; either version 3 of -// the License, or (at your option) any later version. - -// Gnowmacs is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU Affero General Public -// License along with Gnowmacs (agpl.txt); if not, write to the -// Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -// Boston, MA 02110-1301 USA59 Temple Place, Suite 330, - -// Author: Divya <divyas15@gmail.com> - -// @require ymacs-tokenizer.js - -var arr4; -Ymacs_Tokenizer.define("org", function(stream, tok){ - - var PARSER = { - next : next, - copy : copy, - indentation : indentation - }; - - var $parens = []; - var $passedParens = []; - var $cont = []; - var $inString = null; - var $inComment = null; - var $inHeading = null; - - function copy() { - var c = resume.context = { - parens : $parens.slice(0), - passedParens : $passedParens.slice(0), - cont : $cont.slice(0), - inString : $inString, - inComment : $inComment, - inHeading : $inHeading - }; - function resume() { - $parens = c.parens.slice(0); - $passedParens = c.passedParens.slice(0); - $cont = c.cont.slice(0); - $inString = c.inString; - $inComment = c.inComment; - $inHeading = c.inHeading; - return PARSER; - }; - return resume; - }; - - function INDENT_LEVEL() { - return tok.buffer.getq("indent_level"); - }; - - var OPEN_PAREN = { - "(" : ")", - "{" : "}", - "[" : "]" - }; - - var CLOSE_PAREN = { - ")" : "(", - "}" : "{", - "]" : "[" - }; - - function isOpenParen(ch) { - return OPEN_PAREN[ch]; - }; - - function isCloseParen(ch) { - return CLOSE_PAREN[ch]; - }; - - function foundToken(c1, c2, type) { - tok.onToken(stream.line, c1, c2, type); - }; - - function readComment() { - var line = stream.lineText(), pos = line.indexOf("*/", stream.col); - var m = /^\s*\*+/.exec(line.substr(stream.col)); - if (m) { - foundToken(stream.col, stream.col += m[0].length, "mcomment-starter"); - } - if (pos >= 0) { - $cont.pop(); - $inComment = null; - foundToken(stream.col, pos, "mcomment"); - foundToken(pos, pos += 2, "mcomment-stopper"); - stream.col = pos; - } else { - foundToken(stream.col, line.length, "mcomment"); - stream.col = line.length; - } - }; - - function readString(end, type) { - var ch, esc = false, start = stream.col; - while (!stream.eol()) { - ch = stream.peek(); - if (ch === end && !esc) { - $cont.pop(); - $inString = null; - foundToken(start, stream.col, type); - foundToken(stream.col, ++stream.col, type + "-stopper"); - return true; - } - esc = !esc && ch === "\\"; - stream.nextCol(); - } - foundToken(start, stream.col, type); - }; - - function readHeading(type) { - var start = stream.col; - while (!stream.eol()) { - stream.nextCol(); - } - foundToken(start, stream.col, type); - }; - - function next() { - stream.checkStop(); - if ($cont.length > 0) - return $cont.peek()(); - var ch = stream.peek(), tmp; - if (stream.lookingAt("/*")) { - $inComment = { line: stream.line, c1: stream.col }; - foundToken(stream.col, stream.col += 2, "mcomment-starter"); - $cont.push(readComment); - } - else if (ch === '"' || ch === "'") { - $inString = { line: stream.line, c1: stream.col }; - foundToken(stream.col, ++stream.col, "string-starter"); - $cont.push(readString.$C(ch, "string")); - } - //to start with org - else if ((tmp = stream.lookingAt(/^(\[\[)(.+?)(\]\[)(.+?)(\]\])/))) { - foundToken(stream.col, stream.col += tmp[2].length+4, "org-link-url"); - var url = tmp[2]; - foundToken(stream.col, stream.col += (tmp[4].length+1), "org-link-text"); - window.open(url); - foundToken(stream.col, stream.col += 1, "org-link-close"); - - - } - else if ((tmp = stream.lookingAt(/^(\*.+?\*)/))) { - if (tmp[1].substring(1,2) === " " || tmp[1].substring(tmp[1].length-2, tmp[1].length-1) === " ") - {foundToken(stream.col, stream.col += tmp[1].length, null);} - else{ - foundToken(stream.col, stream.col += tmp[1].length, "org-bold"); - } - } - else if ((tmp = stream.lookingAt(/^(\/.+?\/)/))) { - if (tmp[1].substring(1,2) === " " || tmp[1].substring(tmp[1].length-2, tmp[1].length-1) === " ") - {foundToken(stream.col, stream.col += tmp[1].length, null);} - else{ - foundToken(stream.col, stream.col += tmp[1].length, "org-italic"); - } - } - else if ((tmp = stream.lookingAt(/^(_.+?_)/))) { - if (tmp[1].substring(1,2) === " " || tmp[1].substring(tmp[1].length-2, tmp[1].length-1) === " ") - {foundToken(stream.col, stream.col += tmp[1].length, null);} - else{ - foundToken(stream.col, stream.col += tmp[1].length, "org-underline"); - } - } - else if ((tmp = stream.lookingAt(/^(\+.+?\+)/))) { - if (tmp[1].substring(1,2) === " " || tmp[1].substring(tmp[1].length-2, tmp[1].length-1) === " ") - {foundToken(stream.col, stream.col += tmp[1].length, null);} - else{ - foundToken(stream.col, stream.col += tmp[1].length, "org-strike"); - } - } - - else if ((tmp = stream.lookingAt(/^(\*+\s+)/))) { - if (stream.col == 0){ - var headtype = "org-heading" + (tmp[1].length -1); - foundToken(stream.col, stream.col += tmp[1].length, headtype); - readHeading(headtype); - } - } - - - //to end with org - - else { - foundToken(stream.col, ++stream.col, null); - } - }; - - - - - function indentation() { - // no indentation for continued strings - if ($inString) - return 0; - - var row = stream.line; - var currentLine = stream.lineText(); - var indent = 0; - - if ($inComment) { - var commentStartLine = stream.lineText($inComment.line); - indent = $inComment.c1 + 1; - if (!/^\s*\*/.test(currentLine)) { - // align with the first non-whitespace and non-asterisk character in the comment - var re = /[^\s*]/g; - re.lastIndex = $inComment.c1 + 1; - var m = re.exec(commentStartLine); - if (m) - indent = m.index; - } - return indent; - } - - var p = $parens.peek(); - if (p) { - // check if the current line closes the paren - var re = new RegExp("^\\s*\\" + OPEN_PAREN[p.type]); - var thisLineCloses = re.test(currentLine); - - // Check if there is text after the opening paren. If so, indent to that column. - var line = stream.lineText(p.line); - re = /\S/g; - re.lastIndex = p.col + 1; - var m = re.exec(line); - if (m) { - // but if this line closes the paren, better use the column of the open paren - indent = thisLineCloses ? p.col : m.index; - } - else { - // Otherwise we should indent to one level more than the indentation of the line - // containing the opening paren. - indent = stream.lineIndentation(p.line) + INDENT_LEVEL(); - - // but if this line closes the paren, then back one level - if (thisLineCloses) - indent -= INDENT_LEVEL(); - } - } - - return indent; - }; - - return PARSER; - -}); - -DEFINE_SINGLETON("Ymacs_Keymap_Org", Ymacs_Keymap); -Ymacs_Keymap_Org().defineKeys({ - "ENTER" : "newline_and_indent", - ": && } && )" : "c_insert_and_indent" -}); - -Ymacs_Buffer.newMode("org_mode", function(){ - - var tok = this.tokenizer; - this.setTokenizer(new Ymacs_Tokenizer({ buffer: this, type: "org" })); - var was_paren_match = this.cmd("paren_match_mode", true); - this.pushKeymap(Ymacs_Keymap_Org()); - - return function() { - this.setTokenizer(tok); - if (!was_paren_match) - this.cmd("paren_match_mode", false); - this.popKeymap(Ymacs_Keymap_Org()); - }; -}); - - -Ymacs_Buffer.newCommands({ - - org_insert_heading: Ymacs_Interactive(function() { - this.cmd("beginning_of_line"); - this.cmd("insert", "* "); - }), - - org_bold: Ymacs_Interactive("r", function(begin, end) { - if (end < begin) { var tmp = begin; begin = end; end = tmp; } - this.cmd("goto_char", begin); - this.cmd("insert", "*"); - this.cmd("goto_char", end+1); - this.cmd("insert", "*"); - }), - - org_italic: Ymacs_Interactive("r", function(begin, end) { - if (end < begin) { var tmp = begin; begin = end; end = tmp; } - this.cmd("goto_char", begin); - this.cmd("insert", "/"); - this.cmd("goto_char", end+1); - this.cmd("insert", "/"); - }), - - org_underline: Ymacs_Interactive("r", function(begin, end) { - if (end < begin) { var tmp = begin; begin = end; end = tmp; } - this.cmd("goto_char", begin); - this.cmd("insert", "_"); - this.cmd("goto_char", end+1); - this.cmd("insert", "_"); - }), - - org_strike: Ymacs_Interactive("r", function(begin, end) { - if (end < begin) { var tmp = begin; begin = end; end = tmp; } - this.cmd("goto_char", begin); - this.cmd("insert", "+"); - this.cmd("goto_char", end+1); - this.cmd("insert", "+"); - }), - - org_file: Ymacs_Interactive("f", function() { - if (end < begin) { var tmp = begin; begin = end; end = tmp; } - this.cmd("goto_char", begin); - this.cmd("insert", "+"); - this.cmd("goto_char", end+1); - this.cmd("insert", "+"); - }), - org_link: Ymacs_Interactive("r", function(begin, end) { - if (end < begin) { var tmp = begin; begin = end; end = tmp; } - this.cmd("goto_char", begin); - this.cmd("insert", "[["); - this.cmd("goto_char", end+2); - this.cmd("insert", "]]"); - }), - org_table_create: Ymacs_Interactive("r", function(begin, end) { - if (end < begin) { var tmp = begin; begin = end; end = tmp; } - this.cmd("goto_char", begin); - this.cmd("insert", "|"); - this.cmd("insert"," "); - //this.cmd("goto_char", end+1); - //this.cmd("insert", "|"); - }) - - -}); diff --git a/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/gnowmoz.html.svn-base b/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/gnowmoz.html.svn-base deleted file mode 100644 index 7873887..0000000 --- a/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/gnowmoz.html.svn-base +++ /dev/null @@ -1,276 +0,0 @@ -<!DOCTYPE html> -<!-- -#**** BEGIN LICENSE BLOCK ***** -# Version: MPL 1.1/GPL 2.0/LGPL 2.1 -# -# The contents of this file are subject to the Mozilla Public License -# Version 1.1 (the "License"); you may not use this file except in -# compliance with the License. You may obtain a copy of the License at -# http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" -# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -# License for the specific language governing rights and limitations -# under the License. -# -# The Original Code is MozGnowser code. -# -# The Initial Developer of the Original Code is Jayakrishnan B Nair -# Portions created by the Initial Developer are Copyright (C) 2009-2010. -# All Rights Reserved. -# -# Contributor(s): -# Jayakrishnan B Nair <jayakrishnan.bk.nair@gmail.com> -# Sai Srivatsan R Iyengar -# Ridima Borkar -# Foram Dalal -# -# Alternatively, the contents of this file may be used under the terms of -# either the GNU General Public License Version 2 or later (the "GPL"), or -# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -# in which case the provisions of the GPL or the LGPL are applicable instead -# of those above. If you wish to allow use of your version of this file only -# under the terms of either the GPL or the LGPL, and not to allow others to -# use your version of this file under the terms of the MPL, indicate your -# decision by deleting the provisions above and replace them with the notice -# and other provisions required by the GPL or the LGPL. If you do not delete -# the provisions above, a recipient may use your version of this file under -# the terms of any one of the MPL, the GPL or the LGPL. -# -#**** END LICENSE BLOCK ***** ---> -<html xmlns="http://www.w3.org/1999/xhtml" svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> -<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></meta> -<head> -<!--<link type="text/css" href="chrome://gnowmoz/content/css/ui-darkness/jquery-ui-1.8rc3.custom.css" rel="stylesheet" />--> -<link type="text/css" href="chrome://gnowmoz/content/css/cupertino/jquery-ui-1.8rc3.custom.css" rel="stylesheet" /> -<!--<link type="text/css" rel="stylesheet" href="http://jqueryui.com/themes/base/ui.all.css" />--> -<script type="text/javascript" src="chrome://gnowmoz/content/js/json2.js"></script> -<script type="text/javascript" src="chrome://gnowmoz/content/js/jquery.js"></script> -<script type="text/javascript" src="chrome://gnowmoz/content/js/jquery-ui.js"></script> -<script type="text/javascript" src="chrome://gnowmoz/content/js/jquery.qtip.min.js"></script> -<script type="text/javascript" src="chrome://gnowmoz/content/js/jquery.jsonviewer.js"></script> -<!--<script type="text/javascript" src="http://jqueryui.com/themeroller/themeswitchertool/"></script>--> - -<script type="text/javascript" src="chrome://gnowmoz/content/js/jquery.hotkeys.js"></script> -<script type="text/javascript" src="chrome://gnowmoz/content/js/gnowmoz.js"></script> - -</head> -<body onLoad="dologin()"> - - <!-- HEADER WITH SEARCH BOX --> -<div id="layout-header" style="display:none"> - <div id="page-header" style="padding:5px;height:30px;background:#deedf7" class="ui-corner-all"> - <div style="float:left;width:20%;font-weight:bold">MozGnowser</div> - <button style="float:left;width:10%" id="help">HELP TIPS</button> - <button style="float:left;" id="gnowql-shell-link" onClick="gnowqlShell()" > GnowQL SHELL </button> - <div style="float:left" id="themes" ></div> - <button style="float:right;" id="SEARCH" class="ui-widget-content" onClick="GnowqlSearch()">SEARCH</button> - <input type="text" style="float:right;font-size:18px" class="ui-widget-content ui-corner-all autocomplete" - id="search-value" value="" > - <select style="float:right;font-size:18px" id="search-type" class="ui-widget ui-widget-content ui-corner-all "> - <option value="All">ALL</option> - <option value="gbobjects">Object</option> - <option value="gbobjecttypes">Objecttype</option> - <option value="gbrelations">Relation</option> - <option value="gbrelationtypes">Relationtype</option> - <option value="gbattributes">Attribute</option> - <option value="gbattributetypes">Attributetype</option> - <option value="gbmetatypes">Metatype</option> - <option value="gbusers">User</option> - <option value="gbusertypes">Usertype</option> - <option value="gbprocess">Process</option> - <option value="gbprocesstypes">Processtype</option> - </select> - - </div> -<div id="search-loading"></div> -</div> - - - -<div id="startup-info" style="display:none" class="ui-widget"> -<pre> - Welcome to MozGnowser - - Searching the Gnowsys DB can be done using the - search box on the top right of the page. - The appropriate item of choice can be selected from the list. - The NBH-SVG tab will give a digramatic representation - of the item selected. - The NBH-INFO tab will give u textual representation - of the node's neighbourhood. - - Various Key Shortcuts are available : - (do not press down the buttons continously and make sure to - have clicked outside the SVG image before using the shortcuts) - 1) Ctrl + z : Zoom In for the SVG image - 2) Ctrl + x : Zoom Out for the SVG image - 3) Ctrl + arrowkeys will help u pan the image as per requirement - -</pre> -</div> - -<div id="search-tip" style="display:none"> -<pre> - Search Box : - You can search the title from the Gnowsys DB. - You can use "ssid:" without the quotes to - make a specific search example: "ssid:108" -</pre> -</div> - - -<div id="result-table" style="width:100%;display:none"> - - <div id="result-border" style="width:79%;height:100%;border:4px #00FFFF solid;float:left"> - - <div id="add" style="width:100%:z-index:1000"> - <h3><a href="#">Add</a></h3> - <div id="nbh-add" style="height:20%"> - <ul> - <li><a href="#atabs-1" id="addrel">RELATIONS</a></li> - <li><a href="#atabs-2" id="addatt">ATTRIBUTES</a></li> - <li><a href="#atabs-3" id="adddep">DEPENDSON</a></li> - </ul> - <div id="atabs-1" > - <input type="text" id="nbh-add-nid-rel" style="width:30%;float:left;" - class="ui-widget-content ui-corner-all autocomplete"></input> - <select id="nbh-add-select-rel" class="text ui-widget-content " style="width:30%;float:left"></select> - <input type="text" id="nbh-add-text-rel" class="ui-widget-content ui-corner-all autocomplete" - style="width:30%;float:left"></input> - <input type="button" id="nbh-add-submit-rel" class="ui-widget-content ui-corner-all" value="Submit" - onclick='if(document.getElementById("nbh-add-text-rel").value!="")add("rel");'></input> - </div> - <div id="atabs-2"> - <input type="text" id="nbh-add-nid-att" style="width:30%;float:left;" - class="ui-widget-content ui-corner-all autocomplete"></input> - <select id="nbh-add-select-att" class="text ui-widget-content" style="width:30%;float:left"></select> - <input type="text" id="nbh-add-text-att" class="text ui-widget-content ui-corner-all autocomplete" - style="width:30%;float:left"></input> - <input type="button" id="nbh-add-submit-att" class="text ui-widget-content ui-corner-all" - value="Submit" onclick='if(document.getElementById("nbh-add-text-att").value!="")add("att")'></input> - </div> - - <div id="atabs-3"> - <input type="text" id="nbh-add-nid-dep" style="width:30%;float:left;" - class="ui-widget-content ui-corner-all autocomplete"></input> - <select id="nbh-add-select-dep" class="text ui-widget-content" style="width:30%;float:left"></select> - <input type="text" id="nbh-add-text-dep" class="text ui-widget-content ui-corner-all autocomplete" - style="width:30%;float:left"></input> - <input type="button" id="nbh-add-submit-dep" class="text ui-widget-content ui-corner-all" - value="Submit" onclick='if(document.getElementById("nbh-add-text-dep").value!="")add("dep")'></input> - </div> - - </div> - </div> - - - <div id="nbh-resultinfo" style="width:100%"> - <ul> - <li><a href="#tabs-1" >NBH-SVG</a></li> - <li><a href="#tabs-2" >NBH-INFO</a></li> - </ul> - <div id="tabs-1"> - <div id="nbh-svg" style="height:100%;width:100%"></div> - </div> - <div id="tabs-2"> - <div id="nbh-info" style="height:100%;width:100%" ></div> - </div> - </div> - </div> - - <div id="result-area" class="text" style="width:19.5%;float:right;border:4px #00FFFF solid;overflow:auto" ></div> - -</div> - - - -<!-- LOGIN FORM DIALOG--> -<div id="login-form" title="Dialog Title" style="display:none" title="Login Form"> - <p >All form fields are required.</p> - - - <table style="width:100%" align="left"> - <tr> - <td><label for="name" >Name</label></td> - <td><input type="text" name="name" id="login" value="" class="text ui-widget-content ui-corner-all logintext" - style="width:100%"></td> - </tr> - - <tr> - <td><label for="password" >Password</label></td> - <td><input type="password" name="password" id="pass" value="" style="width:100%" - class="text ui-widget-content ui-corner-all logintext"></td> - </tr> - - <tr> - <td><label for="text" >GnowQL URL</label></td> - <td><input type="text" name="url" id="url" value="http://sandboxat.gnowledge.org/gnowql" - style="width:100%" class="text ui-widget-content ui-corner-all logintext"></td> - </tr> - </table> - <table style="width:100%"> - <tr> - <td> - <div id="proxy" style="width:100%"> - <h3><a href="#">Proxy Settings : Click To Enable</a></h3> - <div> - <table> - <tr> - <td><label style="float:left">Proxy URL</label></td> - <td><input type="text" name="url" id="proxy-url" value="" - style="width:100%" class="text ui-widget-content ui-corner-all logintext"> </td> - </tr> - <tr> - <td><label style="float:left">Proxy Port</label></td> - <td><input type="text" name="url" id="proxy-port" value="0" - style="width:100%" class="text ui-widget-content ui-corner-all logintext"></td> - </tr> - <tr> - <td><label >Proxy Username</label></td> - <td><input type="text" name="url" id="proxy-username" value="" - style="width:100%" class="text ui-widget-content ui-corner-all logintext"></td> - </tr> - <tr> - <td><label >Proxy Password</label></td> - <td><input type="password" name="url" id="proxy-password" value="" - style="width:100%" class="text ui-widget-content ui-corner-all logintext"></td> - </tr> - </table> - </div> - </td> - </tr> - <table> - </table> - <tr> - <td></td> - <td colspan=2><div id="login-error" style="color:black;visibility:hidden">LOGIN ERROR !!!</div></td> - </tr> - </table> - - - </div> - -<!-- ADD Options --> -<div id="add-options" title="Choice" style="display:none" title="Multiple Choice"> - <p class="validateTips">Please Select your Choice!!!</p> - </div> - -<!--GnowQL Shell--> - - -<div id="gnowql-shell" title="GnowQL SHELL" style="display:none" > - <label>Type HERE : </label> - <input type="text" id="gnowql-shell-text" value="" style="width:100%;height:50px;font-weight:bold;font-size:30px" - class="text ui-widget-content ui-corner-all"> - <label> Result (JSON string) : </label><br /> - <textarea id="gnowql-shell-box" cols="130" rows="20" style:"float:left"></textarea> - <br /> -<div style="overflow:auto"> -<div id="gnowql-shell-tree"></div> -</div> - </div> - -</body> -</html> diff --git a/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-buffer.js.svn-base b/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-buffer.js.svn-base deleted file mode 100644 index ba6303e..0000000 --- a/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-buffer.js.svn-base +++ /dev/null @@ -1,1079 +0,0 @@ -//> This file is part of Ymacs, an Emacs-like editor for the Web -//> http://www.ymacs.org/ -//> -//> Copyright (c) 2009-2010, Mihai Bazon, Dynarch.com. All rights reserved. -//> -//> Redistribution and use in source and binary forms, with or without -//> modification, are permitted provided that the following conditions are -//> met: -//> -//> * Redistributions of source code must retain the above copyright -//> notice, this list of conditions and the following disclaimer. -//> -//> * Redistributions in binary form must reproduce the above copyright -//> notice, this list of conditions and the following disclaimer in -//> the documentation and/or other materials provided with the -//> distribution. -//> -//> * Neither the name of Dynarch.com nor the names of its contributors -//> may be used to endorse or promote products derived from this -//> software without specific prior written permission. -//> -//> THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY -//> EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -//> IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -//> PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE -//> FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -//> CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -//> SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -//> INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -//> CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -//> ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF -//> THE POSSIBILITY OF SUCH DAMAGE. - -// @require ymacs-interactive.js - -DEFINE_CLASS("Ymacs_Buffer", DlEventProxy, function(D, P){ - - D.DEFAULT_EVENTS = [ - "onLineChange", - "onInsertLine", - "onDeleteLine", - "onPointChange", - "onResetCode", - "onMessage", - "onOverwriteMode", - "onOverlayChange", - "onOverlayDelete", - "beforeInteractiveCommand", - "afterInteractiveCommand", - "beforeRedraw", - "afterRedraw", - "finishedEvent", - "onProgressChange", - "onTextInsert", - "onTextDelete" - ]; - - D.DEFAULT_ARGS = { - name : [ "name" , "*scratch*" ], - _code : [ "code" , null ], - ymacs : [ "ymacs" , null ], - tokenizer : [ "tokenizer" , null ], - isMinibuffer : [ "isMinibuffer" , false ] - }; - - var GLOBAL_VARS = { - case_fold_search : true, - line_movement_requested_col : 0, - fill_column : 78, - tab_width : 8, - indent_level : 8, - - // syntax variables - syntax_word : { test: TEST_UNICODE_WORD_CHAR }, - syntax_word_dabbrev : { test: TEST_DABBREV_WORD_CHAR }, - syntax_paragraph_sep : /\n\s*\n/g - }; - - function setq(key, val) { - if (typeof key == "string") { - if (val === undefined) - delete this[key]; - else - this[key] = val; - if (val instanceof Function) - val.ymacsCommand = key; - return val; - } else { - var changed = {}; - for (var i in key) { - changed[i] = this[i]; - setq.call(this, i, key[i]); - } - return changed; - } - }; - - var MAX_UNDO_RECORDS = 50000; // XXX: should we not limit? - - function MRK(x) { - return x instanceof Ymacs_Marker ? x.getPosition() : x; - }; - - function TEST_UNICODE_WORD_CHAR(c) { - if (c) { - var code = c.charCodeAt(0); - return (code >= 48 && code <= 57) || c.toUpperCase() != c.toLowerCase(); - } - }; - - function TEST_DABBREV_WORD_CHAR(c) { - if (c) { - var code = c.charCodeAt(0); - return (code >= 48 && code <= 57) || c == "_" || c.toUpperCase() != c.toLowerCase(); - } - }; - - P.lastIndexOfRegexp = function(str, re, caret, bound) { - str = str.substring(0, caret); - re = Ymacs_Regexp.search_backward(re); - re.lastIndex = bound || 0; - var m = re.exec(str); - if (m) { - var a = Array.$(m, 2); - a.index = m.index + m[1].length; - a.after = m.index + m[0].length; - a[0] = str.substring(a.index, a.after); - this.matchData = a; - return a; - } - }; - - D.COMMANDS = P.COMMANDS = {}; - - D.newCommands = P.newCommands = function() { - return setq.apply(this.COMMANDS, arguments); - }; - - D.newMode = P.newMode = function(name, activate) { - var modevar = "*" + name + "*", hookvar = modevar + "hooks"; - D.setGlobal(hookvar, []); - this.COMMANDS[name] = Ymacs_Interactive("P", function(force){ - var status = this.getq(modevar); - if (status) { - // currently active - if (force !== true) { - // deactivate - this.getq(hookvar).foreach(function(hook){ - hook.call(this, false); - }, this); - if (status instanceof Function) { - // clean-up - status.call(this); - } - this.setq(modevar, null); - this.modes.remove(name); - } - } - else { - // inactive - if (force !== false) { - var off = activate.apply(this, arguments); - if (!(off instanceof Function)) - off = true; - this.setq(modevar, off); - this.modes.push(name); - this.getq(hookvar).foreach(function(hook){ - hook.call(this, true); - }, this); - } - } - return status; - }); - }; - - D.addModeHook = P.addModeHook = function(name, func) { - if (typeof func == "string") - func = this.COMMANDS[func]; - var hookvar = "*" + name + "*hooks"; - this.getq(hookvar).pushUnique(func); - }; - - D.removeModeHook = P.removeModeHook = function(name, func) { - if (typeof func == "string") - func = this.COMMANDS[func]; - var hookvar = "*" + name + "*hooks"; - this.getq(hookvar).remove(func); - }; - - D.FIXARGS = function(args) { - if (args.code == null) - args.code = ""; - }; - - D.CONSTRUCT = function() { - this.__savingExcursion = 0; - this.__preventUpdates = 0; - this.__preventUndo = 0; - this.__undoInProgress = 0; - this.__dirtyLines = []; - this.__undoQueue = []; - this.__redoQueue = []; - this.__overlays = {}; - - this.markers = []; - this.caretMarker = this.createMarker(0, false, "point"); - this.markMarker = this.createMarker(0, true, "mark"); - this.matchData = []; - this.previousCommand = null; - this.currentCommand = null; - this.currentKeys = []; - this.progress = {}; - - this.variables = {}; - this.globalVariables = GLOBAL_VARS; - this.modes = []; - - this.caretMarker.onChange.push(function(pos) { - this._rowcol = this.caretMarker.getRowCol(); - // XXX: this shouldn't be needed - if (this.__preventUpdates == 0) { - this.callHooks("onPointChange", this._rowcol, this.point()); - } - }); - - this._tokenizerEvents = { - "onFoundToken": this._on_tokenizerFoundToken.$(this) - }; - - this._textProperties = new Ymacs_Text_Properties({ buffer: this }); - this._textProperties.addEventListener("onChange", this._on_textPropertiesChange.$(this)); - - this.keymap = []; - this.pushKeymap(this.makeDefaultKeymap()); - this.setCode(this._code); - this._lastCommandWasKill = 0; - delete this["_code"]; - }; - - /* -----[ dynamic variables ]----- */ - - // Who said dynamic scope is bad? Ever since I'm using Lisp I - // started considering them one of the most valuable features. - // Everybody is using dynamic scope. - // - // Since we don't have real dynamic scope in JS, we store the - // values in a hash and using the withVariables method we can - // assign temporary values to them and execute a function. - - P.withVariables = function(vars, cont) { - var saved = {}, i, ret; - for (i in vars) { - saved[i] = this.variables[i]; - this.variables[i] = vars[i]; - } - try { - if (cont instanceof Function) - return cont.apply(this, Array.$(arguments, 2)); - else - return this.cmdApply(cont, Array.$(arguments, 2)); - } finally { - for (i in saved) { - if (saved[i] === undefined) - delete this.variables[i]; - else - this.variables[i] = saved[i]; - } - } - }; - - P.withCommands = function(cmds, cont) { - var saved = this.COMMANDS; - this.COMMANDS = Object.makeCopy(saved); - Object.merge(this.COMMANDS, cmds); - try { - if (cont instanceof Function) - return cont.apply(this, Array.$(arguments, 2)); - else - return this.cmdApply(cont, Array.$(arguments, 2)); - } finally { - this.COMMANDS = saved; - } - }; - - P.getVariable = function(key) { - return (key in this.variables) - ? this.variables[key] - : GLOBAL_VARS[key]; - }; - - P.setVariable = function() { - return setq.apply(this.variables, arguments); - }; - - D.setq = D.setVariable = D.setGlobal = P.setGlobal = function() { - return setq.apply(GLOBAL_VARS, arguments); - }; - - P.setq = P.setVariable; - P.getq = P.getVariable; - D.getq = D.getVariable = function(key) { - return GLOBAL_VARS[key]; - }; - - /* -----[ public API ]----- */ - - P.pushKeymap = function(keymap) { - if (keymap instanceof Array) { - keymap.foreach(this.pushKeymap, this); - } else { - this.popKeymap(keymap); - this.keymap.push(keymap); - keymap.attached(this); - } - }; - - P.popKeymap = function(keymap) { - this.keymap.remove(keymap); - keymap.detached(this); - }; - - P.makeDefaultKeymap = function() { - return Ymacs_Keymap_Emacs(); - }; - - P.signalError = function(text, html, timeout) { - this.callHooks("onMessage", "error", text, html, timeout); - }; - - P.signalInfo = function(text, html, timeout) { - this.callHooks("onMessage", "info", text, html, timeout); - }; - - P.createMarker = function(pos, before, name) { - if (pos == null) - pos = this.point(); - return new Ymacs_Marker({ editor: this, pos: pos, name: name, before: before }); - }; - - P.point = function() { - return this.caretMarker.getPosition(); - }; - - P.setCode = function(code) { - // this.__code = code = code.replace(/\t/g, " ".x(this.getq("tab_width"))); - this.__code = code; - this.__size = code.length; - this.__undoQueue = []; - this.__redoQueue = []; - this.__overlays = {}; - this.markers.map("setPosition", 0, true, true); - this.code = code.split(/\n/); - this._textProperties.reset(); - if (this.tokenizer) { - this.tokenizer.reset(); - } - this.callHooks("onResetCode", this.code); - this.caretMarker.setPosition(0, false, true); - this.markMarker.setPosition(0, true); - }; - - P.setTokenizer = function(tok) { - if (this.tokenizer != null) { - this.tokenizer.removeEventListener(this._tokenizerEvents); - } - this.tokenizer = tok; - if (tok) { - tok.addEventListener(this._tokenizerEvents); - } else { - this._textProperties.reset(); - this.callHooks("onResetCode", this.code); - } - }; - - P.getCode = function() { - return this.__code || (this.__code = this.code.join("\n")); - }; - - P.getCodeSize = function() { - if (this.__size) - return this.__size; - var i = this.code.length, size = i > 0 ? -1 : 0; - while (--i >= 0) - size += this.code[i].length + 1; - return this.__size = size; - }; - - P.getLine = function(row) { - if (row == null) - row = this._rowcol.row; - return this.code[row]; - }; - - P.charAtRowCol = function(row, col) { - var n = this.code.length; - if (row >= n--) - return null; - var line = this.code[row]; - if (col == line.length) - return row == n && line.charAt(col) || "\n"; - return line.charAt(col); - }; - - P.charAt = function(point) { - if (point == null) - point = this.point(); - else { - point = MRK(point); - if (point < 0) - point += this.point(); - } - var rc = this._positionToRowCol(point); - return this.charAtRowCol(rc.row, rc.col); - }; - - P.callInteractively = function(func, args, finalArgs) { - if (!args) - args = []; // make IE happy - var cmd; - if (!(func instanceof Function)) { - cmd = func; - func = this.COMMANDS[func]; - } else { - cmd = func.ymacsCommand || null; - } - if (func.ymacsCallInteractively && !finalArgs) { - // after prompting for eventual - // arguments, ymacsCallInteractively - // will actually call back again - // buffer's callInteractively, so we - // should STOP here. - return func.ymacsCallInteractively.apply(this, args); - } - this.currentCommand = cmd; - // the amount of brain twisting to get - // this right is incredible. :-( I give up. - if (cmd != "undo") { - this.__undoQueue = this.__undoQueue.concat(this.__redoQueue); - this.__redoQueue = []; - } - if (this.previousCommand != cmd) { - this.sameCommandCount(0); - if (cmd != "undo") { - this._placeUndoBoundary(); - } - } else if (cmd != "self_insert_command" || this.sameCommandCount() % 20 == 0) { - if (cmd != "undo") { - this._placeUndoBoundary(); - } - } - this.preventUpdates(); - try { - this.callHooks("beforeInteractiveCommand", cmd, func); - if (!func.ymacsMarkExtend) - this.clearTransientMark(); - return func.apply(this, args); - } catch(ex) { - if (ex instanceof Ymacs_Exception) { - this.signalError(ex.message); - } else { - throw ex; - } - } finally { - this.resumeUpdates(); - this.callHooks("afterInteractiveCommand", cmd, func); - this.previousCommand = cmd; - this.sameCommandCount(+1); - } - }; - - P.resetOverwriteMode = function(om) { - if (arguments.length == 0) - om = this.overwriteMode; - this.callHooks("onOverwriteMode", this.overwriteMode = !om); - this.signalInfo(om ? "Insert mode" : "Overwrite mode"); - }; - - P.getMinibuffer = function() { - return this.whenYmacs(function(ymacs) { return ymacs.minibuffer; }); - }; - - P.getMinibufferFrame = function() { - return this.whenYmacs(function(ymacs) { return ymacs.minibuffer_frame; }); - }; - - P.setMinibuffer = function(text) { - this.whenMinibuffer(function(mb){ - mb.setCode(text); - mb.cmd("end_of_buffer"); - }); - }; - - P.cmd = function(cmd) { - return this.COMMANDS[cmd].apply(this, Array.$(arguments, 1)); - }; - - P.cmdApply = function(cmd, args) { - return this.COMMANDS[cmd].apply(this, args); - }; - - P.createDialog = function(args) { - if (!args.parent) { - args.parent = this.getActiveFrame() && this.getActiveFrame().getParentDialog(); - if (!("noShadows" in args)) { - args.noShadows = true; - } - } - var dlg = new DlDialog(args); - this.whenActiveFrame(function(frame){ - dlg.addEventListener("onDestroy", frame.focus.clearingTimeout(0, frame)); - }); - return dlg; - }; - - P.getActiveFrame = function() { - return this.whenYmacs("getActiveFrame"); - }; - - // This function receives a string and a continuation. If - // there is an object property or variable named $what, then - // $cont is called in the context of this object and given the - // value of $what as first argument. The returned value is - // passed back to caller. - // - // The continuation can also be a string, in which case it's - // assumed to be a method in the value of $what, thus called - // on it. - // - // This is a bit messy, but should work well as long as we - // don't use the same name for both an object property and a - // variable in this.variables. Otherwise, the property takes - // precedence. - P.when = function(what, cont) { - what = this[what] || this.getq(what); - if (what != null) { - if (cont instanceof Function) - return cont.call(this, what); - else { - return what[cont].apply(what, Array.$(arguments, 2)); - } - } - }; - - // XXX: this is way too ugly. - P.whenActiveFrame = function() { - var fr = this.getActiveFrame(); // miserable hack - if (fr.buffer === this) { - this.activeFrame = fr; - var a = Array.$(arguments); - a.unshift("activeFrame"); - return this.when.apply(this, a); - } else { - this.activeFrame = null; - } - }; - - P.forAllFrames = function(cont) { - this.ymacs.getBufferFrames(this).foreach(cont); - }; - - P.whenYmacs = function() { - var a = Array.$(arguments); - a.unshift("ymacs"); - return this.when.apply(this, a); - }; - - P.whenMinibuffer = function(cont) { - // In fact, we should move when() into some base - // object... but which one? JS doesn't have multiple - // inheritance, though we could easily "invent" it. - return this.whenYmacs(function(ymacs){ - if (ymacs.minibuffer) - return cont.call(this, ymacs.minibuffer); - }); - }; - - P.preventUpdates = function() { - ++this.__preventUpdates; - }; - - P.resumeUpdates = function() { - if ((this.__preventUpdates = Math.max(this.__preventUpdates - 1, 0)) == 0) { - this.redrawDirtyLines(); - } - }; - - P.getRegion = function(begin, end) { - if (begin == null) begin = this.caretMarker; - if (end == null) end = this.markMarker; - begin = MRK(begin); - end = MRK(end); - if (end < begin) { var tmp = begin; begin = end; end = tmp; } - return { begin: begin, end: end }; - }; - - P.redrawDirtyLines = function() { - this.callHooks("beforeRedraw"); - this.__dirtyLines.foreach(function(draw, row){ - if (draw) { - this.callHooks("onLineChange", row); - } - }, this); - this.__dirtyLines = []; - this.callHooks("afterRedraw"); - }; - - P.getOverlays = function() { - return this.__overlays; - }; - - P.getOverlay = function(name) { - return this.__overlays[name]; - }; - - P.setOverlay = function(name, props) { - var ov = this.__overlays[name], isNew = !ov, tmp; - if (isNew) - ov = this.__overlays[name] = props; - else - Object.merge(ov, props); - // normalize line/col - if (ov.line2 < ov.line1) { - tmp = ov.line2; ov.line2 = ov.line1; ov.line1 = tmp; - tmp = ov.col2; ov.col2 = ov.col1; ov.col1 = tmp; - } - else if (ov.line2 == ov.line1 && ov.col2 < ov.col1) { - tmp = ov.col2; ov.col2 = ov.col1; ov.col1 = tmp; - } - this.callHooks("onOverlayChange", name, ov, isNew); - }; - - P.deleteOverlay = function(name) { - delete this.__overlays[name]; - this.callHooks("onOverlayDelete", name); - }; - - P.ensureTransientMark = function() { - var rc = this._rowcol, tm; - if (!this.transientMarker) { - this.transientMarker = this.createMarker(); - this.markMarker.setPosition(this.point()); - tm = rc; - } - if (!tm) - tm = this.transientMarker.getRowCol(); - this.setOverlay("selection", { - line1 : tm.row, - col1 : tm.col, - line2 : rc.row, - col2 : rc.col - }); - }; - - P.clearTransientMark = function() { - if (this.transientMarker) { - this.transientMarker.destroy(); - this.transientMarker = null; - this.deleteOverlay("selection"); - } - }; - - P.deleteTransientRegion = function() { - if (this.transientMarker) { - this._deleteText(this.caretMarker, this.transientMarker); - this.clearTransientMark(); - this._placeUndoBoundary(); - return true; - } - }; - - var $sameCommandCount = 0; - P.sameCommandCount = function(diff) { - if (diff == null) - return $sameCommandCount; - return $sameCommandCount += diff; - }; - - var $lastKeyEvent; - P.interactiveEvent = function(ev) { - if (arguments.length == 0) - return $lastKeyEvent; - return $lastKeyEvent = ev; - }; - - P.getPrefixArg = function(noDiscard) { - var ret = this.getq("universal_prefix"); - if (!noDiscard) { - this.setq("universal_prefix", undefined); - if (!this.isMinibuffer) - this.setMinibuffer(""); - } - return ret; - }; - - P.setPrefixArg = function(val) { - return this.setq("universal_prefix", val); - }; - - P.updateProgress = function(name, val) { - if (val == null) - delete this.progress[name]; - else - this.progress[name] = val; - this.callHooks("onProgressChange"); - }; - - P.renderModelineContent = function(rc) { - var ml = String.buffer("-- <b>", this.name.htmlEscape(), "</b> (", rc.row + 1, ",", rc.col, ") "); - var pr = []; - for (var i in this.progress) { - pr.push(i + ": " + this.progress[i]); - } - if (pr.length > 0) { - ml("[", pr.join(", "), "]"); - } - return ml.get(); - }; - - /* -----[ not-so-public API ]----- */ - - // BEGIN: undo queue - - P._recordChange = function(type, pos, len, text) { - if (len > 0) { - var q = this.__undoQueue; - q.push({ - type : type, - pos : pos, - len : len, - text : text - }); - if (q.length > MAX_UNDO_RECORDS) - q.shift(); - } - }; - - P._placeUndoBoundary = function(q) { - q = q || this.__undoQueue; - var m = this.markers.map(function(m){ - return [ m, m.getPosition() ]; - }); - var last = q.peek(); - if (!last || last.type != 3) { - q.push({ type: 3, markers: m }); - } else { - last.markers = m; - } - }; - - P._playbackUndo = function(q) { - ++this.__undoInProgress; - var didit = false, action; - while (q.length > 0 && q.peek().type == 3) { - action = q.pop(); - } - while (q.length > 0) { - action = q.pop(); - if (action.type == 3) { // boundary - // restore markers - action.markers.foreach(function(m){ - m[0].setPosition(m[1]); - }); - break; - } - didit = true; - var pos = action.pos; - switch (action.type) { - case 1: // insert - this._deleteText(pos, pos + action.len); - break; - case 2: // delete - this._insertText(action.text, pos); - break; - } - } - --this.__undoInProgress; - return didit; - }; - - // END: undo - - P._replaceLine = function(row, text) { - this.code[row] = text; - this._textProperties.replaceLine(row, text); - if (this.__preventUpdates == 0) { - this.callHooks("onLineChange", row); - } else { - this.__dirtyLines[row] = true; - } - }; - - P._deleteLine = function(row) { - this.code.splice(row, 1); - this._textProperties.deleteLine(row); - if (this.tokenizer) - this.tokenizer.quickDeleteLine(row); - this.__dirtyLines.splice(row, 1); - this.callHooks("onDeleteLine", row); - }; - - P._insertLine = function(row, text) { - this.code.splice(row, 0, text); - this._textProperties.insertLine(row); - if (this.tokenizer) - this.tokenizer.quickInsertLine(row); - var drawIt = this.__preventUpdates == 0; - this.callHooks("onInsertLine", row, drawIt); - if (!drawIt) { - if (this.__dirtyLines.length <= row) - this.__dirtyLines[row] = true; - else - this.__dirtyLines.splice(row, 0, true); - } - }; - - P._insertText = function(text, pos) { - if (text.length == 0) - return; - if (pos == null) - pos = this.caretMarker.getPosition(); - pos = MRK(pos); - // *** UNDO RECORDING - if (this.__preventUndo == 0) - this._recordChange(1, pos, text.length); - var rc = pos == this.point() ? this._rowcol : this._positionToRowCol(pos), - i = rc.row; - if (/^\n+$/.test(text) && rc.col == 0) { - // handle this case separately, since it's so - // frequently used (ENTER pressed) and the - // default algorithm messes up colorization - // for a fraction of a second, flashing badly. - text.length.times(function(j){ - this._insertLine(i + j, ""); - }, this); - } else { - var lines = text.split("\n"), ln = this.code[i], rest = ln.substr(rc.col); - if (lines.length > 1) { - this._replaceLine(i, ln.substr(0, rc.col) + lines.shift()); - lines.foreach(function(text){ - this._insertLine(++i, text); - }, this); - this._replaceLine(i, this.code[i] + rest); - } else { - this._replaceLine(i, ln.substr(0, rc.col) + lines[0] + ln.substr(rc.col)); - } - } - this._updateMarkers(pos, text.length); - this.callHooks("onTextInsert", pos, text); - }; - - P._deleteText = function(begin, end) { - begin = this._boundPosition(MRK(begin)); - end = this._boundPosition(MRK(end)); - if (begin == end) - return; - if (end < begin) { var tmp = begin; begin = end; end = tmp; } - // *** UNDO RECORDING - if (this.__preventUndo == 0) - this._recordChange(2, begin, end - begin, this._bufferSubstring(begin, end)); - var brc = this._positionToRowCol(begin), - erc = this._positionToRowCol(end); - var line = this.code[brc.row]; - if (brc.row == erc.row) { - // same line, that's easy - line = line.substr(0, brc.col) + line.substr(erc.col); - this._replaceLine(brc.row, line); - } else { - // fix first line - line = line.substr(0, brc.col) + this.code[erc.row].substr(erc.col); - this._replaceLine(brc.row, line); - // delete lines in between - line = brc.row + 1; - (erc.row - brc.row).times(this._deleteLine.$(this, line)); - } - this._updateMarkers(begin, begin - end, begin); - this.callHooks("onTextDelete", begin, end); - }; - - P._replaceText = function(begin, end, text) { - this._deleteText(begin, end); - this._insertText(text, begin); - }; - - P._swapAreas = function(a) { - a = a.map(MRK).mergeSort(); - var b1 = a[0], - e1 = a[1], - b2 = a[2], - e2 = a[3], - t1 = this._bufferSubstring(b1, e1), - t2 = this._bufferSubstring(b2, e2); - this._replaceText(b2, e2, t1); - this._replaceText(b1, e1, t2); - return e2; - }; - - P._bufferSubstring = function(begin, end) { - if (begin == null) begin = this.point(); - else begin = MRK(begin); - - if (end == null) end = this.getCodeSize(); - else end = MRK(end); - - if (end < begin) { var tmp = begin; begin = end; end = tmp; } - // var brc = this._positionToRowCol(begin), - // erc = this._positionToRowCol(end); - // if (brc.row == erc.row) { - // return this.code[brc.row].substring(brc.col, erc.col); - // } else return [ this.code[brc.row].substr(brc.col) ]. - // concat(this.code.slice(brc.row + 1, erc.row)). - // concat(this.code[erc.row].substr(0, erc.col)). - // join("\n"); - return this.getCode().substring(begin, end); - }; - - P._killingAction = function(p1, p2, prepend, noDelete) { - p1 = MRK(p1); - p2 = MRK(p2); - var text = this._bufferSubstring(p1, p2); - this._saveKilledText(text, prepend); - if (!noDelete) - this._deleteText(p1, p2); - }; - - P._saveKilledText = function(text, prepend) { - if (!this._lastCommandWasKill) - this.ymacs.killRingToMaster(); - this.ymacs.pushToKillRing(text, prepend); - this._lastCommandWasKill++; - }; - - P._positionToRowCol = function(pos) { - var line = 0, a = this.code, n = a.length; - while (pos > 0 && line < n) { - var len = a[line].length; - if (len >= pos) - break; - pos -= len + 1; // one for the newline - line++; - } - return { row: line, col: pos }; - }; - - P._rowColToPosition = function(row, col) { - var pos = 0, a = this.code, i = Math.min(row, a.length - 1), n = i; - if (i < 0) - return 0; - while (--i >= 0) - pos += a[i].length + 1; // one for the newline - return pos + Math.min(col, a[n].length); - }; - - P._boundPosition = function(pos) { - if (pos < 0) - return 0; - return Math.min(pos, this.getCodeSize()); - }; - - P._repositionCaret = function(pos) { - var p = this.caretMarker.getPosition(); - if (pos == null) - pos = p; - pos = MRK(pos); - pos = this._boundPosition(pos); - this.caretMarker.setPosition(pos); - return pos != p; - }; - - P._updateMarkers = function(offset, delta, min) { - this.__size = null; - this.__code = null; - // if (this.__undoInProgress == 0) { - this.markers.map("editorChange", offset, delta, min || 0); - // } - if (this.tokenizer) { - this.tokenizer.quickUpdate(Math.min(offset, offset + delta)); - } - }; - - P._saveExcursion = function(cont, markerBefore) { - var tmp = this.createMarker(null, markerBefore); - ++this.__savingExcursion; - try { - return cont.call(this); - } finally { - --this.__savingExcursion; - this.caretMarker.swap(tmp, false, true); - tmp.destroy(); - } - }; - - P._disableUndo = function(cont) { - ++this.__preventUndo; - try { - return cont.call(this); - } finally { - --this.__preventUndo; - } - }; - - P._handleKeyEvent = function(ev) { - var handled = false; - this.interactiveEvent(ev); - var lcwk = this._lastCommandWasKill; - - if (this.__nextIsMeta) - ev.altKey = true; - this.__nextIsMeta = false; - - var key = Ymacs_Keymap.unparseKey(ev); - var cc = this.currentKeys; - var foundPrefix = false; - cc.push(key); - - this.keymap.r_foreach(function(km){ - var h = km.getHandler(cc); - if (h instanceof Array) { - this.callInteractively(h[0], h[1]); - handled = true; - } - else if (h) { - handled = foundPrefix = true; - } - else if (key === "ESCAPE") { - this.__nextIsMeta = true; - handled = true; - } - else if (km.defaultHandler && cc.length == 1) { - handled = this.callInteractively(km.defaultHandler[0], km.defaultHandler[1]); - } - if (handled) - $BREAK(); - }, this); - - if (!foundPrefix) { - if (!handled) { - if (cc.length > 1) { - this.signalError(cc.join(" ").bold() + " is undefined", true); - handled = true; - } - } - cc.splice(0, cc.length); - } - - if (this._lastCommandWasKill == lcwk && typeof handled != "object") { - // selecting a prefix keymap shouldn't clear the killRing - this._lastCommandWasKill = 0; - } - - this.callHooks("finishedEvent", handled); - this.interactiveEvent(null); - return handled; - }; - - P._on_tokenizerFoundToken = function(row, c1, c2, what) { - if (what) { - this._textProperties.addLineProps(row, c1, c2, "css", what); - } else { - this._textProperties.removeLineProps(row, c1, c2, "css"); - } - }; - - P._on_textPropertiesChange = function(row) { - if (this.__preventUpdates == 0) { - this.callHooks("onLineChange", row); - } else { - this.__dirtyLines[row] = true; - } - }; - - P.formatLineHTML = function(row, caret) { - var rc = this._rowcol; - if (caret instanceof Ymacs_Marker) - rc = caret.getRowCol(); - caret = row == rc.row ? rc.col : null; - return this._textProperties.getLineHTML(row, this.code[row], caret); - }; - -}); diff --git a/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-commands-utils.js.svn-base b/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-commands-utils.js.svn-base deleted file mode 100644 index 04d3d36..0000000 --- a/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-commands-utils.js.svn-base +++ /dev/null @@ -1,157 +0,0 @@ -//> This file is part of Ymacs, an Emacs-like editor for the Web -//> http://www.ymacs.org/ -//> -//> Copyright (c) 2009-2010, Mihai Bazon, Dynarch.com. All rights reserved. -//> -//> Redistribution and use in source and binary forms, with or without -//> modification, are permitted provided that the following conditions are -//> met: -//> -//> * Redistributions of source code must retain the above copyright -//> notice, this list of conditions and the following disclaimer. -//> -//> * Redistributions in binary form must reproduce the above copyright -//> notice, this list of conditions and the following disclaimer in -//> the documentation and/or other materials provided with the -//> distribution. -//> -//> * Neither the name of Dynarch.com nor the names of its contributors -//> may be used to endorse or promote products derived from this -//> software without specific prior written permission. -//> -//> THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY -//> EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -//> IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -//> PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE -//> FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -//> CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -//> SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -//> INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -//> CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -//> ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF -//> THE POSSIBILITY OF SUCH DAMAGE. - -// @require ymacs-buffer.js - -Ymacs_Buffer.newCommands({ - - get_region: function() { - return this.getRegion(); - }, - - cperl_lineup: Ymacs_Interactive("r", function(begin, end){ - this.cmd("save_excursion", function(){ - var rcend = this._positionToRowCol(end), max = 0, lines = []; - this.cmd("goto_char", begin); - this.cmd("forward_whitespace", true); - var ch = this.charAt(); - if (ch.toLowerCase() != ch.toUpperCase()) { - this.signalError("Cannot lineup here"); - return; - } - while (this._rowcol.row <= rcend.row) { - var pos = this.getLine().indexOf(ch); - if (pos >= 0) { - if (pos > max) - max = pos; - lines.push([ this._rowcol.row, pos ]); - } - if (!this.cmd("forward_line")) - break; - } - ++max; - lines.foreach(function(l){ - this.cmd("goto_char", this._rowColToPosition(l[0], l[1])); - this.cmd("insert", " ".x(max - l[1])); - }, this); - }); - }), - - htmlize_region: Ymacs_Interactive("r\nP", function(begin, end, lineNum) { - this.tokenizer.finishParsing(); - var row = this._positionToRowCol(begin).row, - html = String.buffer(), - line = row, pad; - if (lineNum && !lineNum.empty) - line = parseInt(lineNum, 10); - end = this._positionToRowCol(end).row; - pad = String(end).length; - while (row <= end) { - html("<div class='line'>"); - if (lineNum) - html("<span class='line-number'>", line.zeroPad(pad, " "), "</span>"); - ++line; - html(this._textProperties.getLineHTML(row, this.code[row], null), "</div>\n"); - ++row; - } - html = html.get(); - var tmp = this.ymacs.switchToBuffer("*Htmlize*"); - tmp.setCode(html); - tmp.cmd("xml_mode", true); - }), - - execute_extended_command: Ymacs_Interactive("^CM-x ", function(cmd) { - this.callInteractively(cmd); - }), - - set_variable: Ymacs_Interactive("vSet variable: \nsTo value: ", function(variable, value) { - var tmp = parseFloat(value); - if (!isNaN(tmp)) - value = tmp; - this.setq(variable, value); - }), - - eval_string: Ymacs_Interactive("^MEval string: ", function(code){ - try { - var variables = [ - this, // buffer - this.ymacs // ymacs - ]; - code = new Function("buffer", "ymacs", code); - code.apply(this, variables); - this.clearTransientMark(); - } catch(ex) { - this.signalError(ex.type + ": " + ex.message); - if (window.console) - console.log(ex); - } - }), - - eval_region: Ymacs_Interactive("^r", function(begin, end) { - this.cmd("eval_string", this.cmd("buffer_substring", begin, end)); - }), - - eval_buffer: Ymacs_Interactive(function(){ - this.cmd("eval_string", this.getCode()); - }), - - toggle_line_numbers: Ymacs_Interactive("^", function(){ - this.whenActiveFrame("toggleLineNumbers"); - }), - - save_file: Ymacs_Interactive("FWrite file: ", function(name){ - var files = this.ymacs.ls_getFileDirectory(name, "file"); - files.dir[files.other[0]] = this.getCode(); - this.ymacs.ls_set(files.store); - this.signalInfo("Saved in local storage"); - }), - - load_file: Ymacs_Interactive("fFind file: ", function(name){ - var code = this.ymacs.ls_getFileContents(name); - var buffer = this.ymacs.createBuffer({ name: name }); - buffer.setCode(code); - this.cmd("switch_to_buffer", name); - }), - - delete_file: Ymacs_Interactive("fDelete file: ", function(name){ - this.ymacs.ls_getFileContents(name); - var files = this.ymacs.ls_get(); - delete files[name]; - this.ymacs.ls_set(files); - }), - - eval_file: Ymacs_Interactive("fEval file: ", function(name){ - this.cmd("eval_string", this.ymacs.ls_getFileContents(name)); - }) - -}); diff --git a/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-commands.js.svn-base b/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-commands.js.svn-base deleted file mode 100644 index 93190e0..0000000 --- a/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-commands.js.svn-base +++ /dev/null @@ -1,1491 +0,0 @@ -//> This file is part of Ymacs, an Emacs-like editor for the Web -//> http://www.ymacs.org/ -//> -//> Copyright (c) 2009-2010, Mihai Bazon, Dynarch.com. All rights reserved. -//> -//> Redistribution and use in source and binary forms, with or without -//> modification, are permitted provided that the following conditions are -//> met: -//> -//> * Redistributions of source code must retain the above copyright -//> notice, this list of conditions and the following disclaimer. -//> -//> * Redistributions in binary form must reproduce the above copyright -//> notice, this list of conditions and the following disclaimer in -//> the documentation and/or other materials provided with the -//> distribution. -//> -//> * Neither the name of Dynarch.com nor the names of its contributors -//> may be used to endorse or promote products derived from this -//> software without specific prior written permission. -//> -//> THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY -//> EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -//> IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -//> PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE -//> FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -//> CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -//> SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -//> INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -//> CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -//> ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF -//> THE POSSIBILITY OF SUCH DAMAGE. - -// @require ymacs-buffer.js - - -Ymacs_Buffer.newCommands({ - - forward_char: Ymacs_Interactive("p", function(x) { - if (x == null) x = 1; - return this.cmd("goto_char", this.point() + x); - }), - - backward_char: Ymacs_Interactive("p", function(x) { - if (x == null) x = 1; - return this.cmd("forward_char", -x); - }), - - forward_line: Ymacs_Interactive("p", function(x) { - if (x == null) x = 1; - var rc = this._rowcol; - if (!/^(forward|backward)_line$/.test(this.previousCommand)) { - this.setq("line_movement_requested_col", rc.col); - } - var ret = this.cmd("goto_char", - this._rowColToPosition(rc.row + x, - Math.max(rc.col, - this.getq("line_movement_requested_col")))); // starting to look like Lisp, eh? - if (!ret) - this.setq("line_movement_requested_col", rc.col); - return ret; - }), - - backward_line: Ymacs_Interactive("p", function(x) { - if (x == null) x = 1; - return this.cmd("forward_line", -x); - }), - - forward_whitespace: Ymacs_Interactive("P", function(noLine) { - var re = noLine ? /[^\x20\t\xA0]/g : /[^\s]/g; - if (this.cmd("search_forward_regexp", re)) { - this.cmd("backward_char"); - return true; - } else if (!noLine) - return this.cmd("end_of_buffer"); - }), - - backward_whitespace: Ymacs_Interactive("P", function(noLine) { - var re = noLine ? /[^\x20\t\xA0]/g : /[^\s]/g; - if (this.cmd("search_backward_regexp", re)) { - this.cmd("forward_char"); - return true; - } else if (!noLine) - return this.cmd("beginning_of_buffer"); - }), - - beginning_of_line: Ymacs_Interactive(function() { - return this.cmd("goto_char", this._rowColToPosition(this._rowcol.row, 0)); - }), - - back_to_indentation: Ymacs_Interactive(function() { - var rc = this._rowcol, line = this.code[rc.row], m = /\S/.exec(line); - if (m) - return this.cmd("goto_char", this._rowColToPosition(rc.row, m.index)); - }), - - beginning_of_indentation_or_line: Ymacs_Interactive(function() { - return this.cmd("back_to_indentation") || this.cmd("beginning_of_line"); - }), - - end_of_line: Ymacs_Interactive(function() { - var rc = this._rowcol; - return this.cmd("goto_char", this._rowColToPosition(rc.row, this.code[rc.row].length)); - }), - wrap : Ymacs_Interactive(function() { - var i = 0; - this.cmd("end_of_buffer"); - var st1 = this.caretMarker.getPosition(); - this.cmd("beginning_of_buffer"); - if(st1 != 0) - { - while(i < 50 ) - { - this.cmd("goto_line", i); - i= i+1; - rc = this._rowcol; - var line = this.code[rc.row]; - var line_size = line.length; - if(line_size > 112) - { - this.cmd("move_to_column", 111); - this.cmd("insert", "\n"); - this.cmd("forward_line"); - } - } - - } - - }), - - - wrap_at_edge : Ymacs_Interactive(function() { - rc = this._rowcol; - var line = this.code[rc.row]; - var str1 = line.length; - if(str1 > 112) - { - this.cmd("insert", "\n"); - } - }), - - wrap_status:Ymacs_Interactive(function() { - var one = flag; - //alert("inside wrap_status"); - return one; - }), - - word_wrap : Ymacs_Interactive(function() { - - var one1 = this.cmd("wrap_status"); - if(one1 == "Word Wrap") - { - var x = 112; - rc = this._rowcol; - var line = this.code[rc.row]; - var str1 = line.length; - if(str1 > x) - { - var str2 = line.slice(0,str1-2); - var str3 = str2.lastIndexOf(" "); - this.cmd("move_to_column", str3+1); - this.cmd("insert", "\n"); - this.cmd("end_of_line"); - this.cmd("insert", " "); - } - else - { - this.cmd("insert", " "); - } - } - else - { - - this.cmd("insert", " "); - } - - - }), - - - wrap1:Ymacs_Interactive(function() { - var i = 1; - this.cmd("end_of_buffer"); - var str1 = this.caretMarker.getPosition(); - //this.cmd("beginning_of_buffer"); - if(str1 != 0) - { - while(i < 50 ) - { - this.cmd("goto_line" ,i); - i=i+1; - rc = this._rowcol; - var line = this.code[rc.row]; - var str2 = line.lastIndexOf(" "); - if(str2 > 112) - { - var str2 = line.slice(0,115); - var str3 = str2.lastIndexOf(" "); - this.cmd("move_to_column", str3+1); - this.cmd("insert", "\n"); - this.cmd("forward_line"); - } - } - } - - }), - - - beginning_of_buffer: Ymacs_Interactive(function() { - return this.cmd("goto_char", 0); - }), - - end_of_buffer: Ymacs_Interactive(function() { - return this.cmd("goto_char", this.getCodeSize()); - }), - - eob_p: function() { - return this.point() == this.getCodeSize(); - }, - - bob_p: function() { - return this.point() == 0; - }, - - eol_p: function() { - var rc = this._positionToRowCol(this.point()); - return rc.col == this.code[rc.line].length; - }, - - bol_p: function() { - return this._positionToRowCol(this.point()).col == 0; - }, - - backward_delete_char: Ymacs_Interactive("^p", function(n){ - if (!this.deleteTransientRegion()) { - if (n == null) n = 1; - var pos = this.point(); - if (pos > 0) - this._deleteText(pos - n, pos); - } - }), - - delete_char: Ymacs_Interactive("^p", function(n){ - if (!this.deleteTransientRegion()) { - if (n == null) n = 1; - var pos = this.point(); - this._deleteText(pos, pos + n); - } - }), - - delete_whitespace: Ymacs_Interactive("^P", function(noLine) { - if (!this.deleteTransientRegion()) { - var p = this.point(); - if (this.cmd("forward_whitespace", noLine)) { - this._deleteText(p, this.point()); - return true; - } - } - }), - - backward_delete_whitespace: Ymacs_Interactive("^P", function(noLine) { - if (!this.deleteTransientRegion()) { - var p = this.point(); - if (this.cmd("backward_whitespace", noLine)) { - this._deleteText(this.point(), p); - return true; - } - } - }), - - universal_argument: Ymacs_Interactive("^", function(){ - this.pushKeymap(Ymacs_Keymap_UniversalArgument()); - if (!this.isMinibuffer) - this.setMinibuffer("C-u"); - }), - - overwrite_mode: Ymacs_Interactive(function() { - this.resetOverwriteMode(); - }), - - self_insert_command: Ymacs_Interactive("^p", function(repeat) { - var ev = this.interactiveEvent(), - ch = String.fromCharCode(ev.charCode), - rc = this._rowcol; - if (ev.charCode && ch && !ev.altKey && !ev.ctrlKey) { - this.deleteTransientRegion(); - if (repeat != null) - ch = ch.x(repeat); - if (this.overwriteMode) { - var line = this.code[rc.row], left = line.length - rc.col; - if (left > 0) - this.cmd("delete_char", Math.min(left, repeat || 1)); - } - this.cmd("insert", ch); - ev.domStop = true; - return true; - } - return false; - }), - - newline: Ymacs_Interactive("^p", function(n){ - if (n == null) n = 1; - this.deleteTransientRegion(); - this.cmd("insert", "\n".x(n)); - }), - - - newline_and_indent: Ymacs_Interactive("^p", function(n){ - if (n) { - this.cmd("newline", n); - } else { - this.cmd("backward_delete_whitespace", true); - this.cmd("newline"); - this.cmd("indent_line"); - } - }), - - -// tab is not working on the 1st position of the buffer -// user should create table from 1st position only - - indent_line: Ymacs_Interactive("P", function(noEmpty) { - if (this.tokenizer) { - var indent = this.tokenizer.getIndentation(this._rowcol.row, this); - var a = " "; - if (indent != null) { - if (!noEmpty || /\S/.test(this.getLine())) { - var pos = this.cmd("save_excursion", function(){ - - if (this._rowcol.col != indent) { - - - var pos1 = this.caretMarker.getPosition(); - //alert(pos1); - this.cmd("beginning_of_line"); - - var pos2 = this.caretMarker.getPosition(); - - var char1 = this.charAt(pos2); - this.cmd("forward_paragraph"); - this.cmd("backward_line"); - this.cmd("end_of_line"); - var para_end1 = this.caretMarker.getPosition(); - var para_end2 = (para_end1 - 1); - - - // identifying table or text - - if (char1 == "|"){ - this.cmd("goto_char",pos1); - this.cmd("end_of_line"); - var end_line1 = this.caretMarker.getPosition(); - var end_line2 =(end_line1 - 1); - for( var a1=1;a1<113;a1=a1+1){ - - var pos3 = (pos1 + a1); - //alert(pos3); - var char2 = this.charAt(pos3); - // checks end of the table - if (char2 == "|"){ - if (char2 == "|" && pos3 == para_end2) - {this.cmd("goto_char",pos3); - //this.point(); - this.cmd("beginning_of_line"); - var B11 = this.caretMarker.getPosition(); - //alert(B1); - this.cmd("end_of_line"); - var P11 = this.caretMarker.getPosition(); - //alert(P1); - var count1=0; - for(i=B11;i<=P11;i=i+1) - { - var c11=this.charAt(i); - if(c11=="|") - {count1=count1 + 1;} - - } - - var count2 = (count1 - 1); - this.cmd("newline"); - for(i=1;i<=count2;i=i+1) - { - this.cmd("org_table_create");} - this.cmd("insert","|"); - this.cmd("beginning_of_line"); - this.cmd("forward_char"); - } - // checks row or table end - else if(char2 == "|" && end_line2 == pos3) - { this.cmd("forward_line"); - this.cmd("beginning_of_line"); - var beg = this.caretMarker.getPosition(); - var a11= this.charAt(beg); - if(a11 == "|"){ - //alert(a11); - var beg1 = (beg + 1); - this.cmd("goto_char",beg1);} - else - {//alert("table-end"); - this.cmd("goto_char",pos1); - var r_count = 1; - for(i=0;i<=5;i=i+1) - { - this.cmd("backward_line"); - this.cmd("beginning_of_line"); - var c_row = this.caretMarker.getPosition(); - this.cmd("goto_char",c_row); - var ch_row = this.charAt(c_row); - // alert(ch_row); - - if (ch_row == "|") - { r_count = r_count + 1 ; - - }else - break; - }//alert("no_of_rows:" +r_count); - - - this.cmd("goto_char",pos3); - //this.point(); - this.cmd("beginning_of_line"); - var B1 = this.caretMarker.getPosition(); - //alert(B1); - this.cmd("end_of_line"); - var P1 = this.caretMarker.getPosition(); - //alert(P1); - var count=0; - for(i=B1;i<=P1;i=i+1) - { - var c1=this.charAt(i); - if(c1=="|") - {count=count + 1;} - - } - var count_n = (count -1); - //alert(count); - this.cmd("newline"); - for(i=1;i<=count_n;i=i+1) - {this.cmd("org_table_create");} - this.cmd("insert","|"); - this.cmd("beginning_of_line"); - this.cmd("forward_char"); - } - - } - else if (char2 == "|") - { - - var pos31 = (pos3 + 1); - this.cmd("goto_char",pos31); - - }break;}} - - - } - // for text gives 4 spaces - else { - this.cmd("goto_char",pos1); - this.cmd("insert",a);} - - } - return this.point(); - }); - // when point is before the indentation, go there. - if (this.point() < pos) - this.cmd("goto_char", pos); - } - return; - } - } - this.cmd("insert", " ".x(this.getq("indent_line"))); - }), - indent_region: Ymacs_Interactive("r", function(begin, end) { - if (end < begin) { var tmp = begin; begin = end; end = tmp; } - this.cmd("save_excursion", function() { - var m = this.createMarker(end); - this.cmd("goto_char", begin); - while (this.point() < m.getPosition()) { - this.cmd("indent_line", true); - this.cmd("beginning_of_line"); - if (!this.cmd("forward_line")) - break; - }; - m.destroy(); - }); - }), - - make_marker: function(pos) { - return this.createMarker(pos); - }, - - looking_at: function(rx) { - var pos = rx.lastIndex = this.point(); - var ret = this.matchData = rx.exec(this.getCode()); - if (ret) - ret.after = rx.lastIndex; - return ret && ret.index == pos; - }, - - looking_back: function(rx) { - var m = this.lastIndexOfRegexp(this.getCode(), rx, this.point()); - return m && m.after == this.point(); - }, - - search_forward: Ymacs_Interactive("sSearch: ", function(str, bound) { - var code = this.getCode(), point = this.point(); - if (this.getq("case_fold_search")) { - code = code.toLowerCase(); - str = str.toLowerCase(); - } - var pos = code.indexOf(str, point); - if (pos >= 0 && (bound == null || pos <= bound)) { - this.cmd("goto_char", pos + str.length); - return true; - } - }), - - search_backward: Ymacs_Interactive("sSearch backward: ", function(str, bound) { - var code = this.getCode(), point = this.point(); - if (this.getq("case_fold_search")) { - code = code.toLowerCase(); - str = str.toLowerCase(); - } - var pos = code.lastIndexOf(str, point); - if (pos == point) - pos = code.lastIndexOf(str, point - 1); - if (pos >= 0 && pos != point && (bound == null || pos >= bound)) { - this.cmd("goto_char", pos); - return true; - } - }), - - make_regexp: function(rx) { - if (!(rx instanceof RegExp)) { - var matchCase = rx.toLowerCase() != rx.toUpperCase(); - try { - rx = new RegExp(rx, matchCase ? "ig" : "g"); - } catch(ex) { - throw new Ymacs_Exception("Invalid regexp"); - } - } - return rx; - }, - - search_forward_regexp: Ymacs_Interactive("sRegExp search: ", function(rx) { - rx = this.cmd("make_regexp", rx); - var code = this.getCode(), - pos = rx.lastIndex = this.point(), - ret = this.matchData = rx.exec(code); - if (ret && rx.lastIndex != pos) { - ret.after = rx.lastIndex; - this.cmd("goto_char", rx.lastIndex); - return true; - } - }), - - search_backward_regexp: Ymacs_Interactive("sBackward RegExp search: ", function(rx) { - rx = this.cmd("make_regexp", rx); - var m = this.lastIndexOfRegexp(this.getCode(), rx, this.point()); - if (m && m.index != this.point()) { - this.cmd("goto_char", m.index); - return true; - } - }), - - forward_word: Ymacs_Interactive_X(function(){ - var word = this.getq("syntax_word"), end = false; - while (!end && !word.test(this.charAt())) - if (!this.cmd("forward_char")) - end = true; - while (!end && word.test(this.charAt())) - if (!this.cmd("forward_char")) - end = true; - }), - - backward_word: Ymacs_Interactive_X(function(){ - var word = this.getq("syntax_word"), end = false; - while (!end && !word.test(this.charAt(-1))) - if (!this.cmd("backward_char")) - end = true; - while (!end && word.test(this.charAt(-1))) - if (!this.cmd("backward_char")) - end = true; - }), - - forward_paragraph: Ymacs_Interactive_X(function(){ - this.cmd("forward_whitespace"); - if (this.cmd("search_forward_regexp", this.getq("syntax_paragraph_sep"))) - this.cmd("goto_char", this.cmd("match_beginning") + 1); - else - this.cmd("end_of_buffer"); - }), - - backward_paragraph: Ymacs_Interactive_X(function(){ - this.cmd("backward_whitespace"); - if (this.cmd("search_backward_regexp", this.getq("syntax_paragraph_sep"))) - this.cmd("goto_char", this.cmd("match_end") - 1); - else - this.cmd("beginning_of_buffer"); - }), - - transpose_words: Ymacs_Interactive_X(function() { - // if we're in the middle of a word, some - // weird things happen; better skip it, just - // like Emacs does. - this.cmd("backward_char"); - if (this.getq("syntax_word").test(this.charAt())) - this.cmd("forward_word"); - - var a = []; - this.cmd("forward_word"); a.push(this.point()); - this.cmd("backward_word"); a.push(this.point()); - this.cmd("backward_word"); a.push(this.point()); - this.cmd("forward_word"); a.push(this.point()); - this.cmd("goto_char", this._swapAreas(a)); - }), - - transpose_lines: Ymacs_Interactive_X(function() { - var a = []; - //alert(a[0]); - this.cmd("backward_line"); - this.cmd("beginning_of_line"); a.push(this.point()); - this.cmd("end_of_line"); a.push(this.point()); - this.cmd("forward_char"); a.push(this.point()); - this.cmd("end_of_line"); a.push(this.point()); - this.cmd("goto_char", this._swapAreas(a)); - }), - - transpose_para: Ymacs_Interactive_X(function() { - var a = []; - //alert(a[0]); - this.cmd("backward_paragraph"); - // this.cmd("backward_line"); - this.cmd("forward_line"); a.push(this.point()); - this.cmd("forward_paragraph"); - this.cmd("backward_char"); a.push(this.point()); - this.cmd("forward_whitespace"); a.push(this.point()); - this.cmd("forward_paragraph"); - this.cmd("backward_char");a.push(this.point()); - this.cmd("goto_char", this._swapAreas(a)); - }), - - transpose_text: Ymacs_Interactive_X(function() { - var a = []; - //alert(a[0]); - this.cmd("beginning_of_line"); - this.cmd("backward_paragraph"); - this.cmd("forward_line"); - this.cmd("forward_char"); - this.cmd("forward_char"); a.push(this.point()); - this.cmd("forward_paragraph"); - this.cmd("backward_char"); a.push(this.point()); - this.cmd("forward_whitespace"); - this.cmd("forward_char"); - this.cmd("forward_char");a.push(this.point()); - this.cmd("forward_paragraph"); - this.cmd("backward_char");a.push(this.point()); - this.cmd("goto_char", this._swapAreas(a)); - }), - - transpose_chars: Ymacs_Interactive_X(function() { - var pos = this.point(); - if (this.cmd("backward_char")) - this.cmd("goto_char", this._swapAreas([ pos - 1, pos, pos, pos + 1 ])); - }), - - kill_word: Ymacs_Interactive_X(function() { - var pos = this.point(); - this.cmd("forward_word"); - var pos2 = this.point(); - this._killingAction(pos, pos2, false); - }), - - backward_kill_word: Ymacs_Interactive_X(function() { - var pos = this.point(); - this.cmd("backward_word"); - var pos2 = this.point(); - this._killingAction(pos, pos2, true); - }), - - _apply_operation_on_word: function (op, cc) { - var pos = this.point(); - if (this.getq("syntax_word").test(this.charAt())) { - var pos2 = this.cmd("save_excursion", function(){ - this.cmd("forward_word"); - return this.point(); - }); - var word = op.call(this._bufferSubstring(pos, pos2)); - this._deleteText(pos, pos2); - this._insertText(word); - } else { - this.cmd("forward_word"); - this.cmd("backward_word"); - if (pos != this.point()) - this.cmd(cc); - } - }, - - capitalize_word: Ymacs_Interactive_X(function() { - this.cmd("_apply_operation_on_word", function() { - return this.charAt(0).toUpperCase() + this.substr(1).toLowerCase(); - }, "capitalize_word"); - }), - - downcase_word: Ymacs_Interactive_X(function() { - this.cmd("_apply_operation_on_word", String.prototype.toLowerCase, "downcase_word"); - }), - - upcase_word: Ymacs_Interactive_X(function() { - this.cmd("_apply_operation_on_word", String.prototype.toUpperCase, "upcase_word"); - }), - - goto_char: Ymacs_Interactive("NGoto char: ", function(pos){ - return this._repositionCaret(pos); - }), - - goto_line: Ymacs_Interactive("NGoto line: ", function(row){ - var pos = this._rowColToPosition(row - 1, 0); - return this.cmd("goto_char", pos); - }), - - move_to_column: Ymacs_Interactive("NMove to column: ", function(col, force){ - var rc = this._positionToRowCol(this.point()); - var text = this.code[rc.row]; - if (text.length < col) { - if (force) { - this.cmd("end_of_line"); - this.cmd("insert", " ".x(col - text.length)); - } else { - this.cmd("end_of_line"); - } - } else { - this.cmd("goto_char", this._rowColToPosition(rc.row, col)); - } - }), - - delete_region: Ymacs_Interactive("r", function(begin, end){ - this._deleteText(begin, end); - }), - - insert: Ymacs_Interactive("sInsert text: ", function(){ - return this._insertText(Array.$(arguments).join("")); - }), - - keyboard_quit: Ymacs_Interactive("^p", Function.noop), - - buffer_substring: function(begin, end) { - if (arguments.length == 0) { - var r = this.getRegion(); - begin = r.begin; - end = r.end; - } - return this._bufferSubstring(begin, end); - }, - - kill_line: Ymacs_Interactive_X(function() { - var pos = this.point(), - rc = this._rowcol, - line = this.code[rc.row], - end = pos + line.length - rc.col; - if (rc.row < this.code.length - 1 && this.cmd("looking_at", /\s*$/mg)) - end++; - this._killingAction(pos, end); - }), - - save_excursion: function() { - return this._saveExcursion.apply(this, arguments); - }, - - prevent_undo: function() { - return this._disableUndo.apply(this, arguments); - }, - - point: function() { - return this.caretMarker.getPosition(); - }, - - kill_region: Ymacs_Interactive("r", function(begin, end){ - this._killingAction(begin, end); - }), - - copy_region_as_kill: Ymacs_Interactive("r", function(begin, end){ - this._killingAction(begin, end, false, true); - }), - - yank: Ymacs_Interactive("^P", function(atStart){ - this.deleteTransientRegion(); - var point = this.point(); - this._insertText(this.ymacs.killRingText()); - this.cmd("set_mark_command", point); - if (atStart) - this.cmd("exchange_point_and_mark"); - }), - - yank_pop: Ymacs_Interactive(function() { - if (/^yank/.test(this.previousCommand)) { - this.ymacs.rotateKillRing(false); - this._deleteText(this.caretMarker, this.markMarker); - this.cmd("yank"); - } else { - this.signalError("Previous command was not a yank"); - } - }), - - yank_shift: Ymacs_Interactive(function() { - if (/^yank/.test(this.previousCommand)) { - this.ymacs.rotateKillRing(true); - this._deleteText(this.caretMarker, this.markMarker); - this.cmd("yank"); - } else { - this.signalError("Previous command was not a yank"); - } - }), - - mark: function() { - return this.markMarker.getPosition(); - }, - - set_mark_command: Ymacs_Interactive("d", function(x){ - if (this.currentCommand == "set_mark_command") - this.signalInfo("Mark set", null, 1000); - this.markMarker.setPosition(x); - }), - - exchange_point_and_mark: Ymacs_Interactive("^", function(){ - this.caretMarker.swap(this.markMarker); - }), - - mark_whole_buffer: Ymacs_Interactive(function(){ - this.clearTransientMark(); - this.cmd("end_of_buffer"); - this.ensureTransientMark(); - this.cmd("beginning_of_buffer"); - this.ensureTransientMark(); - }), - - // <XXX>: the following two kind of suck - - recenter_top_bottom: Ymacs_Interactive(function() { - this.whenActiveFrame(function(frame){ - frame.ensureCaretVisible(true); - frame.centerOnCaret(); - }); - }), - - ensure_caret_visible: Ymacs_Interactive(function() { - this.whenActiveFrame(function(frame){ - // frame.centerOnCaretIfNotVisible(); - frame.ensureCaretVisible(true); - frame.centerOnCaret(); - }); - }), - - // </XXX> - - /* -----[ paragraphs ]----- */ - - fill_paragraph: Ymacs_Interactive("P", function(noPrefix) { - this.cmd("save_excursion", function(){ - if (!this.cmd("looking_at", this.getq("syntax_paragraph_sep"))) - this.cmd("forward_paragraph"); - var eop = this.createMarker(this.point() - 1); - this.cmd("backward_paragraph"); - if (this.point() > 0) - this.cmd("forward_char"); - - // identify the prefix to use for each line - var prefix = "", del = false; - if (this.cmd("looking_at", /\s*([-]|[0-9]+\.|\(?[a-z][\).])?\s+/ig)) { - prefix = " ".x(this.matchData[0].length); - del = /\s*[#>;\s]*\s*/g; - } - else if (this.cmd("looking_at", /\s*[#>;*\s]+\s*/g)) { - prefix = this.matchData[0]; - del = /\s*[#>;\s]*\s*/g; - } - - if (noPrefix) { - this._deleteText(this.point(), this.point() + this.matchData[0].length); - prefix = ""; - } - - // remove newlines first - while (true) { - this.cmd("end_of_line"); - this.cmd("backward_delete_whitespace"); - if (this.point() >= eop.getPosition()) - break; - this._replaceText(this.point(), this.point() + 1, " "); - if (del && this.cmd("looking_at", del)) { - this._deleteText(this.point(), this.point() + this.matchData[0].length); - } - } - - this.cmd("beginning_of_line"); - - // main operation - while (this.point() < eop.getPosition()) { - var p = this.point(); - if (!this.cmd("search_forward_regexp", /\s/g)) - break; - if (this.point() > eop.getPosition()) { - this.cmd("goto_char", eop); - } - if (this._rowcol.col > this.getq("fill_column")) { - this.cmd("goto_char", p); - this.cmd("backward_delete_whitespace"); - this.cmd("newline"); - this.cmd("insert", prefix); - } - } - - eop.destroy(); - - this.cmd("recenter_top_bottom"); - }); - }), - - fill_paragraph_no_prefix: Ymacs_Interactive(function() { - return this.cmd("fill_paragraph", true); - }), - - // this looks at the style of the current paragraph and starts - // a similar one, i.e. using same indentation level and prefix - // (list-like prefixes are incremented) - - - - - - sub_bullet: Ymacs_Interactive(function() { - this.cmd("backward_line"); - if (this.point() > 1) - this.cmd("forward_char"); - - // identify the prefix to use for each line - var prefix = "*"; - if (this.cmd("looking_at", /(\s*)([+#-])(\s)([a-z]+)/g)) { - - prefix = this.matchData[1]+this.matchData[2]; - //alert(prefix); - - } - - this.cmd("forward_line"); - if (this.cmd("eob_p")) - this.cmd("newline"); - // this.cmd("newline"); - - this.cmd("insert",prefix); - - if (!this.cmd("looking_at", /\n/g)) { - this.cmd("newline"); - this.cmd("backward_char"); - }; - }), - - start_next_paragraph: Ymacs_Interactive(function() { - this.cmd("backward_paragraph"); - if (this.point() > 1) - this.cmd("forward_char"); - - // identify the prefix to use for each line - var prefix = "*"; - if (this.cmd("looking_at", /(\s*)([0-9]+)(\.)(\s+)/g)) { - prefix = this.matchData[1] + - (parseInt(this.matchData[2], 10) + 1) + - this.matchData[3];//+this.matchdata[4];//+this.matchdata[5]; - - } - else if (this.cmd("looking_at", /(\s*\(?)([a-z])([\.\)]\s+)/ig)) { - prefix = this.matchData[1] + - String.fromCharCode(this.matchData[2].charCodeAt(0) + 1) + - this.matchData[3];//+this.matchdata[4];//+this.matchdata[5]; - - } - - - else if (this.cmd("looking_at", /[#>;*-]+/g)) { - prefix = this.matchData[0]; - - } - this.cmd("forward_paragraph"); - if (this.cmd("eob_p")) - this.cmd("newline"); - this.cmd("newline"); - - this.cmd("insert",prefix," "); - - if (!this.cmd("looking_at", /\n/g)) { - this.cmd("newline"); - this.cmd("backward_char"); - }; - }), - - scroll_down: Ymacs_Interactive_X(function() { - this.whenActiveFrame(function(frame){ - var hl = frame.heightInLines(); - this.cmd("forward_line", Math.round(hl / 1.33)); - this.cmd("recenter_top_bottom"); - }); - }), - - scroll_up: Ymacs_Interactive_X(function() { - this.whenActiveFrame(function(frame){ - var hl = frame.heightInLines(); - this.cmd("backward_line", Math.round(hl / 1.33)); - this.cmd("recenter_top_bottom"); - }); - }), - - nuke_trailing_whitespace: Ymacs_Interactive(function() { - this.cmd("save_excursion", function(){ - this.cmd("goto_char", 0); - while (this._rowcol.row < this.code.length) { - var line = this.code[this._rowcol.row], - m = /\s+$/.exec(line); - if (m) { - this.cmd("beginning_of_line"); - this._deleteText(this.point() + m.index, this.point() + line.length); - } - if (!this.cmd("forward_line")) - break; - } - }); - }), - - match_string: function(n) { - return this.matchData[n]; - }, - - match_beginning: function() { - return this.matchData.index; - }, - - match_end: function() { - return this.matchData.index + this.matchData[0].length; - }, - - undo: Ymacs_Interactive_X(function() { - var q = this.__undoQueue; - this.__undoQueue = this.__redoQueue; - this._placeUndoBoundary(); - if (!this._playbackUndo(q)) { - this.signalError("No further undo information"); - } - this.__undoQueue = q; - }), - - center_line: Ymacs_Interactive("p", function(n){ - if (n == null) n = 1; - n.times(function(i){ - if (i > 0) - this.cmd("forward_line"); - this.cmd("save_excursion", function(){ - this.cmd("end_of_line"); - this.cmd("backward_delete_whitespace", true); - this.cmd("beginning_of_line"); - this.cmd("delete_whitespace", true); - var line = this.code[this._rowcol.row]; - var indent = Math.floor((this.getq("fill_column") - line.length) / 2); - this.cmd("insert", " ".x(indent)); - }); - }, this); - }), - - /* -----[ dabbrev ]----- */ - - dabbrev_expand: Ymacs_Interactive_X(function() { - if (this.previousCommand != "dabbrev_expand") - this.setq("dabbrev_context", null); - - var ctx = this.getq("dabbrev_context"); - if (!ctx) { - ctx = this.setq("dabbrev_context", {}); - var p1 = this.cmd("save_excursion", function(){ - this.cmd("bind_variables", { - syntax_word: this.getq("syntax_word_dabbrev") - }, "backward_word"); - return this.point(); - }); - if (p1 == this.point()) - return this.signalError("Nothing to expand"); - ctx.search = this.cmd("buffer_substring", p1, this.point()); - ctx.point = p1; - ctx.length = this.point() - p1; - ctx.lastSearch = p1; - ctx.encountered = {}; - ctx.forward = false; - ctx.buffer = this; - ctx.startBuffer = this; - } - var expansion; - - // in the following excursion, *this* is ctx.buffer, - // not necessarily the currently active buffer. It's - // purpose is to determine the next expansion and - // setup the context so that the next invocation would - // continue. - ctx.buffer.cmd("save_excursion", function repeat(){ - var word = this.getq("syntax_word_dabbrev"); - var p1; - var found = false; - this.cmd("goto_char", ctx.lastSearch); - // console.log("last at: %d", ctx.lastSearch); - if (!ctx.forward) { - while (this.cmd("search_backward", ctx.search)) { - if (!word.test(this.charAt(-1))) { - found = true; - break; - } - } - if (found) { - p1 = this.point(); - ctx.lastSearch = p1; - this.cmd("goto_char", p1 + ctx.search.length); - } else { - ctx.forward = true; - ctx.lastSearch = ctx.point + ctx.length; - repeat.call(this); - return; - } - } else { - while (this.cmd("search_forward", ctx.search)) - if (!word.test(this.charAt(-ctx.search.length - 1))) { - found = true; - break; - } - if (found) { - ctx.lastSearch = this.point(); - p1 = this.point() - ctx.search.length; - } else { - ctx.buffer = this.whenYmacs("getNextBuffer", this); - if (ctx.buffer === ctx.startBuffer) { - expansion = ctx.search; - ctx.startBuffer.signalError("No more completions"); - ctx.lastSearch = ctx.point + ctx.length; - ctx.startBuffer.setq("dabbrev_context", null); - return; - } else { - ctx.lastSearch = 0; - ctx.buffer.cmd("save_excursion", repeat); - return; - } - } - } - if (p1 != null) { - // console.log("%s at %d, next from %d", ctx.search, p1, ctx.lastSearch); - this.cmd("bind_variables", { - syntax_word: this.getq("syntax_word_dabbrev") - }, "forward_word"); - expansion = this.cmd("buffer_substring", p1, this.point()); - if (Object.HOP(ctx.encountered, expansion)) - repeat.call(this); - } - }); - if (expansion != null) { - this._replaceText(ctx.point, ctx.point + ctx.length, expansion); - ctx.length = expansion.length; - ctx.encountered[expansion] = true; - } - }), - - /* -----[ frames and buffers ]----- */ - - split_frame_vertically: Ymacs_Interactive("p", function(percent) { - if (percent == null) percent = "50%"; - else percent += "%"; - this.whenActiveFrame("vsplit", percent); - }), - - split_frame_horizontally: Ymacs_Interactive("p", function(percent) { - if (percent == null) percent = "50%"; - else percent += "%"; - this.whenActiveFrame("hsplit", percent); - }), - - delete_other_frames: Ymacs_Interactive(function() { - this.whenActiveFrame("deleteOtherFrames"); - }), - - delete_frame: Ymacs_Interactive(function() { - this.whenActiveFrame("deleteFrame"); - }), - - other_frame: Ymacs_Interactive(function() { - this.whenYmacs("focusOtherFrame"); - }), - - windmove: function(dir) { - this.whenYmacs(function(ymacs){ - var f = ymacs.getFrameInDirection(dir); - if (f) f.focus(); - }); - }, - - next_buffer: Ymacs_Interactive(function() { - this.whenYmacs("switchToNextBuffer", this.sameCommandCount() + 1); - }), - - previous_buffer: Ymacs_Interactive(function() { - this.whenYmacs("switchToPreviousBuffer", this.sameCommandCount() + 1); - }), - - switch_to_buffer: Ymacs_Interactive("BSwitch to buffer: ", function(name) { - this.whenYmacs(function(ymacs){ - ymacs.switchToBuffer(name); - }); - }), - - kill_buffer: Ymacs_Interactive(function() { - this.whenYmacs(function(ymacs){ - ymacs.killBuffer(this); - }); - }), - - rename_buffer: Ymacs_Interactive("sRename current buffer to: ", function(name){ - this.whenYmacs(function(ymacs){ - ymacs.renameBuffer(this, name); - }); - }), - - /* -----[ other ]----- */ - - delete_region_or_line: Ymacs_Interactive("^", function() { - if (!this.deleteTransientRegion()) { - this.cmd("beginning_of_line"); - var pos = this.point(); - if (this.cmd("forward_line") || this.cmd("end_of_line")) { - this._deleteText(pos, this.point()); - return true; - } - } - }), - delete_line: Ymacs_Interactive("^", function() { - - - this.cmd("beginning_of_line"); - var pos = this.point(); - alert(pos); - this.cmd("end_of_line"); - var pos1 = this.point(); - alert(pos1); - this._replaceText(pos, pos1,""); - return true; - - - - - - }), - - - - // http://mihai.bazon.net/blog/close-last-xml-tag-emacs - close_last_xml_tag: Ymacs_Interactive_X(function() { - var tag, quote; - this.cmd("save_excursion", function() { - var skip = 1; - while (skip != 0 && this.cmd("search_backward_regexp", /<\x2f?([a-zA-Z0-9:_-]+)/g)) { - tag = this.cmd("match_string", 1); - if (this.cmd("looking_at", /<\x2f/g)) { - ++skip; - } - else if (!this.cmd("looking_at", /<[^\x2f][^>]*?\x2f>/g)) { - --skip; - } - } - if (skip != 0) - tag = null; - }); - if (tag) { - this.cmd("insert", "</", tag, ">"); - } else { - throw new Ymacs_Exception("Couldn't find a tag to close"); - } - }), - - bind_variables: function() { - return this.withVariables.apply(this, arguments); - }, - - for_region: Ymacs_Interactive("^r\nCExecute command within region: ", function(begin, end, func) { - if (end < begin) { var tmp = begin; begin = end; end = tmp; } // MACROS! I WANT MACROS! EVAL SUCKS. x-( - if (!(func instanceof Function)) - func = this.COMMANDS[func]; - this.clearTransientMark(); - this.cmd("goto_char", begin); - begin = this.createMarker(begin, true); - end = this.createMarker(end); - this.withCommands( - { - goto_char: function(pos){ - if (pos >= begin.getPosition() && pos <= end.getPosition()) - return this._repositionCaret(pos); - throw "YMACS_RESTRICT"; - } - }, - function() { - try { - while (true) { - var tmp = this.point(); - func.call(this); - if (this.point() == tmp && !this.cmd("forward_line")) - break; - } - } catch(ex) { - if (ex !== "YMACS_RESTRICT") - throw ex; - } finally { - begin.destroy(); - end.destroy(); - } - } - ); - }) - -}); - -/* -----[ rectangle functions (vertical editing) ]----- */ - -(function(){ - - function apply_on_rectangle(buffer, begin, end, func) { - buffer.cmd("save_excursion", function(){ - var p1 = this._positionToRowCol(begin), - p2 = this._positionToRowCol(end), - width = Math.abs(p2.col - p1.col); - for (var line = p1.row; line <= p2.row; ++line) { - this.cmd("goto_char", this._rowColToPosition(line, 0)); - var text = this.code[line], - c1 = p1.col, - c2 = p2.col, - p = this.point(), ws = 0; - if (c1 > c2) { - var tmp = c1; - c1 = c2; - c2 = tmp; - } - if (c1 > text.length) { - ws = c1 - text.length; - c1 = text.length; - } - if (c2 > text.length) { - c2 = text.length; - } - func.call(this, p + c1, p + c2, ws, width); - } - }, begin == buffer.point()); - }; - - Ymacs_Buffer.newCommands({ - - string_rectangle: Ymacs_Interactive("r\nsString rectangle: ", function(begin, end, string) { - apply_on_rectangle(this, begin, end, function(c1, c2, ws){ - if (ws > 0) { - this._insertText(" ".x(ws), c1); - } else { - this._deleteText(c1, c2); - } - this._insertText(string, c1 + ws); - }); - }), - - kill_rectangle: Ymacs_Interactive("r", function(begin, end){ - var text = []; - apply_on_rectangle(this, begin, end, function(c1, c2, ws, width){ - var str = this._bufferSubstring(c1, c2); - if (c2 - c1 < width) - str += " ".x(width - c2 + c1); - text.push(str); - this._deleteText(c1, c2); - }); - this.setq("killed_rectangle", text); - }), - - clear_rectangle: Ymacs_Interactive("r", function(begin, end){ - this.cmd("string_rectangle", begin, end, - " ".x(Math.abs(this._positionToRowCol(end).col - - this._positionToRowCol(begin).col))); - }), - - insert_rectangle: function(point, rect) { - var col = this._positionToRowCol(point).col; - this.cmd("set_mark_command", point); - rect.foreach(function(text, i){ - if (i > 0) { - if (!this.cmd("forward_line")) { - this.cmd("end_of_line"); - this.cmd("newline"); - } - this.cmd("move_to_column", col, true); - } - this.cmd("insert", text); - }, this); - }, - - yank_rectangle: Ymacs_Interactive("d", function(point){ - var kr = this.getq("killed_rectangle"); - if (kr == null) - throw new Ymacs_Exception("No killed rectangle"); - this.cmd("insert_rectangle", point, kr); - }) - - }); - -})(); - -/* -----[ commands to help using the system clipboard ]----- */ - -(function(){ - - // <XXX> - // this should be moved some level up if it proves to be more - // generally useful - function modalTextarea(title, text, cont) { - var dlg = this.createDialog({ title : title, - quitBtn : "destroy", - modal : true }); - var entry = new DlEntry({ parent: dlg, type: "textarea", fillParent: true, value: text }); - dlg._focusedWidget = entry; - dlg.setSize({ x: 350, y: 250 }); - entry.addEventListener("onKeyPress", function(ev){ - if (ev.keyCode != DlKeyboard.ESCAPE) { - // var code = entry.getValue().replace(/\t/g, " "); - var code = entry.getValue(); - dlg.destroy(); - cont.delayed(0, this, code); - // XXX Without a delay here, be it zero, stars will align in such a way that - // yank_from_operating_system will move the caret in some bizarre position after - // inserting the pasted text. - // cont.call(this, code); - } - }.clearingTimeout(0, this)); - dlg.show(true); - entry.select(); - }; - // </XXX> - - Ymacs_Buffer.newCommands({ - - yank_from_operating_system: Ymacs_Interactive(function() { - modalTextarea.call(this, "Paste below (press CTRL-V)", null, function(code){ - this._saveKilledText(code); - this.cmd("yank"); - this.cmd("recenter_top_bottom"); - }); - }), - - copy_for_operating_system: Ymacs_Interactive("r", function(begin, end) { - modalTextarea.call(this, "Press CTRL-C", this.cmd("buffer_substring"), function(){ - this.cmd("copy_region_as_kill", begin, end); - }); - }), - - kill_for_operating_system: Ymacs_Interactive("r", function(begin, end) { - modalTextarea.call(this, "Press CTRL-C or CTRL-X", this.cmd("buffer_substring"), function(){ - this.cmd("kill_region", begin, end); - }); - }) - - }); - -})(); - -/* -----[ transient mark extension commands ]----- */ - -[ - "forward_char", - "forward_word", - "forward_line", - "forward_paragraph", - "forward_sexp", - "beginning_of_line", - "beginning_of_indentation_or_line", - "beginning_of_buffer", - "backward_char", - "backward_word", - "backward_line", - "backward_paragraph", - "backward_sexp", - "end_of_line", - "end_of_buffer" - -].foreach(function(cmd) { - Ymacs_Buffer.COMMANDS[cmd + "_mark"] = Ymacs_Interactive("^", function(){ - this.ensureTransientMark(); - this.cmdApply(cmd, arguments); - this.ensureTransientMark(); - }); -}); diff --git a/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-exception.js.svn-base b/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-exception.js.svn-base deleted file mode 100644 index 9a3f9bb..0000000 --- a/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-exception.js.svn-base +++ /dev/null @@ -1,36 +0,0 @@ -//> This file is part of Ymacs, an Emacs-like editor for the Web -//> http://www.ymacs.org/ -//> -//> Copyright (c) 2009-2010, Mihai Bazon, Dynarch.com. All rights reserved. -//> -//> Redistribution and use in source and binary forms, with or without -//> modification, are permitted provided that the following conditions are -//> met: -//> -//> * Redistributions of source code must retain the above copyright -//> notice, this list of conditions and the following disclaimer. -//> -//> * Redistributions in binary form must reproduce the above copyright -//> notice, this list of conditions and the following disclaimer in -//> the documentation and/or other materials provided with the -//> distribution. -//> -//> * Neither the name of Dynarch.com nor the names of its contributors -//> may be used to endorse or promote products derived from this -//> software without specific prior written permission. -//> -//> THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY -//> EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -//> IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -//> PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE -//> FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -//> CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -//> SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -//> INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -//> CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -//> ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF -//> THE POSSIBILITY OF SUCH DAMAGE. - -function Ymacs_Exception(why) { - this.message = why; -}; diff --git a/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-frame.js.svn-base b/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-frame.js.svn-base deleted file mode 100644 index c2c83cd..0000000 --- a/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-frame.js.svn-base +++ /dev/null @@ -1,696 +0,0 @@ -//> This file is part of Ymacs, an Emacs-like editor for the Web -//> http://www.ymacs.org/ -//> -//> Copyright (c) 2009-2010, Mihai Bazon, Dynarch.com. All rights reserved. -//> -//> Redistribution and use in source and binary forms, with or without -//> modification, are permitted provided that the following conditions are -//> met: -//> -//> * Redistributions of source code must retain the above copyright -//> notice, this list of conditions and the following disclaimer. -//> -//> * Redistributions in binary form must reproduce the above copyright -//> notice, this list of conditions and the following disclaimer in -//> the documentation and/or other materials provided with the -//> distribution. -//> -//> * Neither the name of Dynarch.com nor the names of its contributors -//> may be used to endorse or promote products derived from this -//> software without specific prior written permission. -//> -//> THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY -//> EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -//> IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -//> PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE -//> FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -//> CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -//> SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -//> INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -//> CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -//> ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF -//> THE POSSIBILITY OF SUCH DAMAGE. - -// @require ymacs.js - -DEFINE_CLASS("Ymacs_Frame", DlContainer, function(D, P, DOM) { - - var DBL_CLICK_SPEED = 300; - - var EX = DlException.stopEventBubbling; - - var LINE_DIV = DOM.createElement("div", null, { className: "line", innerHTML: "<br/>" }); - - var BLINK_TIMEOUT = 225; - - D.DEFAULT_EVENTS = [ "onPointChange" ]; - - D.DEFAULT_ARGS = { - highlightCurrentLine : [ "highlightCurrentLine" , true ], - buffer : [ "buffer" , null ], - ymacs : [ "ymacs" , null ], - isMinibuffer : [ "isMinibuffer" , false ], - - // override in DlWidget - _focusable : [ "focusable" , true ], - _fillParent : [ "fillParent" , true ] - }; - - D.CONSTRUCT = function() { - this.__blinkCaret = this.__blinkCaret.$(this); - this.__caretId = Dynarch.ID(); - this.redrawModelineWithTimer = this.redrawModeline.clearingTimeout(0, this); - - this.getElement().innerHTML = HTML; - - this.addEventListener({ - onDestroy : this._on_destroy, - onFocus : this._on_focus, - onBlur : this._on_blur, - onMouseDown : this._on_mouseDown, - onKeyDown : this._on_keyDown, - onKeyPress : this._on_keyPress, - onKeyPress : this._on_keyPress, - onKeyUp : this._on_keyUp, - onResize : this._on_resize - }); - - this._dragSelectCaptures = { - onMouseOver : EX, - onMouseOut : EX, - onMouseEnter : EX, - onMouseLeave : EX, - onMouseMove : _dragSelect_onMouseMove.$(this), - onMouseUp : _dragSelect_onMouseUp.$(this) - }; - - this._bufferEvents = { - onLineChange : this._on_bufferLineChange.$(this), - onInsertLine : this._on_bufferInsertLine.$(this), - onDeleteLine : this._on_bufferDeleteLine.$(this), - onPointChange : this._on_bufferPointChange.$(this), - onResetCode : this._on_bufferResetCode.$(this), - onOverwriteMode : this._on_bufferOverwriteMode.$(this), - onProgressChange : this._on_bufferProgressChange.$(this), - beforeInteractiveCommand : this._on_bufferBeforeInteractiveCommand.$(this), - afterInteractiveCommand : this._on_bufferAfterInteractiveCommand.$(this), - onOverlayDelete : this._on_bufferOverlayDelete.$(this) - }; - - this._moreBufferEvents = { - onMessage : this._on_bufferMessage.$(this), - onOverlayChange : this._on_bufferOverlayChange.$(this), - afterInteractiveCommand : this.ensureCaretVisible.$(this) - }; - - var buffer = this.buffer; - this.buffer = null; - if (buffer) - this.setBuffer(buffer); - if (!this.isMinibuffer && this.ymacs.cf_lineNumbers) - this.toggleLineNumbers(); - }; - - var HTML = String.buffer( - "<div class='Ymacs-frame-overlays'>", - "<div class='Ymacs-frame-content'></div>", - "</div>", - "<div class='Ymacs_Modeline'></div>" - ).get(); - - P.focus = function(exitAllowed) { - D.BASE.focus.call(this); - if (exitAllowed instanceof Function) { - this.removeEventListener("onBlur", this.__exitFocusHandler); - this.addEventListener("onBlur", this.__exitFocusHandler = function(){ - if (exitAllowed.call(this.buffer)) { - this.removeEventListener("onBlur", this.__exitFocusHandler); - } else { - this.focus.delayed(2, this, null); - } - }); - } - }; - - P.blur = function(force) { - if (force) - this.removeEventListener("onBlur", this.__exitFocusHandler); - D.BASE.blur.call(this); - }; - - P.getOverlaysContainer = function() { - return this.getElement().firstChild; - }; - - P.getModelineElement = function() { - return this.getElement().childNodes[1]; - }; - - P.getContentElement = function() { - return this.getElement().firstChild.firstChild; - }; - - P.getCaretElement = function() { - return document.getElementById(this.__caretId); - }; - - P.getLineDivElement = function(row) { - return this.getContentElement().childNodes[row] || null; - }; - - P.ensureCaretVisible = function() { - this._redrawCaret(); - - var caret = this.getCaretElement(); - if (!caret) - return; - var div = this.getOverlaysContainer(), line = this.getLineDivElement(this.buffer._rowcol.row); - - // vertical - var diff = line.offsetTop + line.offsetHeight - (div.scrollTop + div.clientHeight); - if (diff > 0) { - div.scrollTop += diff; - } else { - diff = line.offsetTop - div.scrollTop; - if (diff < 0) { - div.scrollTop += diff; - } - } - - // horizontal - diff = caret.offsetLeft + caret.offsetWidth - (div.scrollLeft + div.clientWidth); - // if (caret.offsetLeft + caret.offsetWidth < div.clientWidth) - // div.scrollLeft = 0; - if (diff > 0) { - div.scrollLeft += diff; - } else { - diff = caret.offsetLeft - div.scrollLeft; - if (diff < 0) - div.scrollLeft += diff; - } - }; - - P.setBuffer = function(buffer) { - if (this.buffer) { - if (this.caretMarker && !this.isMinibuffer) { - this.caretMarker.destroy(); - this.caretMarker = null; - } - this.buffer.removeEventListener(this._bufferEvents); - this.buffer.removeEventListener(this._moreBufferEvents); - } - this.buffer = buffer; - if (buffer) { - this.buffer.addEventListener(this._bufferEvents); - if (this.focusInside()) { - buffer.addEventListener(this._moreBufferEvents); - } - if (this.isMinibuffer) { - this.caretMarker = buffer.caretMarker; - } else { - this.caretMarker = buffer.createMarker(buffer.caretMarker.getPosition()); - } - this._redrawBuffer(); - this._redrawCaret(true); - this.centerOnCaret(); - } - }; - - P.centerOnCaret = function() { - this.centerOnLine(this.buffer._rowcol.row); - }; - - P.centerOnLine = function(row) { - var line = this.getLineDivElement(row), div = this.getOverlaysContainer(); - div.scrollTop = Math.round(line.offsetTop - div.clientHeight / 2 + line.offsetHeight / 2); - // this._redrawBuffer(); - }; - - P.setModelineContent = function(html) { - this.getModelineElement().innerHTML = html; - }; - - P.deleteOtherFrames = function() { - this.ymacs.keepOnlyFrame(this); - }; - - P.deleteFrame = function() { - this.ymacs.deleteFrame(this); - }; - - P.vsplit = function(percent) { - if (percent == null) percent = "50%"; - var cont = this.parent, - fr = this.ymacs.createFrame({ buffer: this.buffer }), - layout = new DlLayout(), - rb = new DlResizeBar({ widget: this, keepPercent: true, horiz: true, className: "Ymacs-splitbar-horiz" }); - if (this._resizeBar) - this._resizeBar._widget = layout; - this._resizeBar = rb; - cont.replaceWidget(this, layout); - layout.packWidget(this, { pos: "top", fill: percent }); - layout.packWidget(rb, { pos: "top" }); - layout.packWidget(fr, { pos: "top", fill: "*" }); - cont.__doLayout(); - fr.centerOnCaret(); - }; - - P.hsplit = function(percent) { - if (percent == null) percent = "50%"; - var cont = this.parent, - fr = this.ymacs.createFrame({ buffer: this.buffer }), - layout = new DlLayout(), - rb = new DlResizeBar({ widget: this, keepPercent: true, className: "Ymacs-splitbar-vert" }); - if (this._resizeBar) - this._resizeBar._widget = layout; - this._resizeBar = rb; - cont.replaceWidget(this, layout); - layout.packWidget(this, { pos: "left", fill: percent }); - layout.packWidget(rb, { pos: "left" }); - layout.packWidget(fr, { pos: "left", fill: "*" }); - cont.__doLayout(); - fr.centerOnCaret(); - }; - - P.toggleLineNumbers = function() { - this.condClass(this.__lineNumbers =! this.__lineNumbers, "Ymacs-line-numbers"); - }; - - function insertInText(div, col, el) { - // this is for empty lines - if (/^br$/i.test(div.firstChild.tagName)) { - div.insertBefore(el, div.firstChild); - return el; - } - var len = 0, OUT = {}; - function walk(div) { - for (var i = div.firstChild; i; i = i.nextSibling) { - if (i.nodeType == 3 /* TEXT */) { - var clen = i.length; - if (len + clen > col) { - var pos = col - len; // here we should insert it, relative to the current node - var next = i.splitText(pos); - div.insertBefore(el, next); - throw OUT; - } - else if (len + clen == col) { - // this case is simpler; it could have been treated - // above, but let's optimize a bit since there's no need - // to split the text. - div.insertBefore(el, i.nextSibling); - throw OUT; - } - len += clen; - } - else if (i.nodeType == 1 /* ELEMENT */) { - walk(i); // recurse - } - } - }; - try { - walk(div); - } - catch(ex) { - if (ex === OUT) - return el; - throw ex; - } - }; - - P.setMarkerAtPos = function(row, col) { - if (!row.tagName) // accept an element as well - row = this.getLineDivElement(row); - if (row) - return insertInText(row, col, DOM.createElement("span")); - }; - - P.__restartBlinking = function() { - this.__stopBlinking(); - if (this.focusInside()) { - this.__caretTimer = setTimeout(this.__blinkCaret, 2 * BLINK_TIMEOUT); - } - }; - - P.__stopBlinking = function() { - clearTimeout(this.__caretTimer); - this.__showCaret(); - }; - - P.__blinkCaret = function() { - DOM.condClass(this.getCaretElement(), this.BLINKING = ! this.BLINKING, "Ymacs-caret"); - this.__caretTimer = setTimeout(this.__blinkCaret, BLINK_TIMEOUT); - }; - - P.__showCaret = function() { - DOM.addClass(this.getCaretElement(), "Ymacs-caret"); - }; - - P._unhoverLine = function() { - if (this.__hoverLine != null) { - DOM.delClass(this.getLineDivElement(this.__hoverLine), "Ymacs-current-line"); - this.__hoverLine = null; - } - }; - - P._redrawCaret = function(force) { - var isActive = this.ymacs.getActiveFrame() === this; - if (!force && !isActive) - return; - - if (isActive && !this.isMinibuffer) - this.caretMarker.setPosition(this.buffer.caretMarker.getPosition()); - - var rc = this.buffer._rowcol; - - if (this.highlightCurrentLine) { - this._unhoverLine(); - DOM.addClass(this.getLineDivElement(rc.row), "Ymacs-current-line"); - this.__hoverLine = rc.row; - } - - // redraw the line where the caret was previously, so that it disappears from there - if (this.__prevCaretLine != null) { - this._on_bufferLineChange(this.__prevCaretLine); - } - - // redraw current line if it's different - if (this.__prevCaretLine != rc.row) { - this.__prevCaretLine = rc.row; - this._on_bufferLineChange(rc.row); - } - - // var caret = this.getCaretElement(); - // if (caret) - // DOM.strip(caret); - // this._on_bufferLineChange(rc.row); - - if (isActive) - this.__restartBlinking(); - - this.callHooks("onPointChange", rc.row, rc.col); - this.redrawModelineWithTimer(rc); - }; - - P._getLineHTML = function(row) { - var html = this.buffer.formatLineHTML(row, this.caretMarker); - // taking advantage of the fact that a literal > entered by the user will never appear in - // the generated HTML, since special HTMl characters are escaped. - var pos = html.indexOf("Ymacs-caret'>"); - if (pos >= 0) { - html = html.substr(0, pos + 12) - + " id='" + this.__caretId + "'" - + html.substr(pos + 12); - } - return html; - }; - - P._redrawBuffer = function() { - this.setContent(this.buffer.code.map(function(line, i){ - return this._getLineHTML(i).htmlEmbed("div", "line"); - }, this).join("")); - }; - - P.coordinatesToRowCol = function(x, y) { - function findLine(r1, r2) { - if (r1 == r2) - return r1; - var row = Math.floor((r1 + r2) / 2), - div = self.getLineDivElement(row), - y1 = div.offsetTop, - y2 = y1 + div.offsetHeight - 1; - if (y2 < y) - return findLine(row + 1, r2); - if (y < y1) - return findLine(r1, row - 1); - return row; - }; - function findCol(c1, c2) { - if (c1 == c2) - return c1; - var col = Math.floor((c1 + c2) / 2); - var p1 = self.coordinates(row, col), - p2 = self.coordinates(row, col + 1); - if (p2.x < x) - return findCol(col + 1, c2); - if (x < p1.x) - return findCol(c1, col - 1); - return col; - }; - var self = this, - row = findLine(0, this.buffer.code.length - 1), - col = findCol(0, this.buffer.code[row].length); - return { row: row, col: col }; - }; - - P.coordinates = function(row, col) { - var div = this.getLineDivElement(row); - var span = this.setMarkerAtPos(div, col); - var ret = { x: span.offsetLeft, y: div.offsetTop, h: div.offsetHeight }; - DOM.trash(span); - return ret; - }; - - P.heightInLines = function() { - return Math.floor(this.getOverlaysContainer().clientHeight / this.getContentElement().firstChild.offsetHeight); - }; - - P.setOuterSize = P.setSize = function(sz) { - D.BASE.setOuterSize.apply(this, arguments); - DOM.setOuterSize(this.getOverlaysContainer(), sz.x, sz.y - this.getModelineElement().offsetHeight); - DOM.setOuterSize(this.getModelineElement(), sz.x); - }; - - P.redrawModeline = function(rc) { - this.setModelineContent(this.buffer.renderModelineContent(rc || this.caretMarker.getRowCol())); - }; - - /* -----[ event handlers ]----- */ - - P._on_bufferLineChange = function(row) { - var div = this.getLineDivElement(row); - if (div) { - //console.log("Redrawing line %d [%s]", row, this.buffer.code[row]); - div.innerHTML = this._getLineHTML(row); - } - }; - - P._on_bufferInsertLine = function(row, drawIt) { - var div = LINE_DIV.cloneNode(true); - this.getContentElement().insertBefore(div, this.getLineDivElement(row)); - if (drawIt) { - div.innerHTML = this._getLineHTML(row); - } - }; - - P._on_bufferDeleteLine = function(row) { - DOM.trash(this.getLineDivElement(row)); - }; - - P._on_bufferPointChange = function(rc, pos) { - this._redrawCaret(); - }; - - P._on_bufferResetCode = function() { - this._redrawBuffer(); - }; - - P._on_bufferOverwriteMode = function(om) { - this.condClass(om, "Ymacs-overwrite-mode"); - }; - - P._on_bufferMessage = function(type, text, html, timeout) { - var anchor = this.isMinibuffer ? this.ymacs : this; - var popup = Ymacs_Message_Popup.get(0); - popup.popup({ - content : html ? text : text.htmlEscape(), - widget : anchor, - anchor : anchor.getElement(), - align : { prefer: "CC", fallX1: "CC", fallX2: "CC", fallY1: "CC", fallY2: "CC" } - }); - popup.hide(timeout || 5000); - }; - - P._on_bufferBeforeInteractiveCommand = function() { - this._unhoverLine(); - Ymacs_Message_Popup.clearAll(); - }; - - P._on_bufferAfterInteractiveCommand = function() {}; - - P._on_bufferProgressChange = function() { - this.redrawModelineWithTimer(null); - }; - - P.getOverlayId = function(name) { - return this.id + "-ovl-" + name; - }; - - P.getOverlayHTML = function(name, props) { - if (props.line1 == props.line2 && props.col1 == props.col2) { - this._on_bufferOverlayDelete(name, props); - return null; - } - var p1 = this.coordinates(props.line1, props.col1); - var p2 = this.coordinates(props.line2, props.col2); - var p0 = this.__lineNumbers ? this.coordinates(props.line1, 0) : { x: 0, y: 0 }; - p1.x -= p0.x; - p2.x -= p0.x; - var str = String.buffer( - "<div id='", this.getOverlayId(name), "' class='Ymacs_Overlay ", name, - "' style='top:", p1.y, "px;left:", p0.x, "px'>" - ); - if (props.line1 == props.line2) { - str("<div class='", name, "' style='margin-left:", p1.x, - "px; width:", p2.x - p1.x, "px;height:", p2.h, "px;'> </div>"); - } else { - str("<div class='", name, "' style='margin-left:", p1.x, "px;height:", p1.h, "px;'> </div>"); - if (props.line2 - props.line1 > 1) - str("<div class='", name, "' style='height:", p2.y - p1.y - p1.h, "px'></div>"); - str("<div class='", name, "' style='width:", p2.x, "px;height:", p2.h, "px;'> </div>"); - } - str("</div>"); - return str.get(); - }; - - P.getOverlaysCount = function() { - return this.getOverlaysContainer().childNodes.length - 1; // XXX: subtract the div.content; we need to revisit this if we add new elements. - }; - - P._on_bufferOverlayChange = function(name, props, isNew) { - var div = this.getOverlayHTML(name, props); - if (div) { - div = DOM.createFromHtml(div); - var p = this.getOverlaysContainer(), - old = !isNew && $(this.getOverlayId(name)); - old ? p.replaceChild(div, old) : p.appendChild(div); - // this.condClass(this.getOverlaysCount() > 0, "Ymacs_Frame-hasOverlays"); - } - }; - - P._on_bufferOverlayDelete = function(name, props, isNew) { - DOM.trash($(this.getOverlayId(name))); - // this.condClass(this.getOverlaysCount() > 0, "Ymacs_Frame-hasOverlays"); - }; - - /* -----[ self events ]----- */ - - P._on_destroy = function() { - this.setBuffer(null); - this.__stopBlinking(); - }; - - P._on_focus = function() { - window.focus(); - // console.log("FOCUS for %s", this.buffer.name); - this.ymacs.setActiveFrame(this, true); - this.addClass("Ymacs_Frame-active"); - if (!this.isMinibuffer) { - this.buffer.cmd("goto_char", this.caretMarker.getPosition()); - } - this.buffer.addEventListener(this._moreBufferEvents); - this.__restartBlinking(); - }; - - P._on_blur = function() { - // console.log("BLUR for %s", this.buffer.name); - if (!this.isMinibuffer) { - this.caretMarker.setPosition(this.buffer.caretMarker.getPosition()); - } - this.buffer.removeEventListener(this._moreBufferEvents); - this.__stopBlinking(); - }; - - var CLICK_COUNT = 0, CLICK_COUNT_TIMER = null, CLICK_LAST_TIME = null; - function CLEAR_CLICK_COUNT() { CLICK_COUNT = null }; - - P._on_mouseDown = function(ev) { - clearTimeout(CLICK_COUNT_TIMER); - CLICK_COUNT++; - CLICK_COUNT_TIMER = CLEAR_CLICK_COUNT.delayed(DBL_CLICK_SPEED); - - this.__restartBlinking(); - var pos = ev.computePos(this.getContentElement()), - rc = this.coordinatesToRowCol(pos.x, pos.y), - buf = this.buffer; - - buf.clearTransientMark(); - buf.cmd("goto_char", buf._rowColToPosition(rc.row, rc.col)); - buf.callInteractively("keyboard_quit"); - if (CLICK_COUNT == 1) { - buf.ensureTransientMark(); - DlEvent.captureGlobals(this._dragSelectCaptures); - } - else if (CLICK_COUNT == 2) { - buf.cmd("backward_word"); - buf.cmd("forward_word_mark"); - } - else if (CLICK_COUNT == 3) { - buf.cmd("beginning_of_line"); - buf.cmd("end_of_line_mark"); - } - else if (CLICK_COUNT == 4) { - buf.cmd("backward_paragraph"); - buf.cmd("forward_whitespace"); - buf.cmd("beginning_of_line"); - buf.cmd("forward_paragraph_mark"); - } - - EX(); - }; - - function _dragSelect_onMouseMove(ev) { - var pos = ev.computePos(this.getContentElement()), - rc = this.coordinatesToRowCol(pos.x, pos.y); - this.buffer.cmd("goto_char", this.buffer._rowColToPosition(rc.row, rc.col)); - this.buffer.ensureTransientMark(); - this.ensureCaretVisible(); - }; - - function _dragSelect_onMouseUp(ev) { - DlEvent.releaseGlobals(this._dragSelectCaptures); - }; - - P._on_keyDown = function(ev) { - if (!is_gecko) { - var ki = window.KEYBOARD_INSANITY, code = ev.keyCode; - if (code in ki.modifiers) - EX(); - if ((code in ki.letters || code in ki.digits || code in ki.symbols) && !(ev.ctrlKey || ev.altKey)) { - return; // to be handled by the upcoming keypress event - } - ev.charCode = ki.getCharCode(code, ev.shiftKey); - if (ev.charCode) - ev.keyCode = 0; - if (this.buffer._handleKeyEvent(ev)) - EX(); - } - }; - P._on_keyPress = function(ev) { - if (!is_gecko) - ev.keyCode = 0; - if (this.buffer._handleKeyEvent(ev)) - EX(); - var one = this.buffer.cmd("wrap_status"); - if(one =="Wrap At Edge") - { - this.buffer.cmd("wrap_at_edge"); - } - }; - - - P._on_keyUp = function(ev) { - }; - - P._on_resize = function() { - this.centerOnCaret.delayed(1, this); - }; - -}); - -DEFINE_CLASS("Ymacs_Message_Popup", DlPopup, function(D, P) { - D.FIXARGS = function(args) { - args.focusable = false; - args.autolink = false; - args.zIndex = 5000; - }; -}); diff --git a/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-interactive.js.svn-base b/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-interactive.js.svn-base deleted file mode 100644 index 565c264..0000000 --- a/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-interactive.js.svn-base +++ /dev/null @@ -1,286 +0,0 @@ -//> This file is part of Ymacs, an Emacs-like editor for the Web -//> http://www.ymacs.org/ -//> -//> Copyright (c) 2009-2010, Mihai Bazon, Dynarch.com. All rights reserved. -//> -//> Redistribution and use in source and binary forms, with or without -//> modification, are permitted provided that the following conditions are -//> met: -//> -//> * Redistributions of source code must retain the above copyright -//> notice, this list of conditions and the following disclaimer. -//> -//> * Redistributions in binary form must reproduce the above copyright -//> notice, this list of conditions and the following disclaimer in -//> the documentation and/or other materials provided with the -//> distribution. -//> -//> * Neither the name of Dynarch.com nor the names of its contributors -//> may be used to endorse or promote products derived from this -//> software without specific prior written permission. -//> -//> THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY -//> EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -//> IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -//> PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE -//> FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -//> CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -//> SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -//> INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -//> CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -//> ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF -//> THE POSSIBILITY OF SUCH DAMAGE. - -// @require ymacs-exception.js - -(function(){ - - /* - * Ymacs_Interactive(args_description, function_reference) - * - * This is a wrapper that makes it easy to define "interactive" commands. Pass two arguments: arguments - * description (args), and a function (func). args can be null, or a string, an array or a function. When null - * it is assumed that the function should not receive any arguments. When an array or a string, it contains - * some argument descriptions similar to Emacs: - * - * http://www.gnu.org/s/emacs/manual/html_node/elisp/Interactive-Codes.html#Interactive-Codes - * - * (note that Emacs does not take a list for this argument). - * - * Ymacs_Interactive returns func. When not called interactively, the code should supply all the required - * arguments and the function is called with no performance penalty. To call it interactively, use - * func.ymacsCallInteractively(), which will read arguments from the minibuffer according to their description. - */ - - window.Ymacs_Interactive = function(args, func) { - if (arguments.length == 1) { - func = args; - args = null; - } else { - var documentation; - if (!(func instanceof Function)) { - documentation = func; - func = arguments[2]; - func.ymacsDoc = documentation; - } - } - func.ymacsInteractive = true; - if (args instanceof Function) { - func.ymacsGetArgs = args; - } - else if (args != null) { - if (!(args instanceof Array)) { - var m = /^[\^\@\*]+/.exec(args); - if (m) { - m = m[0]; - args = args.substr(m.length); - if (m.indexOf("^") >= 0) { - func.ymacsMarkExtend = true; - } - if (m.indexOf("*") >= 0) { - func.ymacsWarnReadonly = true; - } - if (m.indexOf("@") >= 0) { - func.ymacsSelectFrame = true; - } - } - if (args) - args = args.split(/\n+/); - } - if (args) { - var collect, - execute = function() { - collect.append(Array.$(arguments)); - return this.callInteractively(func, collect, true); - }; - while (args.length > 0) { - execute = createArgumentFunction(args.pop(), function(next) { - collect.append(Array.$(arguments, 1)); - next.call(this); - }.$(null, execute)); - } - func.ymacsCallInteractively = function(){ - collect = []; - return execute.call(this); - }; - } - } - return func; - }; - - window.Ymacs_Interactive_X = function(func) { - return Ymacs_Interactive("p", function(n){ - if (n == null) n = 1; - n.times(func, this); - }); - }; - - var $TRUE = (function(){}); - $TRUE.toString = function() { return "" }; - $TRUE.empty = true; - - /* -----[ argument reader functions ]----- */ - - function prompt(arg) { - var pr = this.getPrefixArg(true /* noDiscard */); - if (pr) { - arg = pr + " " + arg; - } - this.cmd("minibuffer_prompt", arg); - }; - - function read_function_name(arg, cont) { - prompt.call(this, arg); - this.cmd("minibuffer_read_function", cont); - // XXX: enforce it! - }; - - function read_existing_buffer_name(arg, cont) { - prompt.call(this, arg); - this.cmd("minibuffer_read_buffer", cont); - // XXX: enforce it! - }; - - function read_buffer_name(arg, cont) { - prompt.call(this, arg); - this.cmd("minibuffer_read_buffer", cont); - }; - - function read_character(arg, cont) { - - }; - - function read_command_name(arg, cont) { - prompt.call(this, arg); - this.cmd("minibuffer_read_command", cont); - // XXX: enforce it! - }; - - function get_point(arg, cont) { - cont.call(this, this.point()); - }; - - function get_mouse_event(arg, cont) { - - }; - - function irrelevant(arg, cont) { - cont.call(this, null); - }; - - function read_key_sequence(arg, cont) { - - }; - - function read_key_sequence2(arg, cont) { - - }; - - function get_mark(arg, cont) { - cont.call(this, this.markMarker.getPosition()); - }; - - function read_arbitrary_text(arg, cont) { - prompt.call(this, arg); - this.cmd("minibuffer_read_string", null, cont); - }; - - function read_number(arg, cont) { - prompt.call(this, arg); - this.cmd("minibuffer_read_number", cont); - }; - - function read_number_or_prefix(arg, cont) { - var n = parseInt(this.getPrefixArg(), 10); - if (!isNaN(n)) - cont.call(this, n); - else - read_number.call(this, arg, cont); - }; - - function get_numeric_prefix(arg, cont) { - var n = parseInt(this.getPrefixArg(), 10); - if (isNaN(n)) - n = null; - cont.call(this, n); - }; - - function get_raw_prefix(arg, cont) { - arg = this.getPrefixArg(); - if (arg === "") - arg = $TRUE; - cont.call(this, arg); - }; - - function get_point_and_mark(arg, cont) { - var r = this.getRegion(); - cont.call(this, r.begin, r.end); - }; - - function read_key_sequence3(arg, cont) { - - }; - - function read_variable_name(arg, cont) { - prompt.call(this, arg); - this.cmd("minibuffer_read_variable", cont); - }; - - function read_existing_file_name(arg, cont) { - prompt.call(this, arg); - this.cmd("minibuffer_read_existing_file", cont); - }; - - function read_file_name(arg, cont) { - prompt.call(this, arg); - this.cmd("minibuffer_read_file", cont); - }; - - function read_file_or_directory_name(arg, cont) { - prompt.call(this, arg); - this.cmd("minibuffer_read_file_or_directory", cont); - }; - - function read_existing_directory_name(arg, cont) { - prompt.call(this, arg); - this.cmd("minibuffer_read_directory", cont); - }; - - var ARG_READERS = { - a: read_function_name, - b: read_existing_buffer_name, - B: read_buffer_name, - c: read_character, - C: read_command_name, - d: get_point, - e: get_mouse_event, - i: irrelevant, - k: read_key_sequence, - K: read_key_sequence2, - m: get_mark, - M: read_arbitrary_text, - n: read_number, - N: read_number_or_prefix, - p: get_numeric_prefix, - P: get_raw_prefix, - r: get_point_and_mark, - s: read_arbitrary_text, - U: read_key_sequence3, - v: read_variable_name, - - f: read_existing_file_name, - F: read_file_name, - G: read_file_or_directory_name, - D: read_existing_directory_name - - // S: no reader for interned symbols in Ymacs - // no x, X, z and Z either - }; - - function createArgumentFunction(arg, cont) { - var code = arg.charAt(0); - arg = arg.substr(1); - return ARG_READERS[code].$(null, arg, cont); - }; - -})(); diff --git a/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-keyboard.js.svn-base b/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-keyboard.js.svn-base deleted file mode 100644 index c15fd35..0000000 --- a/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-keyboard.js.svn-base +++ /dev/null @@ -1,106 +0,0 @@ -//> This file is part of Ymacs, an Emacs-like editor for the Web -//> http://www.ymacs.org/ -//> -//> Copyright (c) 2009-2010, Mihai Bazon, Dynarch.com. All rights reserved. -//> -//> Redistribution and use in source and binary forms, with or without -//> modification, are permitted provided that the following conditions are -//> met: -//> -//> * Redistributions of source code must retain the above copyright -//> notice, this list of conditions and the following disclaimer. -//> -//> * Redistributions in binary form must reproduce the above copyright -//> notice, this list of conditions and the following disclaimer in -//> the documentation and/or other materials provided with the -//> distribution. -//> -//> * Neither the name of Dynarch.com nor the names of its contributors -//> may be used to endorse or promote products derived from this -//> software without specific prior written permission. -//> -//> THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY -//> EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -//> IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -//> PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE -//> FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -//> CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -//> SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -//> INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -//> CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -//> ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF -//> THE POSSIBILITY OF SUCH DAMAGE. - -// This file tries to define some keyboard constants based on the -// sheer insanity of browser inconsistencies described here: -// -// http://unixpapa.com/js/key.html -// -// Kudos for that work! - -(function(){ - - var letters = {}; - for (var i = 65; i <= 90; ++i) - letters[i] = [ i, i + 32 ]; - letters[32] = [ 32, 32 ]; - - var modifiers = [ 16, 17, 18, 20, 144 ].toHash(true); - - var digit_charcodes = [ - [ 49, 33 ], - [ 50, 64 ], - [ 51, 35 ], - [ 52, 36 ], - [ 53, 37 ], - [ 54, 94 ], - [ 55, 38 ], - [ 56, 42 ], - [ 57, 40 ], - [ 48, 41 ] - ]; - - var digits = [ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57 ].toHash(function(k, i) { - return digit_charcodes[i]; - }); - - var symbol_charcodes = [ - [ 59, 58 ], - [ 61, 43 ], - [ 44, 60 ], - [ 45, 95 ], - [ 46, 62 ], - [ 47, 63 ], - [ 96, 126 ], - [ 91, 123 ], - [ 92, 124 ], - [ 93, 125 ], - [ 39, 34 ] - ]; - - var symbols = ( is_gecko ? [ 59, 61, 188, 109, 190, 191, 192, 219, 220, 221, 222 ] - : is_opera ? [ 59, 61, 44, 45, 46, 47, 96, 91, 92, 93, 39 ] - : [ 186, 187, 188, 189, 190, 191, 192, 219, 220, 221, 222 ] ).toHash(function(k, i) { - return symbol_charcodes[i]; - }); - - var arrows = [ 37, 38, 39, 40 ].toHash(true); - - var specials = [ 45, 46, 36, 35, 33, 34, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123 ].toHash(true); - - function getCharCode(code, shift) { - var a = letters[code] || digits[code] || symbols[code]; - return a ? shift ? a[1] : a[0] : null; - }; - - window.KEYBOARD_INSANITY = { - letters : letters, - modifiers : modifiers, - digits : digits, - symbols : symbols, - arrows : arrows, - specials : specials, - getCharCode : getCharCode - }; - -})(); diff --git a/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-keymap-emacs.js.svn-base b/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-keymap-emacs.js.svn-base deleted file mode 100644 index 64c9891..0000000 --- a/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-keymap-emacs.js.svn-base +++ /dev/null @@ -1,264 +0,0 @@ -//> This file is part of Ymacs, an Emacs-like editor for the Web -//> http://www.ymacs.org/ -//> -//> Copyright (c) 2009-2010, Mihai Bazon, Dynarch.com. All rights reserved. -//> -//> Redistribution and use in source and binary forms, with or without -//> modification, are permitted provided that the following conditions are -//> met: -//> -//> * Redistributions of source code must retain the above copyright -//> notice, this list of conditions and the following disclaimer. -//> -//> * Redistributions in binary form must reproduce the above copyright -//> notice, this list of conditions and the following disclaimer in -//> the documentation and/or other materials provided with the -//> distribution. -//> -//> * Neither the name of Dynarch.com nor the names of its contributors -//> may be used to endorse or promote products derived from this -//> software without specific prior written permission. -//> -//> THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY -//> EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -//> IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -//> PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE -//> FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -//> CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -//> SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -//> INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -//> CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -//> ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF -//> THE POSSIBILITY OF SUCH DAMAGE. - -// @require ymacs-keymap.js - -// This is the default keymap, as configured in -// Ymacs_Buffer::makeDefaultKeymap. It follows closely the standard -// Emacs keybindings, with some small deviations that match my taste -// (search for "my stuff" below). - -// It would be nice to have more options, such as an Eclipse keymap, -// or Visual Studio -- but I'm not familiar with any of them. -// Contributions welcome. - -// A keymap inherits from Ymacs_Keymap and should define its bindings -// in D.KEYS. They can also define a defaultHandler property to take -// whatever action they consider necessary -- for example the Isearch -// keymap will, by default, print the entered character in the -// minibuffer and trigger a search action. Isearch mode is almost -// completely defined in a keymap -- with the minor note that -// isearch_forward and isearch_backward are assigned below to key -// combinations; once pressed, they will push the Isearch keymap onto -// the buffer's keymap stack, and it will be used until isearch is -// ended. - -/* KEY DEFINITIONS. A key is generally defined in standard Emacs - notation, with the following notes: - - - it is possible to define multiple keys at once for the same - operation, by using the "&&" combination (separate with spaces - from the actual keys) - - - some special characters are named literally; their names contain - more than one character. The available names are defined in - DlKeyboard (see keyboard.js in DynarchLIB). Examples: - ARROW_RIGHT, PAGE_UP, etc. but also SPACE and DASH. - - Normally you would define commands using Ymacs_Buffer.newCommands - (see ymacs-commands.js) and specify the command name for key - bindings, but you can specify a function as well, if you want: - - "C-8": function() { - alert("You pressed CTRL-8"); - } - - It is advised to define commands for more than simple cases, for - two reasons: - - 1. they can be used for "non-interactive" calls too - - 2. the command name is saved in this.currentCommand / - this.previousCommand, which is useful in a number of cases. - -*/ - -DEFINE_SINGLETON("Ymacs_Keymap_Emacs", Ymacs_Keymap, function(D, P){ - - var TMPL_INFO = String.template( - "<table>", - "<tr><td style='text-align: right; font-weight: bold'>Char:</td><td><tt> $ch </tt></td></tr>", - "<tr><td style='text-align: right; font-weight: bold'>Char code:</td><td> $code / 0x$codeHex </td></tr>", - "<tr><td style='text-align: right; font-weight: bold'>Position:</td><td> $point </td></tr>", - "<tr><td style='text-align: right; font-weight: bold'>Mark:</td><td> $mark </td></tr>", - "<tr><td style='text-align: right; font-weight: bold'>Buffer size:</td><td> $sizeKB </td></tr>", - "</table>" - ); - - D.KEYS = { - // movement - "ARROW_UP && C-p" : "backward_line", - "ARROW_DOWN && C-n" : "forward_line", - "ARROW_LEFT && C-b" : "backward_char", - "ARROW_RIGHT && C-f" : "forward_char", - "HOME" : "beginning_of_indentation_or_line", - "END && C-e" : "end_of_line", - "C-c C-c" : "sub_bullet", - "C-a" : "beginning_of_line", - "C-HOME && M-<" : "beginning_of_buffer", - "C-END && M->" : "end_of_buffer", - "C-ARROW_RIGHT && M-f" : "forward_word", - "C-ARROW_LEFT && M-b" : "backward_word", - "C-ARROW_DOWN" : "forward_paragraph", - "C-ARROW_UP" : "backward_paragraph", - "C-l" : "recenter_top_bottom", - "PAGE_UP && M-v" : "scroll_up", - "PAGE_DOWN && C-v" : "scroll_down", - - // transient mark - "S-ARROW_UP && S-C-p" : "backward_line_mark", - "S-ARROW_DOWN && S-C-n" : "forward_line_mark", - "S-ARROW_LEFT && S-C-b" : "backward_char_mark", - "S-ARROW_RIGHT && S-C-f" : "forward_char_mark", - "S-C-ARROW_RIGHT && S-M-f" : "forward_word_mark", - "S-C-ARROW_LEFT && S-M-b" : "backward_word_mark", - "S-C-ARROW_DOWN" : "forward_paragraph_mark", - "S-C-ARROW_UP" : "backward_paragraph_mark", - "S-HOME" : "beginning_of_indentation_or_line_mark", - "S-C-a" : "beginning_of_line_mark", - "S-END" : "end_of_line_mark", - "S-C-HOME" : "beginning_of_buffer_mark", - "S-C-END" : "end_of_buffer_mark", - - // basic editing - "BACKSPACE" : "backward_delete_char", - "DELETE && C-d" : "delete_char", - "ENTER && C-m" : "newline", - "M-d && C-DELETE" : "kill_word", - "C-BACKSPACE && M-BACKSPACE && M-DELETE" : "backward_kill_word", - "C-k" : "kill_line", - "C-y && S-INSERT" : "yank", - "M-y" : "yank_pop", - "C-SPACE" : "set_mark_command", - "C-x C-x" : "exchange_point_and_mark", - "C-w" : "kill_region", - "M-t" : "transpose_words", - "C-t" : "transpose_chars", - "C-x C-t" : "transpose_lines", - "M-w" : "copy_region_as_kill", - "M-c" : "capitalize_word", - "M-u" : "upcase_word", - "M-l" : "downcase_word", - "F11" : "nuke_trailing_whitespace", - "TAB" : "indent_line", - "C-M-\\" : "indent_region", - "M-q" : "fill_paragraph", - "C-/ && C-x u && C-_ && C-z" : "undo", - "INSERT" : "overwrite_mode", - "M-s" : "center_line", - "M-/" : "dabbrev_expand", - "C-s" : "isearch_forward", - "C-r" : "isearch_backward", - "M-C-s" : "isearch_forward_regexp", - "M-C-r" : "isearch_backward_regexp", - "C-u" : "universal_argument", - "M-g" : "goto_line", - "C-x h" : "mark_whole_buffer", - "C-g" : "keyboard_quit", - - // vertical editing - "C-x r t" : "string_rectangle", - "C-x r c" : "clear_rectangle", - "C-x r k" : "kill_rectangle", - "C-x r y" : "yank_rectangle", - - // buffers - "C-x C-ARROW_RIGHT && C-x ARROW_RIGHT && C-TAB" : "next_buffer", - "C-x C-ARROW_LEFT && C-x ARROW_LEFT && C-S-TAB" : "previous_buffer", - "C-x b" : "switch_to_buffer", - "C-x k" : "kill_buffer", - - // frames - "C-x 0" : "delete_frame", - "C-x 1" : "delete_other_frames", - "C-x 2" : "split_frame_vertically", - "C-x 3" : "split_frame_horizontally", - "C-x o" : "other_frame", - "C-x l" : "toggle_line_numbers", - "C-c C-o" : "org-open-at-point", - //"C-c C-l" : "Links", - - // eval - "M-x" : "execute_extended_command", - - // necessary evil - "C-S-y" : "yank_from_operating_system", - "M-S-w" : "copy_for_operating_system", - "C-S-w" : "kill_for_operating_system", - - // my stuff, sorry if these have different meanings in the standard Emacs keys - "M-S-y" : "yank_shift", // that's the reverse of yank_shift - "C-c /" : "close_last_xml_tag", - "S-BACKSPACE" : "backward_delete_whitespace", - "S-DELETE" : "delete_whitespace", - "C-M-d" : "delete_region_or_line", - "M-ENTER" : "start_next_paragraph", - "M-S-q" : "fill_paragraph_no_prefix", - "C-M-|" : "cperl_lineup", - "C-F4" : "kill_buffer", - "M-ARROW_LEFT" : [ "windmove", "left" ], - "M-ARROW_RIGHT" : [ "windmove", "right" ], - "M-ARROW_UP" : [ "windmove", "up" ], - "M-ARROW_DOWN" : [ "windmove", "down" ], - - // others - "C-x =": function() { - var ch = this.charAt(), chname = ch; - if (ch == " ") - chname = "<SPACE>"; - else if (ch == "\n") - chname = "<NEWLINE>"; - else if (ch == "-") - chname = "<DASH>"; - - this.signalInfo(TMPL_INFO({ - ch : chname.htmlEscape(), - code : ch.charCodeAt(0), - codeHex : ch.charCodeAt().hex(), - point : this.point(), - mark : this.markMarker.getPosition(), - size : this.getCodeSize(), - sizeKB : this.getCodeSize().formatBytes(2) - }), true); - } - }; - - P.defaultHandler = [ "self_insert_command" ]; - -}); - -DEFINE_SINGLETON("Ymacs_Keymap_UniversalArgument", Ymacs_Keymap, function(D, P){ - - P.defaultHandler = [ Ymacs_Interactive("^", function(){ - var ev = this.interactiveEvent(), - ch = String.fromCharCode(ev.charCode), - prefix = this.getPrefixArg(true); - if (ev.charCode && (/^[0-9]$/.test(ch) || (ch === "-" && prefix === "")) && !ev.altKey && !ev.ctrlKey) { - prefix += ch; - this.setPrefixArg(prefix); - if (!this.isMinibuffer) { - this.whenMinibuffer(function(mb){ - mb.cmd("insert", " ", ch); - }); - } - return true; - } - this.popKeymap(Ymacs_Keymap_UniversalArgument()); - return false; - }) ]; - - P.attached = function(buffer) { - buffer.setPrefixArg(""); - }; - -}); diff --git a/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-keymap-isearch.js.svn-base b/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-keymap-isearch.js.svn-base deleted file mode 100644 index 593b772..0000000 --- a/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-keymap-isearch.js.svn-base +++ /dev/null @@ -1,181 +0,0 @@ -//> This file is part of Ymacs, an Emacs-like editor for the Web -//> http://www.ymacs.org/ -//> -//> Copyright (c) 2009-2010, Mihai Bazon, Dynarch.com. All rights reserved. -//> -//> Redistribution and use in source and binary forms, with or without -//> modification, are permitted provided that the following conditions are -//> met: -//> -//> * Redistributions of source code must retain the above copyright -//> notice, this list of conditions and the following disclaimer. -//> -//> * Redistributions in binary form must reproduce the above copyright -//> notice, this list of conditions and the following disclaimer in -//> the documentation and/or other materials provided with the -//> distribution. -//> -//> * Neither the name of Dynarch.com nor the names of its contributors -//> may be used to endorse or promote products derived from this -//> software without specific prior written permission. -//> -//> THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY -//> EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -//> IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -//> PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE -//> FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -//> CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -//> SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -//> INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -//> CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -//> ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF -//> THE POSSIBILITY OF SUCH DAMAGE. - -// @require ymacs-keymap.js - -DEFINE_SINGLETON("Ymacs_Keymap_ISearch", Ymacs_Keymap, function(D, P){ - - D.KEYS = { - "C-g && ESCAPE": [ "isearch_abort", true ], - "C-w": "isearch_yank_word_or_char", - "C-s": "isearch_forward", - "C-r": "isearch_backward", - "BACKSPACE": function() { - if (this.getMinibuffer().point() > this._isearchContext.mbMark.getPosition()) { - this.getMinibuffer().cmd("backward_delete_char"); - this.cmd("goto_char", this._isearchContext.point); - updateIsearch.call(this, this._isearchContext.forward); - } - }, - "ENTER": "isearch_abort" - }; - - D.CONSTRUCT = function() { - this.defaultHandler = [ "isearch_printing_char" ]; - }; - - function initIsearch(fw) { - if (!this._isearchContext) { - this.pushKeymap(Ymacs_Keymap_ISearch()); - this.cmd("set_mark_command", this.point()); - this.setMinibuffer(fw ? "I-Search: " : "I-Search backward: "); - this._isearchContext = { - forward : fw, - point : this.point(), - mbMark : this.getMinibuffer().createMarker(null, true) - }; - return true; - } - }; - - function updateIsearch(fw) { - this._isearchContext.forward = fw; - this._isearchContext.point = this.point(); - var text = getText(this); - if (!/\S/.test(text) && this._isearchLastText) { - this.getMinibuffer()._placeUndoBoundary(); - this.getMinibuffer().cmd("insert", this._isearchLastText); - text = this._isearchLastText; - } - return doSearch.call(this, text); - }; - - function doSearch(text) { - if (text == null) - text = getText(this); - var found = this.cmd("bind_variables", { case_fold_search: text == text.toLowerCase() }, - this.cmd, - this._isearchContext.forward ? "search_forward" : "search_backward", - text); - if (found) { - this.cmd("ensure_caret_visible"); - var rc_begin = this._positionToRowCol(this.point() + (this._isearchContext.forward ? -1 : 1) * text.length); - this.setOverlay("isearch", { - line1: rc_begin.row, line2: this._rowcol.row, - col1: rc_begin.col, col2: this._rowcol.col - }); - } - return found; - }; - - function getText(o) { - return o.cmd("isearch_get_search_text"); - }; - - Ymacs_Buffer.newCommands({ - - isearch_get_search_text: Ymacs_Interactive(function() { - if (this._isearchContext) { - return this.getMinibuffer()._bufferSubstring(this._isearchContext.mbMark); - } - }), - - isearch_forward: Ymacs_Interactive(function() { - if (!initIsearch.call(this, true)) { - if (!updateIsearch.call(this, true)) - this.signalError("No more forward occurrences of the search text"); - } - }), - - isearch_forward_regexp: Ymacs_Interactive(function() { - this.signalError("Not implemented, but should be easy. Volunteers?"); - }), - - isearch_backward_regexp: Ymacs_Interactive(function() { - this.signalError("Not implemented, but should be easy. Volunteers?"); - }), - - isearch_backward: Ymacs_Interactive(function() { - if (!initIsearch.call(this, false)) { - if (!updateIsearch.call(this, false)) - this.signalError("No more backward occurrences of the search text"); - } - }), - - isearch_yank_word_or_char: Ymacs_Interactive(function() { - var pos = this.point(), - pos2 = this.cmd("save_excursion", function(){ - this.cmd("forward_word"); - return this.point(); - }); - if (pos2 != pos) { - var word = this._bufferSubstring(pos, pos2); - this.getMinibuffer()._placeUndoBoundary(); - this.getMinibuffer().cmd("insert", word.toLowerCase()); - word = getText(this); - if (this._isearchContext.forward) - this.cmd("goto_char", pos2 - word.length); - doSearch.call(this, word); - } - }), - - isearch_printing_char: Ymacs_Interactive(function() { - var ev = this.interactiveEvent(); - if (ev.charCode && !ev.ctrlKey && !ev.altKey) { - this.getMinibuffer().cmd("self_insert_command"); - this.cmd("goto_char", this._isearchContext.point); - doSearch.call(this, getText(this)); - return ev.domStop = true; - } else if (ev.keyCode != 0 || ev.ctrlKey || ev.altKey) { - this.cmd("isearch_abort"); - return false; - } - }), - - isearch_abort: Ymacs_Interactive(function(cancelled) { - if (!cancelled) - this._isearchLastText = getText(this); - this.setMinibuffer(""); - this.popKeymap(Ymacs_Keymap_ISearch()); - this._isearchContext.mbMark.destroy(); - this._isearchContext = null; - if (cancelled) - this.cmd("exchange_point_and_mark"); - this.deleteOverlay("isearch"); - this.deleteOverlay("isearch-lazy"); - return true; - }) - - }); - -}); diff --git a/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-keymap.js.svn-base b/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-keymap.js.svn-base deleted file mode 100644 index 142570a..0000000 --- a/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-keymap.js.svn-base +++ /dev/null @@ -1,167 +0,0 @@ -//> This file is part of Ymacs, an Emacs-like editor for the Web -//> http://www.ymacs.org/ -//> -//> Copyright (c) 2009-2010, Mihai Bazon, Dynarch.com. All rights reserved. -//> -//> Redistribution and use in source and binary forms, with or without -//> modification, are permitted provided that the following conditions are -//> met: -//> -//> * Redistributions of source code must retain the above copyright -//> notice, this list of conditions and the following disclaimer. -//> -//> * Redistributions in binary form must reproduce the above copyright -//> notice, this list of conditions and the following disclaimer in -//> the documentation and/or other materials provided with the -//> distribution. -//> -//> * Neither the name of Dynarch.com nor the names of its contributors -//> may be used to endorse or promote products derived from this -//> software without specific prior written permission. -//> -//> THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY -//> EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -//> IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -//> PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE -//> FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -//> CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -//> SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -//> INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -//> CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -//> ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF -//> THE POSSIBILITY OF SUCH DAMAGE. - -// @require ymacs-buffer.js - -DEFINE_CLASS("Ymacs_Keymap", null, function(D, P){ - - var REVERSE_KEYS = {}; - Object.foreach(DlKeyboard, function(val, key) { - if (typeof val == "number") - REVERSE_KEYS[val] = key; - }); - - D.CONSTRUCT = function() { - this.definitions = Object.makeCopy(this.__originalDefs); - }; - - P.FINISH_OBJECT_DEF = function() { - this.__originalDefs = {}; - var keys = this.constructor.KEYS; - if (keys) - this.defineKeys(keys); - }; - - P.parseKey = function(str) { - var key = {}; - var a = str.split(/-/); - a.reverse(); - a.foreach(function(c, i){ - if (i == 0) { - if (typeof DlKeyboard[c] == "number") - key.keyCode = DlKeyboard[c]; - else { - a[i] = c.toLowerCase(); - key.charCode = a[i].charCodeAt(0); - } - } else switch(c) { - case "C": key.ctrlKey = true; break; - case "M": key.metaKey = true; break; - case "S": key.shiftKey = true; break; - } - }); - a.reverse(); - var c = a.pop(); - key.str = a.sort().join("-"); - if (key.str) - key.str += "-"; - key.str += c; - return key; - }; - - D.unparseKey = function(ev) { - var key, modifiers = []; - if (ev.keyCode in REVERSE_KEYS) - key = REVERSE_KEYS[ev.keyCode]; - else if (ev.charCode) { - if (ev.charCode == 32) - key = "SPACE"; - else if (ev.charCode == 45) - key = "DASH"; - else if (ev.charCode == 58) - key = "COLON"; - else if (ev.charCode == 41) - key = "CLOSED ROUND BRACKET"; - else if (ev.charCode == 125) - key = "CLOSED CURLY BRACKET"; - else - key = String.fromCharCode(ev.charCode).toLowerCase(); - } - if (ev.ctrlKey) - modifiers.push("C"); - if (ev.altKey) - modifiers.push("M"); - if (ev.shiftKey && (ev.charCode && /^[a-zA-Z0-9]$/.test(key) || ev.keyCode)) - modifiers.push("S"); - modifiers.sort(); - modifiers = modifiers.join("-"); - if (modifiers) - modifiers += "-"; - return modifiers + key; - }; - - P.defineKey = function(key, func, args) { - if (func instanceof Array) { - args = func.slice(1); - func = func[0]; - } - key = key.trim().split(/\s*&&\s*/); - if (key.length > 1) { - key.foreach(function(key){ - this.defineKey(key, func, args); - }, this); - } else { - key = key[0].trim(); - var dfn = this.definitions || this.__originalDefs; - if (key.indexOf(" ") >= 0) { - var a = key.split(/\s+/); - key = a.pop(); - a.foreach(function(key){ - key = this.parseKey(key).str; - if (!dfn[key]) - dfn[key] = {}; - dfn = dfn[key]; - }, this); - } - key = this.parseKey(key); - dfn[key.str] = [ func, args ]; - } - }; - - P.defineKeys = function(map) { - Object.foreach(map, function(func, key){ - this.defineKey(key, func); - }, this); - }; - - P.getHandler = function(keys) { - var handler = null, def = this.definitions; - keys.foreach(function(key){ - var tmp = handler ? handler[key] : def[key]; - if (tmp) { - handler = tmp; - if (handler instanceof Array) - $BREAK(); - } - else if (handler) { - handler = null; - $BREAK(); - } - }); - return handler; - }; - - P.attached = Function.noop; - P.detached = Function.noop; - -}); diff --git a/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-marker.js.svn-base b/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-marker.js.svn-base deleted file mode 100644 index ca9c1c0..0000000 --- a/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-marker.js.svn-base +++ /dev/null @@ -1,105 +0,0 @@ -//> This file is part of Ymacs, an Emacs-like editor for the Web -//> http://www.ymacs.org/ -//> -//> Copyright (c) 2009-2010, Mihai Bazon, Dynarch.com. All rights reserved. -//> -//> Redistribution and use in source and binary forms, with or without -//> modification, are permitted provided that the following conditions are -//> met: -//> -//> * Redistributions of source code must retain the above copyright -//> notice, this list of conditions and the following disclaimer. -//> -//> * Redistributions in binary form must reproduce the above copyright -//> notice, this list of conditions and the following disclaimer in -//> the documentation and/or other materials provided with the -//> distribution. -//> -//> * Neither the name of Dynarch.com nor the names of its contributors -//> may be used to endorse or promote products derived from this -//> software without specific prior written permission. -//> -//> THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY -//> EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -//> IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -//> PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE -//> FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -//> CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -//> SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -//> INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -//> CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -//> ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF -//> THE POSSIBILITY OF SUCH DAMAGE. - -// @require ymacs-buffer.js - -/* -----[ markers are objects that hold a position which is - automatically maintained as text is inserted or - removed ]----- */ - -DEFINE_CLASS("Ymacs_Marker", null, function(D, P){ - - D.DEFAULT_ARGS = { - position : [ "pos" , null ], - editor : [ "editor" , null ], - before : [ "before" , false ], - name : [ "name" , null ] - }; - - D.CONSTRUCT = function() { - this.editor.markers.push(this); - this.rowcol = null; - this.onChange = []; - }; - - P.destroy = function() { - this.editor.markers.remove(this); - this.editor = null; - }; - - P.editorChange = function(pos, diff, min) { - var p = this.position; - if (this.before) - --p; - if (diff != 0 && pos <= p) { - this.rowcol = null; - this.position += diff; - if (this.position < min) - this.position = min; - this.callHooks(this.onChange, this.position); - } - }; - - P.callHooks = function(a, arg) { - for (var i = a.length; --i >= 0;) - a[i].call(this.editor, arg); - }; - - P.getPosition = function() { - return this.position; - }; - - P.setPosition = function(pos, noHooks, force) { - if (force || this.position != pos) { - this.rowcol = null; - this.position = pos; - if (!noHooks) - this.callHooks(this.onChange, this.position); - } - }; - - P.getRowCol = function() { - return this.rowcol || (this.rowcol = this.editor._positionToRowCol(this.position)); - }; - - P.updateMarkers = function(delta) { - this.editor._updateMarkers(this.getPosition(), delta); - }; - - P.swap = function(other, noHooks, force) { - var tmp = this.getPosition(); - this.setPosition(other.getPosition(), noHooks, force); - other.setPosition(tmp, noHooks, force); - }; - -}); diff --git a/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-minibuffer.js.svn-base b/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-minibuffer.js.svn-base deleted file mode 100644 index 01fd0f2..0000000 --- a/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-minibuffer.js.svn-base +++ /dev/null @@ -1,429 +0,0 @@ -//> This file is part of Ymacs, an Emacs-like editor for the Web -//> http://www.ymacs.org/ -//> -//> Copyright (c) 2009-2010, Mihai Bazon, Dynarch.com. All rights reserved. -//> -//> Redistribution and use in source and binary forms, with or without -//> modification, are permitted provided that the following conditions are -//> met: -//> -//> * Redistributions of source code must retain the above copyright -//> notice, this list of conditions and the following disclaimer. -//> -//> * Redistributions in binary form must reproduce the above copyright -//> notice, this list of conditions and the following disclaimer in -//> the documentation and/or other materials provided with the -//> distribution. -//> -//> * Neither the name of Dynarch.com nor the names of its contributors -//> may be used to endorse or promote products derived from this -//> software without specific prior written permission. -//> -//> THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY -//> EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -//> IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -//> PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE -//> FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -//> CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -//> SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -//> INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -//> CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -//> ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF -//> THE POSSIBILITY OF SUCH DAMAGE. - -// @require ymacs-buffer.js -// @require ymacs-keymap.js - -Ymacs_Buffer.newMode("minibuffer_mode", function(){ - var marker = this.createMarker(0, true); - var changed_vars = this.setq({ - minibuffer_end_marker: marker - }); - var keymap = Ymacs_Keymap_Minibuffer(); - this.pushKeymap(keymap); - return function() { - this.setq(changed_vars); - marker.destroy(); - this.popKeymap(keymap); - }; -}); - -(function(){ - - var $popupActive = false; - var $menu = null, $item = null; - function popupCompletionMenu(frame, list) { - if ($menu) - $menu.destroy(); - $menu = new DlVMenu({}); - list.foreach(function(item){ - var data = item; - if (typeof item != "string") { - data = item.completion; - item = item.label; - } - new DlMenuItem({ parent: $menu, label: item.htmlEscape(), data: data }); - }); - var popup = Ymacs_Completion_Popup.get(); - popup.popup({ - timeout: 0, - content: $menu, - align: { - prefer: "Tr", - fallX1: "_r", - fallX2: "_L", - fallY1: "B_", - fallY2: "T_" - }, - anchor: frame.getCaretElement(), - widget: frame, - onHide: function() { - $popupActive = false; - // $menu.destroy(); - $item = null; - $menu = null; - }, - isContext: true - }); - $popupActive = true; - }; - - function read_with_continuation(completions, cont, validate) { - this.whenMinibuffer(function(mb){ - var changed_vars = mb.setq({ - completion_list: completions, - minibuffer_validation: function(what){ - if (what == null) - what = mb.cmd("minibuffer_contents"); - if (validate) - return validate.call(this, mb, what); - return true; // accept anything by default - }.$(this), - minibuffer_continuation: function(what){ - mb.setq(changed_vars); - if (cont) - cont.call(this, what); - }.$(this) - }); - }); - }; - - function filename_completion(mb, str) { - var info = this.ymacs.ls_getFileDirectory(str), - dir = info.dir, - other = info.other, - path = info.path, - last = other[0]; - if (other.length != 1) - throw new Ymacs_Exception("Not found"); - if (typeof dir[last] == "string") - return [ path.concat([ last ]).join("/") ]; // fully completed - var completions = []; - for (var i in dir) { - if (i.indexOf(last) == 0) { - completions.push(i); - } - } - var prefix = completions.common_prefix(); - if (prefix != last) { - if (completions.length == 1 && typeof dir[prefix] != "string") - prefix += "/"; - mb.cmd("minibuffer_replace_input", path.concat([ prefix ]).join("/")); - } - else if (completions.length == 1) { - // XXX: do we ever get here? - throw new Ymacs_Exception("Single completion"); - } - else if (completions.length == 0) { - throw new Ymacs_Exception("No completions"); - } - else { - completions = completions.map(function(name){ - if (typeof dir[name] != "string") - name += "/"; - return { - label: name, - completion: path.concat([ name ]).join("/") - }; - }); - popupCompletionMenu(this.getMinibufferFrame(), completions); - } - return null; - }; - - Ymacs_Buffer.newCommands({ - - minibuffer_prompt: function(prompt, nofocus) { - this.whenMinibuffer(function(mb){ - var f = this.getMinibufferFrame(); - mb.setCode(""); - mb.cmd("prevent_undo", function(){ - mb.cmd("insert", prompt); - }); - mb.getq("minibuffer_end_marker").setPosition(mb.point()); - f._redrawCaret(true); - if (!nofocus) - f.focus(); - }); - }, - - minibuffer_read_number: function(cont) { - read_with_continuation.call(this, null, cont, function(mb, text){ - var n = parseInt(text, 10); - if (isNaN(n)) - mb.signalError("Please enter a number"); - return !isNaN(n); - }); - }, - - minibuffer_read_command: function(cont) { - var commandNames = Array.hashKeys(this.COMMANDS).grep(function(cmd){ - return this.COMMANDS[cmd].ymacsInteractive; - }, this).sort(); - read_with_continuation.call(this, commandNames, cont, function(mb, name){ - var cmd = this.COMMANDS[name], - ret = cmd && cmd.ymacsInteractive; - if (!ret) { - mb.signalError("No such command: " + name); - } - return ret; - }); - }, - - minibuffer_read_function: function(cont) { - var commandNames = Array.hashKeys(this.COMMANDS).sort(); - read_with_continuation.call(this, commandNames, cont, function(mb, name){ - var cmd = this.COMMANDS[name], - ret = !!cmd; - if (!ret) - mb.signalError("No such function: " + name); - return ret; - }); - }, - - minibuffer_read_buffer: function(cont) { - this.whenYmacs(function(ymacs){ - var bufferNames = ymacs.buffers.map("name"); - bufferNames.push(bufferNames.shift()); - read_with_continuation.call(this, bufferNames, cont); - handle_tab.call(this); - }); - }, - - minibuffer_read_string: function(completions, cont) { - read_with_continuation.call(this, completions, cont); - }, - - minibuffer_read_variable: function(cont) { - var tmp = this.globalVariables; - Object.merge(tmp, this.variables); - var completions = Array.hashKeys(tmp).grep(function(name){ - return !/^\*/.test(name); - }).sort(); - read_with_continuation.call(this, completions, cont - // XXX: seems like a good idea, but it doesn't work - // XXX: need to refactor the signalInfo stuff. It doesn't show up - // currently because the buffer frame is not active, or something... - // , function(mb, name){ - // var val = this.getq(name); - // mb.signalInfo("Current value of " + name + ": " + val); - // return true; - // } - ); - }, - - minibuffer_read_existing_file: function(cont) { - var dir = this.ymacs.ls_getFileDirectory(this.name).path.join("/"); - if (dir) dir += "/"; - this.cmd("minibuffer_replace_input", dir); - read_with_continuation.call(this, filename_completion, cont, function(mb, name){ - var ret = this.ymacs.ls_getFileContents(name, true); - if (!ret) - mb.signalError("No such file: " + name); - return ret; - }); - }, - - minibuffer_read_file: function(cont) { - var dir = this.ymacs.ls_getFileDirectory(this.name).path.join("/"); - if (dir) dir += "/"; - read_with_continuation.call(this, filename_completion, cont); - }, - - minibuffer_read_file_or_directory: function(cont) { - var dir = this.ymacs.ls_getFileDirectory(this.name).path.join("/"); - if (dir) dir += "/"; - read_with_continuation.call(this, filename_completion, cont); - }, - - minibuffer_read_directory: function(cont) { - var dir = this.ymacs.ls_getFileDirectory(this.name).path.join("/"); - if (dir) dir += "/"; - read_with_continuation.call(this, filename_completion, cont); - }, - - minibuffer_prompt_end: function() { - return this.whenMinibuffer(function(mb){ - return mb.getq("minibuffer_end_marker").getPosition(); - }); - }, - - minibuffer_contents: function() { - return this.whenMinibuffer(function(mb){ - return mb._bufferSubstring(mb.getq("minibuffer_end_marker")); - }); - }, - - minibuffer_replace_input: function(value) { - this.whenMinibuffer(function(mb){ - mb._replaceText(mb.getq("minibuffer_end_marker"), mb.getCodeSize(), value); - this.getMinibufferFrame()._redrawCaret(true); - }); - }, - - minibuffer_complete: function() { - this.whenMinibuffer(function(mb){ - var a = mb.getq("completion_list"), - str = mb.cmd("minibuffer_contents"), - re = str.replace(/([\[\]\(\)\{\}\.\*\+\?\|\\])/g, "\\$1").replace(/([_-])/g, "[^_-]*[_-]"); - re = new RegExp("^" + re, "i"); - if (a instanceof Function) { - a = a.call(this, mb, str, re); - if (!a) - return; - } - else if (a && a.length > 0) { - a = a.grep(function(cmd){ - return re.test(cmd); - }); - } - if (!a || a.length == 0) { - mb.signalError("No completions"); - } - else { - var prefix = a.common_prefix(); - if (prefix != str) { - mb.cmd("minibuffer_replace_input", prefix); - } - else if (a.length == 1) { - mb.signalError("Sole completion"); - } - else { - popupCompletionMenu(this.getMinibufferFrame(), a); - } - } - }); - }, - - minibuffer_complete_and_exit: function() { - this.whenMinibuffer(function(mb){ - if (mb.getq("minibuffer_validation").call(mb)) { - mb.cmd("minibuffer_keyboard_quit", this.getq("minibuffer_continuation")); - } - }); - }, - - minibuffer_keyboard_quit: function(cont) { - this.whenMinibuffer(function(mb){ - var text = this.cmd("minibuffer_contents"); - mb.setCode(""); - this.ymacs.getActiveFrame().focus(); - (function(text){ - if (cont) - cont.call(this, text); - this.getPrefixArg(); - }).delayed(1, this, text); - }); - DlPopup.clearAllPopups(); - } - - }); - - function handle_completion(how) { - var old_item = $item, w; - switch (how) { - case "next": - if ($item == null) - $item = -1; - $item = $menu.children().rotateIndex(++$item); - break; - case "prev": - if ($item == null) - $item = 0; - $item = $menu.children().rotateIndex(--$item); - break; - } - if (old_item != null) { - w = $menu.children(old_item); - w.callHooks("onMouseLeave"); - } - old_item = $item; - w = $menu.children($item); - w.callHooks("onMouseEnter"); - }; - - function handle_arrow_down() { - if ($popupActive) { - return handle_completion.call(this, "next"); - } - }; - - function handle_arrow_up() { - if ($popupActive) { - return handle_completion.call(this, "prev"); - } - }; - - function handle_enter() { - if ($popupActive) { - if ($item != null) { - this.cmd("minibuffer_replace_input", $menu.children()[$item].userData); - DlPopup.clearAllPopups(); - } else { - this.signalError("Select something..."); - } - } else { - this.cmd("minibuffer_complete_and_exit"); - } - }; - - function handle_tab() { - if (!$popupActive) - this.cmd("minibuffer_complete"); - handle_arrow_down.call(this); // autoselect the first one anyway - }; - - function handle_s_tab() { - handle_arrow_up.call(this); - }; - - function handle_escape() { - if ($popupActive) { - DlPopup.clearAllPopups(); - } else { - this.cmd("minibuffer_keyboard_quit"); - } - }; - - DEFINE_SINGLETON("Ymacs_Keymap_Minibuffer", Ymacs_Keymap, function(D, P){ - - D.KEYS = { - "C-g" : "minibuffer_keyboard_quit", - "TAB" : handle_tab, - "S-TAB" : handle_s_tab, - "ARROW_DOWN" : handle_arrow_down, - "ARROW_UP" : handle_arrow_up, - "ENTER" : handle_enter, - "ESCAPE" : handle_escape - }; - - P.defaultHandler = [ function() { - DlPopup.clearAllPopups(); - return false; // say it's not handled though - } ]; - - }); - -})(); - -DEFINE_CLASS("Ymacs_Completion_Popup", DlCompletionPopup); diff --git a/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-mode-css.js.svn-base b/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-mode-css.js.svn-base deleted file mode 100644 index 40cb87a..0000000 --- a/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-mode-css.js.svn-base +++ /dev/null @@ -1,263 +0,0 @@ -//> This file is part of Ymacs, an Emacs-like editor for the Web -//> http://www.ymacs.org/ -//> -//> Copyright (c) 2009-2010, Mihai Bazon, Dynarch.com. All rights reserved. -//> -//> Redistribution and use in source and binary forms, with or without -//> modification, are permitted provided that the following conditions are -//> met: -//> -//> * Redistributions of source code must retain the above copyright -//> notice, this list of conditions and the following disclaimer. -//> -//> * Redistributions in binary form must reproduce the above copyright -//> notice, this list of conditions and the following disclaimer in -//> the documentation and/or other materials provided with the -//> distribution. -//> -//> * Neither the name of Dynarch.com nor the names of its contributors -//> may be used to endorse or promote products derived from this -//> software without specific prior written permission. -//> -//> THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY -//> EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -//> IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -//> PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE -//> FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -//> CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -//> SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -//> INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -//> CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -//> ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF -//> THE POSSIBILITY OF SUCH DAMAGE. - -// @require ymacs-tokenizer.js - -Ymacs_Tokenizer.define("css", function(stream, tok){ - - var PARSER = { - next : next, - copy : copy, - indentation : indentation - }; - - var $parens = []; - var $passedParens = []; - var $cont = []; - var $inString = null; - var $inComment = null; - - function copy() { - var c = resume.context = { - parens : $parens.slice(0), - passedParens : $passedParens.slice(0), - cont : $cont.slice(0), - inString : $inString, - inComment : $inComment - }; - function resume() { - $parens = c.parens.slice(0); - $passedParens = c.passedParens.slice(0); - $cont = c.cont.slice(0); - $inString = c.inString; - $inComment = c.inComment; - return PARSER; - }; - return resume; - }; - - function INDENT_LEVEL() { - return tok.buffer.getq("indent_level"); - }; - - var OPEN_PAREN = { - "(" : ")", - "{" : "}", - "[" : "]" - }; - - var CLOSE_PAREN = { - ")" : "(", - "}" : "{", - "]" : "[" - }; - - function isOpenParen(ch) { - return OPEN_PAREN[ch]; - }; - - function isCloseParen(ch) { - return CLOSE_PAREN[ch]; - }; - - function foundToken(c1, c2, type) { - tok.onToken(stream.line, c1, c2, type); - }; - - function readComment() { - var line = stream.lineText(), pos = line.indexOf("*/", stream.col); - var m = /^\s*\*+/.exec(line.substr(stream.col)); - if (m) { - foundToken(stream.col, stream.col += m[0].length, "mcomment-starter"); - } - if (pos >= 0) { - $cont.pop(); - $inComment = null; - foundToken(stream.col, pos, "mcomment"); - foundToken(pos, pos += 2, "mcomment-stopper"); - stream.col = pos; - } else { - foundToken(stream.col, line.length, "mcomment"); - stream.col = line.length; - } - }; - - function readString(end, type) { - var ch, esc = false, start = stream.col; - while (!stream.eol()) { - ch = stream.peek(); - if (ch === end && !esc) { - $cont.pop(); - $inString = null; - foundToken(start, stream.col, type); - foundToken(stream.col, ++stream.col, type + "-stopper"); - return true; - } - esc = !esc && ch === "\\"; - stream.nextCol(); - } - foundToken(start, stream.col, type); - }; - - function next() { - stream.checkStop(); - if ($cont.length > 0) - return $cont.peek()(); - var ch = stream.peek(), tmp; - if (stream.lookingAt("/*")) { - $inComment = { line: stream.line, c1: stream.col }; - foundToken(stream.col, stream.col += 2, "mcomment-starter"); - $cont.push(readComment); - } - else if (ch === '"' || ch === "'") { - $inString = { line: stream.line, c1: stream.col }; - foundToken(stream.col, ++stream.col, "string-starter"); - $cont.push(readString.$C(ch, "string")); - } - else if ((tmp = isOpenParen(ch))) { - $parens.push({ line: stream.line, col: stream.col, type: ch }); - foundToken(stream.col, ++stream.col, "open-paren"); - } - else if ((tmp = isCloseParen(ch))) { - var p = $parens.pop(); - if (!p || p.type != tmp) { - foundToken(stream.col, ++stream.col, "error"); - } else { - // circular reference; poor browsers will leak. mwuhahahaha - p.closed = { line: stream.line, col: stream.col, opened: p }; - $passedParens.push(p); - foundToken(stream.col, ++stream.col, "close-paren"); - } - } - else if ((tmp = stream.lookingAt(/^([a-zA-z-]+):/))) { - foundToken(stream.col, stream.col += tmp[1].length, "keyword"); - foundToken(stream.col, ++stream.col, "operator"); - } - else if ((tmp = stream.lookingAt(/^([0-9.]+)(px|pt|em|ex|in|cm|mm|%)/))) { - foundToken(stream.col, stream.col += tmp[1].length, "number"); - foundToken(stream.col, stream.col += tmp[2].length, "type"); - } - else if ((tmp = stream.lookingAt(/^(\.[a-zA-Z0-9_:-]+)/))) { - foundToken(stream.col, stream.col += tmp[1].length, "function-name"); - } - else if ((tmp = stream.lookingAt(/^(#[a-zA-Z0-9_:-]+)/))) { - foundToken(stream.col, stream.col += tmp[1].length, "constant"); - } - else if ((tmp = stream.lookingAt(/^(@[a-zA-Z0-9_:-]+)/))) { - foundToken(stream.col, stream.col += tmp[1].length, "builtin"); - } - else if ((tmp = stream.lookingAt(/^(url|none|auto|bold|italic|normal|inherit|print|screen|all)/))) { - foundToken(stream.col, stream.col += tmp[1].length, "builtin"); - } - else { - foundToken(stream.col, ++stream.col, null); - } - }; - - function indentation() { - // no indentation for continued strings - if ($inString) - return 0; - - var row = stream.line; - var currentLine = stream.lineText(); - var indent = 0; - - if ($inComment) { - var commentStartLine = stream.lineText($inComment.line); - indent = $inComment.c1 + 1; - if (!/^\s*\*/.test(currentLine)) { - // align with the first non-whitespace and non-asterisk character in the comment - var re = /[^\s*]/g; - re.lastIndex = $inComment.c1 + 1; - var m = re.exec(commentStartLine); - if (m) - indent = m.index; - } - return indent; - } - - var p = $parens.peek(); - if (p) { - // check if the current line closes the paren - var re = new RegExp("^\\s*\\" + OPEN_PAREN[p.type]); - var thisLineCloses = re.test(currentLine); - - // Check if there is text after the opening paren. If so, indent to that column. - var line = stream.lineText(p.line); - re = /\S/g; - re.lastIndex = p.col + 1; - var m = re.exec(line); - if (m) { - // but if this line closes the paren, better use the column of the open paren - indent = thisLineCloses ? p.col : m.index; - } - else { - // Otherwise we should indent to one level more than the indentation of the line - // containing the opening paren. - indent = stream.lineIndentation(p.line) + INDENT_LEVEL(); - - // but if this line closes the paren, then back one level - if (thisLineCloses) - indent -= INDENT_LEVEL(); - } - } - - return indent; - }; - - return PARSER; - -}); - -DEFINE_SINGLETON("Ymacs_Keymap_CSS", Ymacs_Keymap); -Ymacs_Keymap_CSS().defineKeys({ - "ENTER" : "newline_and_indent", - ": && } && )" : "c_insert_and_indent" -}); - -Ymacs_Buffer.newMode("css_mode", function(){ - - var tok = this.tokenizer; - this.setTokenizer(new Ymacs_Tokenizer({ buffer: this, type: "css" })); - var was_paren_match = this.cmd("paren_match_mode", true); - this.pushKeymap(Ymacs_Keymap_CSS()); - - return function() { - this.setTokenizer(tok); - if (!was_paren_match) - this.cmd("paren_match_mode", false); - this.popKeymap(Ymacs_Keymap_CSS()); - }; - -}); diff --git a/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-mode-js.js.svn-base b/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-mode-js.js.svn-base deleted file mode 100644 index 1265bc6..0000000 --- a/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-mode-js.js.svn-base +++ /dev/null @@ -1,431 +0,0 @@ -//> This file is part of Ymacs, an Emacs-like editor for the Web -//> http://www.ymacs.org/ -//> -//> Copyright (c) 2009-2010, Mihai Bazon, Dynarch.com. All rights reserved. -//> -//> Redistribution and use in source and binary forms, with or without -//> modification, are permitted provided that the following conditions are -//> met: -//> -//> * Redistributions of source code must retain the above copyright -//> notice, this list of conditions and the following disclaimer. -//> -//> * Redistributions in binary form must reproduce the above copyright -//> notice, this list of conditions and the following disclaimer in -//> the documentation and/or other materials provided with the -//> distribution. -//> -//> * Neither the name of Dynarch.com nor the names of its contributors -//> may be used to endorse or promote products derived from this -//> software without specific prior written permission. -//> -//> THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY -//> EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -//> IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -//> PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE -//> FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -//> CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -//> SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -//> INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -//> CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -//> ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF -//> THE POSSIBILITY OF SUCH DAMAGE. - -// @require ymacs-tokenizer.js - -/* -----[ This defines the tokenizer ]----- */ - -(function(){ - - var KEYWORDS = "abstract break case catch class const \ -continue debugger default delete do else \ -enum export extends final finally for \ -function goto if implements import in \ -instanceof interface native new package \ -private protected public return static \ -super switch synchronized throw \ -throws transient try typeof var void let \ -yield volatile while with".qw(); - - var KEYWORDS_TYPE = "boolean byte char double float int long short void \ -Array Date Function Math Number Object RegExp String".qw(); - - var KEYWORDS_CONST = "false null undefined Infinity NaN true arguments this".qw(); - - var KEYWORDS_BUILTIN = "Infinity NaN \ -Packages decodeURI decodeURIComponent \ -encodeURI encodeURIComponent eval isFinite isNaN parseFloat \ -parseInt undefined window document alert prototype constructor".qw(); - - var ALLOW_REGEXP_AFTER = /[\[({,;+\-*=?&|!:][\x20\t\n\xa0]*$|return\s+$|typeof\s+$/; - - function isLetter(ch) { - return ch.toLowerCase() != ch.toUpperCase(); - }; - - function isNameStart(ch) { - return ch && (isLetter(ch) || /^[_$]$/.test(ch)); - }; - - function isNameChar(ch) { - return ch && (isLetter(ch) || /^[0-9_$]$/.test(ch)); - }; - - var OPEN_PAREN = { - "(" : ")", - "{" : "}", - "[" : "]" - }; - - var CLOSE_PAREN = { - ")" : "(", - "}" : "{", - "]" : "[" - }; - - function isOpenParen(ch) { - return OPEN_PAREN[ch]; - }; - - function isCloseParen(ch) { - return CLOSE_PAREN[ch]; - }; - - function JS_PARSER(KEYWORDS, KEYWORDS_TYPE, KEYWORDS_CONST, KEYWORDS_BUILTIN, stream, tok) { - - var $cont = [], - $parens = [], - $passedParens = [], - $inComment = null, - $inString = null, - PARSER = { - next : next, - copy : copy, - indentation : indentation - }; - - function INDENT_LEVEL() { - return stream.buffer.getq("indent_level"); - }; - - function copy() { - var context = restore.context = { - cont : $cont.slice(0), - inComment : $inComment, - inString : $inString, - parens : $parens.slice(0), - passedParens : $passedParens.slice(0) - }; - function restore() { - $cont = context.cont.slice(0); - $inComment = context.inComment; - $inString = context.inString; - $parens = context.parens.slice(0); - $passedParens = context.passedParens.slice(0); - return PARSER; - }; - return restore; - }; - - function foundToken(c1, c2, type) { - tok.onToken(stream.line, c1, c2, type); - }; - - function readName() { - var col = stream.col, ch = stream.get(), - name = ch; - while (!stream.eol()) { - ch = stream.peek(); - if (!isNameChar(ch)) - break; - name += ch; - stream.nextCol(); - } - return ch && { line: stream.line, c1: col, c2: stream.col, id: name }; - }; - - function readComment() { - var line = stream.lineText(), pos = line.indexOf("*/", stream.col); - var m = /^\s*\*+/.exec(line.substr(stream.col)); - if (m) { - foundToken(stream.col, stream.col += m[0].length, "mcomment-starter"); - } - if (pos >= 0) { - $cont.pop(); - $inComment = null; - foundToken(stream.col, pos, "mcomment"); - foundToken(pos, pos += 2, "mcomment-stopper"); - stream.col = pos; - } else { - foundToken(stream.col, line.length, "mcomment"); - stream.col = line.length; - } - }; - - function readString(end, type) { - var ch, esc = false, start = stream.col; - while (!stream.eol()) { - ch = stream.peek(); - if (ch === end && !esc) { - $cont.pop(); - $inString = null; - foundToken(start, stream.col, type); - foundToken(stream.col, ++stream.col, type + "-stopper"); - return true; - } - esc = !esc && ch === "\\"; - stream.nextCol(); - } - foundToken(start, stream.col, type); - }; - - // function readLiteralRegexp() { - // var m; - // if (readString("/", "regexp") && (m = stream.lookingAt(/^[gmsiy]+/))) - // foundToken(stream.col, stream.col += m[0].length, "regexp-modifier"); - // }; - - function readLiteralRegexp() { - var ch, esc = false, inset = 0, start = stream.col; - while (!stream.eol()) { - ch = stream.peek(); - if (isOpenParen(ch) && !esc && !inset) - inset++; - if (isCloseParen(ch) && !esc) { - inset--; - if (inset < 0) - inset = 0; - } - if (ch === "/" && !esc && !inset) { - $cont.pop(); - $inString = null; - foundToken(start, stream.col, "regexp"); - foundToken(stream.col, ++stream.col, "regexp-stopper"); - var m = stream.lookingAt(/^[gmsiy]+/); - if (m) - foundToken(stream.col, stream.col += m[0].length, "regexp-modifier"); - return true; - } - esc = !esc && ch === "\\"; - stream.nextCol(); - } - foundToken(start, stream.col, "regexp"); - }; - - function next() { - stream.checkStop(); - if ($cont.length > 0) - return $cont.peek()(); - var ch = stream.peek(), m, tmp; - if (stream.lookingAt("/*")) { - $inComment = { line: stream.line, c1: stream.col }; - foundToken(stream.col, stream.col += 2, "mcomment-starter"); - $cont.push(readComment); - } - else if (stream.lookingAt("//")) { - foundToken(stream.col, stream.col += 2, "comment-starter"); - foundToken(stream.col, stream.col = stream.lineLength(), "comment"); - } - else if (ch === '"' || ch === "'") { - $inString = { line: stream.line, c1: stream.col }; - foundToken(stream.col, ++stream.col, "string-starter"); - $cont.push(readString.$C(ch, "string")); - } - else if ((m = stream.lookingAt(/^0x[0-9a-f]+|^[0-9]*\.?[0-9]+/))) { - foundToken(stream.col, stream.col += m[0].length, "number"); - } - else if (isNameStart(ch) && (tmp = readName())) { - var type = tmp.id in KEYWORDS ? "keyword" - : tmp.id in KEYWORDS_TYPE ? "type" - : tmp.id in KEYWORDS_CONST ? "constant" - : tmp.id in KEYWORDS_BUILTIN ? "builtin" - : null; - foundToken(tmp.c1, tmp.c2, type); - } - else if ((tmp = isOpenParen(ch))) { - $parens.push({ line: stream.line, col: stream.col, type: ch }); - foundToken(stream.col, ++stream.col, "open-paren"); - } - else if ((tmp = isCloseParen(ch))) { - var p = $parens.pop(); - if (!p || p.type != tmp) { - foundToken(stream.col, ++stream.col, "error"); - } else { - // circular reference; poor browsers will leak. mwuhahahaha - p.closed = { line: stream.line, col: stream.col, opened: p }; - $passedParens.push(p); - foundToken(stream.col, ++stream.col, "close-paren"); - } - } - else if (ch === "/" && ALLOW_REGEXP_AFTER.test(stream.textBefore())) { - foundToken(stream.col, ++stream.col, "regexp-starter"); - $cont.push(readLiteralRegexp); - } - else if ((m = stream.lookingAt(/^\s+$/))) { - foundToken(stream.col, stream.col += m[0].length, "trailing-whitespace"); - } - else { - foundToken(stream.col, ++stream.col, null); - } - }; - - function indentation() { - - // no indentation for continued strings - if ($inString) - return 0; - - var row = stream.line; - var currentLine = stream.lineText(); - var indent = 0; - - if ($inComment) { - var commentStartLine = stream.lineText($inComment.line); - indent = $inComment.c1 + 1; - if (!/^\s*\*/.test(currentLine)) { - // align with the first non-whitespace and non-asterisk character in the comment - var re = /[^\s*]/g; - re.lastIndex = $inComment.c1 + 1; - var m = re.exec(commentStartLine); - if (m) - indent = m.index; - } - return indent; - } - - var p = $parens.peek(); - if (p) { - // check if the current line closes the paren - var re = new RegExp("^\\s*\\" + OPEN_PAREN[p.type]); - var thisLineCloses = re.test(currentLine); - - // Check if there is text after the opening paren. If so, indent to that column. - var line = stream.lineText(p.line); - re = /\S/g; - re.lastIndex = p.col + 1; - var m = re.exec(line); - if (m) { - // but if this line closes the paren, better use the column of the open paren - indent = thisLineCloses ? p.col : m.index; - } - else { - // Otherwise we should indent to one level more than the indentation of the line - // containing the opening paren. - indent = stream.lineIndentation(p.line) + INDENT_LEVEL(); - - // but if this line closes the paren, then back one level - if (thisLineCloses) - indent -= INDENT_LEVEL(); - } - } - - // Some more adjustments for continued statements. Since we don't really have a - // rigorous parser, we have to rely on other regexps here, which sucks but will do for - // now. - - if (row > 0) { - var before = stream.textBefore(); - if (/\)\s*$/.test(before) && $passedParens.length > 0) { - // Ends in a paren, could be an if, while or for which demands smart - // indentation on the current line, let's check it out. - - // Note that the passedParen saved for that close paren is actually - // the opening one, which suits us greatly. - p = $passedParens.peek(); - var stmtLine = stream.lineText(p.line); - if (/^\s*(if|for|while)\W/.test(stmtLine)) - indent += INDENT_LEVEL(); - } - else if (/\Welse\s*$/.test(before)) { - indent += INDENT_LEVEL(); - } - } - - // switch labels use half the indent level, which is my favorite - if (/^\s*(case|default)\W/.test(currentLine)) - indent -= INDENT_LEVEL() / 2; - - return indent; - }; - - return PARSER; - - }; - - Ymacs_Tokenizer.define("js", JS_PARSER.$C( - KEYWORDS.toHash(true), - KEYWORDS_TYPE.toHash(true), - KEYWORDS_CONST.toHash(true), - KEYWORDS_BUILTIN.toHash(true) - )); - - /* -----[ DynarchLIB ]----- */ - - var DL_KEYWORDS_BUILTIN = KEYWORDS_BUILTIN.concat("\ -DEFINE_CLASS DEFINE_SINGLETON DEFINE_HIDDEN_CLASS \ -DEFAULT_ARGS DEFAULT_EVENTS \ -FIXARGS CONSTRUCT BEFORE_BASE FINISH_OBJECT_DEF \ -D P $".qw()); - - Ymacs_Tokenizer.define("js-dynarchlib", JS_PARSER.$C( - KEYWORDS.toHash(true), - KEYWORDS_TYPE.toHash(true), - KEYWORDS_CONST.toHash(true), - DL_KEYWORDS_BUILTIN.toHash(true) - )); - -})(); - -/* -----[ Keymap for C-like language mode ]----- */ - -DEFINE_SINGLETON("Ymacs_Keymap_CLanguages", Ymacs_Keymap, function(D, P){ - - D.KEYS = { - "ENTER" : "newline_and_indent", - "} && ) && ] && : && ; && { && ( && [ && *" : "c_insert_and_indent" - // "{" : "c_electric_block" - }; - -}); - -/* -----[ Mode entry point ]----- */ - -Ymacs_Buffer.newMode("javascript_mode", function(useDL) { - var tok = this.tokenizer; - var keymap = Ymacs_Keymap_CLanguages(); - this.setTokenizer(new Ymacs_Tokenizer({ buffer: this, type: useDL ? "js-dynarchlib" : "js" })); - this.pushKeymap(keymap); - var was_paren_match = this.cmd("paren_match_mode", true); - - return function() { - this.setTokenizer(tok); - this.popKeymap(keymap); - if (!was_paren_match) - this.cmd("paren_match_mode", false); - }; - -}); - -Ymacs_Buffer.newCommands({ - - javascript_dl_mode: Ymacs_Interactive(function() { - return this.cmd("javascript_mode", true); - }), - - c_electric_block: Ymacs_Interactive(function() { - this.cmd("indent_line"); - this.cmd("insert", "{\n\n}"); - this.cmd("indent_line"); - this.cmd("backward_line", 1); - this.cmd("indent_line"); - }), - - c_insert_and_indent: Ymacs_Interactive(function() { - var ret; - if ((ret = this.cmd("self_insert_command"))) { - this.cmd("indent_line"); - return ret; - } - }) - -}); diff --git a/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-mode-lisp.js.svn-base b/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-mode-lisp.js.svn-base deleted file mode 100644 index dede250..0000000 --- a/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-mode-lisp.js.svn-base +++ /dev/null @@ -1,419 +0,0 @@ -//> This file is part of Ymacs, an Emacs-like editor for the Web -//> http://www.ymacs.org/ -//> -//> Copyright (c) 2009-2010, Mihai Bazon, Dynarch.com. All rights reserved. -//> -//> Redistribution and use in source and binary forms, with or without -//> modification, are permitted provided that the following conditions are -//> met: -//> -//> * Redistributions of source code must retain the above copyright -//> notice, this list of conditions and the following disclaimer. -//> -//> * Redistributions in binary form must reproduce the above copyright -//> notice, this list of conditions and the following disclaimer in -//> the documentation and/or other materials provided with the -//> distribution. -//> -//> * Neither the name of Dynarch.com nor the names of its contributors -//> may be used to endorse or promote products derived from this -//> software without specific prior written permission. -//> -//> THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY -//> EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -//> IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -//> PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE -//> FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -//> CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -//> SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -//> INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -//> CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -//> ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF -//> THE POSSIBILITY OF SUCH DAMAGE. - -// @require ymacs-tokenizer.js - -(function(){ - - Ymacs_Buffer.newCommands({ - - lisp_open_paren: Ymacs_Interactive(function(what) { - if (what == null) - what = "("; - what += isOpenParen(what); - this.cmd("insert", what); - this.cmd("backward_char"); - }), - - lisp_close_paren: Ymacs_Interactive(function(what) { - var re = new RegExp("\\s*\\" + what, "ig"); - if (this.cmd("looking_at", re)) - this._deleteText(this.point(), this.matchData.after); - this.cmd("insert", what); - }), - - lisp_close_all_parens: Ymacs_Interactive(function() { - var p = this.tokenizer.getParserForLine(this._rowcol.row); - if (p) { - // this kind of sucks, we need to rewind the stream to that location.. - var s = this.tokenizer.stream; - s.line = this._rowcol.row; - s.col = 0; - try { - while (s.col < this._rowcol.col) - p.next(); - } catch(ex) {} - p = p.copy().context.parens; // these are still-to-close - p.r_foreach(function(p){ - this.cmd("lisp_close_paren", isOpenParen(p.type)); - }, this); - } - }) - - }); - - // XXX: much of the parser is actually copied from ymacs-mode-js.js. I should somehow unify - // the duplicate code. - - var SPECIAL_FORMS = "\ -deftype defstruct defclass \ -defmacro defun defmethod defgeneric defpackage in-package defreadtable in-readtable \ -when cond unless etypecase typecase ctypecase \ -lambda let load-time-value quote macrolet \ -progn prog1 prog2 progv go flet the \ -if throw eval-when multiple-value-prog1 unwind-protect let* \ -ignore-errors handler-case case \ -labels function symbol-macrolet block tagbody catch locally \ -return return-from setq multiple-value-call".qw().toHash(); - - var COMMON_MACROS = "loop do while".qw().toHash(); - - var CONSTANTS = "t nil".qw().toHash(); - - var OPEN_PAREN = { - "(" : ")", - "{" : "}", - "[" : "]" - }; - - var CLOSE_PAREN = { - ")" : "(", - "}" : "{", - "]" : "[" - }; - - var DEFINES_FUNCTION = "defun defgeneric defmethod".qw().toHash(); - - var DEFINES_TYPE = "deftype defclass defstruct".qw().toHash(); - - var FORM_ARGS = { - "if" : "3+", - "when" : "1*", - "lambda" : "1*", - "unless" : "1*", - "defun" : "2*", - "defgeneric" : "2*", - "defmethod" : "2*", - "defclass" : "2*", - "defmacro" : "2*", - "progn" : "0*", - "prog1" : "0*", - "prog2" : "0*", - "let" : "1*" - }; - - function isOpenParen(ch) { - return OPEN_PAREN[ch]; - }; - - function isCloseParen(ch) { - return CLOSE_PAREN[ch]; - }; - - function isConstituent(ch) { - return ch.toLowerCase() != ch.toUpperCase() || - /^[-0-9!#$%&*+./:<=>?@\[\]\^_\{\}~]$/i.test(ch); - }; - - function isConstituentStart(ch) { - return ch != "#" && isConstituent(ch); - }; - - // the tokenizer function - Ymacs_Tokenizer.define("lisp", function(stream, tok){ - - var $cont = [], - $inString = false, - $inComment = false, - $quote = null, - $parens = [], - $passedParens = [], - $backList = [], - $list = [], - PARSER = { next: next, copy: copy, indentation: indentation }; - - function copy() { - var context = restore.context = { - cont : $cont.slice(0), - quote : $quote, - inString : $inString, - inComment : $inComment, - parens : $parens.slice(0), - passedParens : $passedParens.slice(0), - backList : $backList.slice(0), - list : $list.slice(0) - }; - function restore() { - $cont = context.cont.slice(0); - $inString = context.inString; - $quote = context.quote; - $inComment = context.inComment; - $parens = context.parens.slice(0); - $passedParens = context.passedParens.slice(0); - $backList = context.backList.slice(0), - $list = context.list.slice(0); - return PARSER; - }; - return restore; - }; - - function foundToken(c1, c2, type) { - tok.onToken(stream.line, c1, c2, type); - }; - - function newArg(what) { - if (what == null) - what = { c1: stream.col }; - $list.push(what); - }; - - function INDENT_LEVEL() { return stream.buffer.getq("indent_level"); }; - - function readName() { - var col = stream.col, ch = stream.get(), - name = ch; - while (!stream.eol()) { - ch = stream.peek(); - if (!isConstituent(ch)) - break; - name += ch; - stream.nextCol(); - } - return ch && { line: stream.line, c1: col, c2: stream.col, id: name.toLowerCase() }; - }; - - function readString(end, type) { - var ch, esc = false, start = stream.col; - while (!stream.eol()) { - ch = stream.peek(); - if (ch === end && !esc) { - $cont.pop(); - $inString = null; - foundToken(start, stream.col, type); - foundToken(stream.col, ++stream.col, type + "-stopper"); - return true; - } - esc = !esc && ch === "\\"; - stream.nextCol(); - } - foundToken(start, stream.col, type); - }; - - function readComment() { - var line = stream.lineText(), pos = line.indexOf("|#", stream.col); - var m = /^\s*\|+/.exec(line.substr(stream.col)); - if (m) { - foundToken(stream.col, stream.col += m[0].length, "mcomment-starter"); - } - if (pos >= 0) { - $cont.pop(); - $inComment = null; - foundToken(stream.col, pos, "mcomment"); - foundToken(pos, pos += 2, "mcomment-stopper"); - stream.col = pos; - } else { - foundToken(stream.col, line.length, "mcomment"); - stream.col = line.length; - } - }; - - function isForm(form) { - var f = $list && $list.length > 0 && $list[0].id; - if (f) { - f = f.toLowerCase(); - if (form == null) - return f; - return typeof form == "string" ? f == form : f in form; - } - }; - - function next() { - stream.checkStop(); - if ($cont.length > 0) - return $cont.peek()(); - var ch = stream.peek(), tmp; - if ((tmp = stream.lookingAt(/^#\\(Space|Newline|.?)/i))) { - newArg(); - foundToken(stream.col, stream.col += tmp[0].length, "constant"); - } - else if (stream.lookingAt(/^#\x27[^(]/)) { - newArg(); - stream.col += 2; - tmp = readName(); - foundToken(tmp.c1, tmp.c2, "function-name"); - } - else if (stream.lookingAt("#|")) { - $inComment = { line: stream.line, c1: stream.col }; - foundToken(stream.col, stream.col += 2, "mcomment-starter"); - $cont.push(readComment); - } - else if ((tmp = stream.lookingAt(/^;+/))) { - foundToken(stream.col, stream.col += tmp[0].length, "comment-starter"); - foundToken(stream.col, stream.col = stream.lineLength(), "comment"); - } - else if (ch === '"') { - newArg(); - $inString = { line: stream.line, c1: stream.col }; - foundToken(stream.col, ++stream.col, "string-starter"); - $cont.push(readString.$C(ch, "string")); - } - else if ((tmp = stream.lookingAt(/^[+-]?(#x[0-9a-f]+|#o[0-7]+|#b[01]+|[0-9]*\.?[0-9]+e?[0-9]*)(\x2f(#x[0-9a-f]+|#o[0-7]+|#b[01]+|[0-9]*\.?[0-9]+e?[0-9]*))?/))) { // Dude, WTF... - newArg(); - foundToken(stream.col, stream.col += tmp[0].length, "number"); - } - else if ((tmp = isOpenParen(ch))) { - newArg(); - $backList.push($list); - $list = []; - $parens.push({ line: stream.line, col: stream.col, type: ch }); - foundToken(stream.col, ++stream.col, "open-paren"); - } - else if ((tmp = isCloseParen(ch))) { - var p = $parens.pop(); - if (!p || p.type != tmp) { - foundToken(stream.col, ++stream.col, "error"); - } else { - p.closed = { line: stream.line, col: stream.col, opened: p }; - $passedParens.push(p); - $list = $backList.pop(); - foundToken(stream.col, ++stream.col, "close-paren"); - } - } - else if (isConstituentStart(ch) && (tmp = readName())) { - var type = ch == ":" ? "lisp-keyword" - : tmp.id in SPECIAL_FORMS ? "keyword" - : tmp.id in COMMON_MACROS ? "builtin" - : tmp.id in CONSTANTS ? "constant" - : null; - if (!type) { - // perhaps function name? - if (isForm(DEFINES_FUNCTION) && $list.length == 1) { - type = "function-name"; - } - else if (isForm(DEFINES_TYPE) && $list.length == 1) { - type = "type"; - } - // there are a lot of macros starting with "with-", so let's highlight this - else if (/^with-/i.test(tmp.id)) { - type = "builtin"; - } - } - newArg(tmp); - foundToken(tmp.c1, tmp.c2, type); - } - else { - foundToken(stream.col, ++stream.col, null); - } - }; - - function indentation() { - // no indentation for continued strings - if ($inString) - return 0; - - var currentLine = stream.lineText(); - var indent = 0; - - var p = $parens.peek(); - if (p) { - var line = stream.lineText(p.line); - indent = p.col + 1; - var nextNonSpace; - if (isConstituentStart(line.charAt(indent))) { - indent = p.col + INDENT_LEVEL(); - var re = /\s\S/g; - re.lastIndex = p.col; - nextNonSpace = re.exec(line); - if (nextNonSpace) { - nextNonSpace = nextNonSpace.index + 1; - } - } - if ($list && $list.length) { - // console.log($list); - var currentForm = isForm(); - if (currentForm) { - currentForm = currentForm.replace(/\*$/, ""); - var formArgs = FORM_ARGS[currentForm]; - if (!formArgs && /^with/.test(currentForm)) { - // "with" macros usually take one argument, then &body - formArgs = "1*"; - } - if (!formArgs) { - formArgs = "1+"; // kind of sucky now - } - if (formArgs) { - var n = parseInt(formArgs, 10); - var hasRest = /\+$/.test(formArgs); - var hasBody =/\*$/.test(formArgs); - // console.log("Expecting %d arguments, got %d already (rest=%o, body=%o)", n, $list.length - 1, hasRest, hasBody); - if ($list.length - 1 < n || hasRest) { - // still in the arguments - if (nextNonSpace) - indent = nextNonSpace; - else - indent += INDENT_LEVEL(); - } - } - } - } - } - - return indent; - }; - - return PARSER; - }); - -})(); - -DEFINE_SINGLETON("Ymacs_Keymap_LispMode", Ymacs_Keymap, function(D, P){ - - D.KEYS = { - "ENTER" : "newline_and_indent", - "(" : [ "lisp_open_paren", "(" ], - ")" : [ "lisp_close_paren", ")" ], - "C-c ] && C-c C-]" : "lisp_close_all_parens" - }; - -}); - -Ymacs_Buffer.newMode("lisp_mode", function() { - - var tok = this.tokenizer; - this.setTokenizer(new Ymacs_Tokenizer({ buffer: this, type: "lisp" })); - var changed_vars = this.setq({ - indent_level: 2 - }); - var keymap = Ymacs_Keymap_LispMode(); - this.pushKeymap(keymap); - var was_paren_match = this.cmd("paren_match_mode", true); - - return function() { - this.setTokenizer(tok); - this.setq(changed_vars); - this.popKeymap(keymap); - if (!was_paren_match) - this.cmd("paren_match_mode", false); - }; - -}); diff --git a/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-mode-markdown.js.svn-base b/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-mode-markdown.js.svn-base deleted file mode 100644 index 42a92b9..0000000 --- a/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-mode-markdown.js.svn-base +++ /dev/null @@ -1,89 +0,0 @@ -//> This file is part of Ymacs, an Emacs-like editor for the Web -//> http://www.ymacs.org/ -//> -//> Copyright (c) 2009-2010, Mihai Bazon, Dynarch.com. All rights reserved. -//> -//> Redistribution and use in source and binary forms, with or without -//> modification, are permitted provided that the following conditions are -//> met: -//> -//> * Redistributions of source code must retain the above copyright -//> notice, this list of conditions and the following disclaimer. -//> -//> * Redistributions in binary form must reproduce the above copyright -//> notice, this list of conditions and the following disclaimer in -//> the documentation and/or other materials provided with the -//> distribution. -//> -//> * Neither the name of Dynarch.com nor the names of its contributors -//> may be used to endorse or promote products derived from this -//> software without specific prior written permission. -//> -//> THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY -//> EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -//> IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -//> PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE -//> FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -//> CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -//> SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -//> INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -//> CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -//> ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF -//> THE POSSIBILITY OF SUCH DAMAGE. - -// @require ymacs-tokenizer.js - -Ymacs_Tokenizer.define("markdown", function(stream, tok) { - - var PARSER = { next: next, copy: copy }; - - function copy() { - var context = restore.context = { - }; - function restore() { - return PARSER; - }; - return restore; - }; - - function foundToken(c1, c2, type) { - tok.onToken(stream.line, c1, c2, type); - }; - - function next() { - stream.checkStop(); - var tmp; - if (stream.col == 0 && (tmp = stream.lookingAt(/^(#+)/))) { - foundToken(0, stream.col = stream.lineLength(), "markdown-heading" + tmp[0].length); - } - else if (stream.line > 0 && stream.col == 0 && (tmp = stream.lookingAt(/^[=-]+$/)) && /\S/.test(stream.lineText(stream.line - 1))) { - tmp = tmp[0].charAt(0) == "=" ? 1 : 2; - tmp = "markdown-heading" + tmp; - tok.onToken(stream.line - 1, 0, stream.lineLength(stream.line - 1), tmp); - foundToken(0, stream.col = stream.lineLength(), tmp); - } - else if (stream.col == 0 && (tmp = stream.lookingAt(/^[>\s]*/))) { - tmp = tmp[0].replace(/\s+/g, "").length; - if (tmp > 3) - tmp = ""; - tmp = "markdown-blockquote" + tmp; - foundToken(0, stream.col = stream.lineLength(), tmp); - } - else { - foundToken(stream.col, ++stream.col, null); - } - }; - - return PARSER; - -}); - -Ymacs_Buffer.newMode("markdown_mode", function() { - - var tok = this.tokenizer; - this.setTokenizer(new Ymacs_Tokenizer({ buffer: this, type: "markdown" })); - return function() { - this.setTokenizer(tok); - }; - -}); diff --git a/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-mode-paren-match.js.svn-base b/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-mode-paren-match.js.svn-base deleted file mode 100644 index cdeeb8f..0000000 --- a/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-mode-paren-match.js.svn-base +++ /dev/null @@ -1,301 +0,0 @@ -//> This file is part of Ymacs, an Emacs-like editor for the Web -//> http://www.ymacs.org/ -//> -//> Copyright (c) 2009-2010, Mihai Bazon, Dynarch.com. All rights reserved. -//> -//> Redistribution and use in source and binary forms, with or without -//> modification, are permitted provided that the following conditions are -//> met: -//> -//> * Redistributions of source code must retain the above copyright -//> notice, this list of conditions and the following disclaimer. -//> -//> * Redistributions in binary form must reproduce the above copyright -//> notice, this list of conditions and the following disclaimer in -//> the documentation and/or other materials provided with the -//> distribution. -//> -//> * Neither the name of Dynarch.com nor the names of its contributors -//> may be used to endorse or promote products derived from this -//> software without specific prior written permission. -//> -//> THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY -//> EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -//> IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -//> PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE -//> FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -//> CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -//> SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -//> INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -//> CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -//> ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF -//> THE POSSIBILITY OF SUCH DAMAGE. - -// @require ymacs-buffer.js -// @require ymacs-tokenizer.js - -DEFINE_SINGLETON("Ymacs_Keymap_ParenMatch", Ymacs_Keymap, function(D, P) { - - D.KEYS = { - "C-c \\" : "goto_matching_paren", - "C-M-q" : "indent_sexp", - "C-M-f && C-M-n" : "forward_sexp", - "C-M-b && C-M-p" : "backward_sexp", - "C-M-u && M-a" : "backward_up_list", - "M-e && C-M-ARROW_UP" : "up_list", - "C-M-ARROW_DOWN" : "down_list", - "M-C-k" : "kill_sexp", - "M-C-SPACE" : "mark_sexp", - "M-C-t" : "transpose_sexps", - "M-(" : [ "paredit_wrap_round", "(" ], - "M-[" : [ "paredit_wrap_round", "[" ], - "M-{" : [ "paredit_wrap_round", "{" ], - 'M-"' : [ "paredit_wrap_round", '"', true ], - "M-'" : [ "paredit_wrap_round", "'", true ] - }; - - /* -----[ new commands ]----- */ - - function compareRowCol(p1, p2) { - return (p1.line < p2.line) - ? -1 - : p1.line > p2.line - ? 1 - : p1.col - p2.col; - }; - - var PARENS = { - "(" : ")", - "[" : "]", - "{" : "}", - '"' : { close: '"', backslash: /[\x22\\]/g }, - "'" : { close: "'", backslash: /[\x27\\]/g } - }; - - function ERROR(o) { - throw new Ymacs_Exception("Balanced expression not found"); - }; - - function getPP(p) { - var pp = p.context.passedParens; - return pp instanceof Function ? pp() : pp; - }; - - Ymacs_Buffer.newCommands({ - - matching_paren: function() { - var p = this.tokenizer.getLastParser(), rc = this._rowcol; - if (p) { - var parens = getPP(p); - return parens.foreach(function(p){ - var match = p.closed; - if (p.line == rc.row && p.col == rc.col) { - $RETURN( this._rowColToPosition(match.line, match.col + 1) ); - } else if (match.line == rc.row && match.col == rc.col - 1) { - $RETURN( this._rowColToPosition(p.line, p.col) ); - } - }, this); - } - }, - - indent_sexp: Ymacs_Interactive(function() { - var pos = this.cmd("matching_paren"); - if (pos != null) { - this.cmd("indent_region", this.point(), pos); - } else { - ERROR(this); - } - }), - - goto_matching_paren: Ymacs_Interactive(function() { - var pos = this.cmd("matching_paren"); - if (pos != null) { - this.cmd("goto_char", pos); - return true; - } - }), - - forward_sexp: Ymacs_Interactive(function() { - var rc = this._rowcol, p = this.tokenizer.finishParsing(); - if (p) { - // find next paren - var parens = getPP(p).mergeSort(compareRowCol); - var next = parens.foreach(function(p){ - if (p.line > rc.row || (p.line == rc.row && p.col >= rc.col)) { - $RETURN(p); - } - }); - if (!next || !next.closed) { - ERROR(this); - return; - } - var start = this._rowColToPosition(next.line, next.col); - if ((this._rowcol.row == next.line && this._rowcol.col == next.col) - || !/\S/.test(this._bufferSubstring(null, start))) - this.cmd("goto_char", this._rowColToPosition(next.closed.line, next.closed.col) + 1); - else - this.cmd("goto_char", start); - return true; - } - }), - - backward_sexp: Ymacs_Interactive(function() { - var rc = this._rowcol, p = this.tokenizer.finishParsing(); - if (p) { - // find next paren - var parens = getPP(p).grep("closed").map("closed").mergeSort(compareRowCol); - var prev = parens.r_foreach(function(p){ - if (p.line < rc.row || (p.line == rc.row && p.col < rc.col)) - $RETURN(p); - }); - if (!prev) { - ERROR(this); - return; - } - this.cmd("goto_char", this._rowColToPosition(prev.opened.line, prev.opened.col)); - return true; - } - }), - - mark_sexp: Ymacs_Interactive("^r", function(begin, end){ - this.cmd("save_excursion", function(){ - if (this.transientMarker) - this.cmd("goto_char", end); - this.ensureTransientMark(); - this.cmd("forward_sexp"); - this.cmd("set_mark_command", this.point()); - this.transientMarker.swap(this.caretMarker); - }); - this.ensureTransientMark(); - }), - - kill_sexp: Ymacs_Interactive(function() { - this._killingAction( - this.point(), - this.cmd("save_excursion", function() { - this.cmd("forward_sexp"); - return this.point(); - }) - ); - }), - - transpose_sexps: Ymacs_Interactive(function() { - var a = []; - this.cmd("forward_sexp"); a.push(this.point()); - this.cmd("backward_sexp"); a.push(this.point()); - this.cmd("backward_sexp"); a.push(this.point()); - this.cmd("forward_sexp"); a.push(this.point()); - this.cmd("goto_char", this._swapAreas(a)); - }), - - paredit_wrap_round: Ymacs_Interactive("^", function(paren, nosexp){ - if (!paren) - paren = "("; - var closing = PARENS[paren], - r = this.transientMarker - ? this.getRegion() - : this.cmd("save_excursion", function(){ - var begin = this.point(); - if (!nosexp) - this.cmd("forward_sexp"); - return { begin: begin, end: this.point() }; - }), - txt = this._bufferSubstring(r.begin, r.end), - before = this.point() < r.end; - if (typeof closing != "string") { - txt = txt.replace(closing.backslash, function(s){ - return "\\" + s; - }); - closing = closing.close; - } - var m = this.createMarker(r.end); - this.cmd("save_excursion", function(){ - this._replaceText(r.begin, r.end, paren + txt + closing); - }, before); - this.cmd("forward_char", before ? 1 : -1); - this.clearTransientMark(); - this.cmd("indent_region", r.begin, m.getPosition()); - m.destroy(); - }), - - down_list: Ymacs_Interactive(function(){ - var rc = this._rowcol, p = this.tokenizer.finishParsing(); - if (p) { - var lc = { line: rc.row, col: rc.col }; - p = getPP(p).grep("closed").mergeSort(compareRowCol).grep_first(function(p){ - return compareRowCol(p, lc) >= 0; - }); - if (p != null) { - this.cmd("goto_char", this._rowColToPosition(p.line, p.col) + 1); - } else { - ERROR(this); - } - } - }), - - backward_up_list: Ymacs_Interactive(function(){ - var rc = this._rowcol, p = this.tokenizer.finishParsing(); - if (p) { - var lc = { line: rc.row, col: rc.col }; - p = getPP(p).grep("closed").mergeSort(compareRowCol).grep_last(function(p){ - return compareRowCol(p, lc) < 0 && compareRowCol(p.closed, lc) >= 0; - }); - if (p != null) { - this.cmd("goto_char", this._rowColToPosition(p.line, p.col)); - } else { - ERROR(this); - } - } - }), - - up_list: Ymacs_Interactive(function(){ - this.cmd("backward_up_list"); - this.cmd("forward_sexp"); - }) - - }); - - Ymacs_Buffer.newMode("paren_match_mode", function(){ - - var keymap = Ymacs_Keymap_ParenMatch(); - this.pushKeymap(keymap); - - var active = false, - clearOvl = function() { - if (active) - this.deleteOverlay("match-paren"); - }.clearingTimeout(500, this); - - var events = { - beforeInteractiveCommand: function() { - clearOvl.doItNow(); - }, - afterInteractiveCommand: function() { - var p = this.tokenizer.getLastParser(), rc = this._rowcol; - if (p) { - getPP(p).foreach(function(p){ - var match = p.closed; - if ((p.line == rc.row && p.col == rc.col) || - (match.line == rc.row && match.col == rc.col - 1)) { - active = true; - this.setOverlay("match-paren", { - line1: p.line, line2: match.line, - col1: p.col, col2: match.col + 1 - }); - clearOvl(); - } - }, this); - } - }.clearingTimeout(100) - }; - this.addEventListener(events); - - return function() { - clearOvl.doItNow(); - this.popKeymap(keymap); - this.removeEventListener(events); - }; - - }); - -}); diff --git a/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-mode-xml.js.svn-base b/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-mode-xml.js.svn-base deleted file mode 100644 index 0e0ed47..0000000 --- a/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-mode-xml.js.svn-base +++ /dev/null @@ -1,474 +0,0 @@ -//> This file is part of Ymacs, an Emacs-like editor for the Web -//> http://www.ymacs.org/ -//> -//> Copyright (c) 2009-2010, Mihai Bazon, Dynarch.com. All rights reserved. -//> -//> Redistribution and use in source and binary forms, with or without -//> modification, are permitted provided that the following conditions are -//> met: -//> -//> * Redistributions of source code must retain the above copyright -//> notice, this list of conditions and the following disclaimer. -//> -//> * Redistributions in binary form must reproduce the above copyright -//> notice, this list of conditions and the following disclaimer in -//> the documentation and/or other materials provided with the -//> distribution. -//> -//> * Neither the name of Dynarch.com nor the names of its contributors -//> may be used to endorse or promote products derived from this -//> software without specific prior written permission. -//> -//> THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY -//> EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -//> IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -//> PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE -//> FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -//> CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -//> SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -//> INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -//> CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -//> ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF -//> THE POSSIBILITY OF SUCH DAMAGE. - -// @require ymacs-tokenizer.js - -Ymacs_Tokenizer.define("xml", function(stream, tok) { - - var $tags = [], - $cont = [], - $inTag = null, - $inComment = null, - PARSER = { next: next, copy: copy, indentation: indentation }; - - function copy() { - var _tags = $tags.slice(0), - _cont = $cont.slice(0), - _inTag = $inTag, - _inComment = $inComment; - function resume() { - $cont = _cont.slice(0); - $tags = _tags.slice(0); - $inTag = _inTag; - $inComment = _inComment; - return PARSER; - }; - return resume; - }; - - function INDENT_LEVEL() { - return stream.buffer.getq("indent_level"); - }; - - function foundToken(c1, c2, type) { - tok.onToken(stream.line, c1, c2, type); - }; - - function isLetter(ch) { - return ch.toLowerCase() != ch.toUpperCase(); - }; - - function isNameStart(ch) { - return ch && (isLetter(ch) || /^[:_-]$/.test(ch)); - }; - - function isNameChar(ch) { - return ch && (isLetter(ch) || /^[0-9_-]$/.test(ch)); - }; - - function readName() { - var col = stream.col, ch = stream.get(), - name = ch; - while (!stream.eol()) { - ch = stream.peek(); - if (!isNameChar(ch)) - break; - name += ch; - stream.nextCol(); - } - return ch && { line: stream.line, c1: col, c2: stream.col, id: name }; - }; - - function readString(end) { - var ch, esc = false, start = stream.col; - while (!stream.eol()) { - ch = stream.peek(); - if (ch === end && !esc) { - $cont.pop(); - foundToken(start, stream.col, "string"); - foundToken(stream.col, ++stream.col, "string-stopper"); - return; - } - esc = !esc && ch === "\\"; - stream.nextCol(); - } - foundToken(start, stream.col, "string"); - }; - - function readTag() { - var ch = stream.peek(), name; - if (stream.lookingAt(/^\x2f>/)) { - $cont.pop(); - $inTag = null; - foundToken(stream.col, ++stream.col, "xml-closetag-slash"); - foundToken(stream.col, ++stream.col, "xml-close-bracket"); - } - else if (ch === ">") { - $cont.pop(); - $tags.push($inTag); - $inTag = null; - foundToken(stream.col, ++stream.col, "xml-close-bracket"); - } - else if (isNameStart(ch) && (name = readName())) { - foundToken(name.c1, name.c2, "xml-attribute"); - } - else if (ch === '"' || ch === "'") { - foundToken(stream.col, ++stream.col, "string-starter"); - $cont.push(readString.$C(ch)); - } - else foundToken(stream.col, ++stream.col, null); - }; - - function readComment(type, end) { - var line = stream.lineText(), pos = line.indexOf(end, stream.col); - if (pos >= 0) { - $cont.pop(); - foundToken(stream.col, pos, type); - $inComment = null; - foundToken(pos, pos += end.length, type + "-stopper"); - stream.col = pos; - } else { - foundToken(stream.col, line.length, type); - stream.col = line.length; - } - }; - - function readCloseBracket() { - var m = stream.lookingAt(/^([\s\xA0]*)(>?)/); - if (m && m[0]) { - if (m[1]) - foundToken(stream.col, stream.col += m[1].length, null); - if (m[2]) { - foundToken(stream.col, stream.col += m[2].length, "xml-close-bracket"); - $cont.pop(); - } - } else { - foundToken(stream.col, ++stream.col, "error"); - } - }; - - function next() { - stream.checkStop(); - if ($cont.length > 0) - return $cont.peek()(); - var ch = stream.peek(), m; - if (stream.lookingAt("<![CDATA[")) { - foundToken(stream.col, stream.col += 9, "xml-cdata-starter"); - $inComment = { line: stream.line, c1: stream.col }; - $cont.push(readComment.$C("xml-cdata", "]]>")); - } - else if (stream.lookingAt("<!--")) { - foundToken(stream.col, stream.col += 4, "mcomment-starter"); - $inComment = { line: stream.line, c1: stream.col }; - $cont.push(readComment.$C("mcomment", "-->")); - } - else if (stream.lookingAt(/^<\x2f/) && isNameStart(stream.peek(+2))) { - foundToken(stream.col, ++stream.col, "xml-open-bracket"); - foundToken(stream.col, ++stream.col, "xml-closetag-slash"); - var tag = readName(), prev = $tags.pop(); - foundToken(tag.c1, tag.c2, ( prev && prev.id == tag.id - ? "xml-close-tag" - : "error" )); - $cont.push(readCloseBracket); - } - else if (ch === "<" && isNameStart(stream.peek(+1))) { - foundToken(stream.col, ++stream.col, "xml-open-bracket"); - var tag = readName(); - foundToken(tag.c1, tag.c2, "xml-open-tag"); - $inTag = tag; - $cont.push(readTag); - } - else if ((m = stream.lookingAt(/^&.*?;/))) { - foundToken(stream.col, ++stream.col, "xml-entity-starter"); - foundToken(stream.col, stream.col += m[0].length - 2, "xml-entity"); - foundToken(stream.col, ++stream.col, "xml-entity-stopper"); - } - else if (ch === "&") { - foundToken(stream.col, ++stream.col, "error"); - } - else { - foundToken(stream.col, ++stream.col, null); - } - }; - - function indentation() { - var indent, lastTag; - if ($inComment) { - indent = stream.lineIndentation($inComment.line) + INDENT_LEVEL(); - } - else if ($inTag) { - indent = $inTag.c1 + $inTag.id.length + 1; - } - else if ((lastTag = $tags.peek())) { - indent = stream.lineIndentation(lastTag.line) + INDENT_LEVEL(); - // if current line begins with a closing tag, back one level - if (/^\s*<\x2f/.test(stream.lineText())) - indent -= INDENT_LEVEL(); - } - return indent; - }; - - return PARSER; - -}); - -DEFINE_SINGLETON("Ymacs_Keymap_XML", Ymacs_Keymap, function(D, P){ - - D.KEYS = { - "C-c /" : "xml_close_tag", - "C-ENTER" : "xml_zen_expand", - "ENTER" : "newline_and_indent" - }; - -}); - -Ymacs_Buffer.newMode("xml_mode", function(){ - - var tok = this.tokenizer; - this.setTokenizer(new Ymacs_Tokenizer({ buffer: this, type: "xml" })); - var keymap = Ymacs_Keymap_XML(); - this.pushKeymap(keymap); - var changed_vars = this.setq({ indent_level: 2 }); - return function() { - this.setTokenizer(tok); - this.popKeymap(keymap); - this.setq(changed_vars); - }; - -}); - -(function(){ - - DEFINE_SINGLETON("Ymacs_Keymap_XML_Zen", Ymacs_Keymap, function(D, P){ - D.KEYS = { - "TAB" : "xml_zen_next_poi", - "S-TAB" : "xml_zen_prev_poi", - "C-g" : "xml_zen_stop" - }; - }); - - var MODE_TYPE = 1, MODE_CLASS = 2, MODE_ID = 3, MODE_REPEAT = 4, MODE_ATTR = 5; - - function zen_render(el, html) { - var n = el.repeat || 1; - for (var i = 1; i <= n; ++i) { - if (i > 1) - html("\n"); - html("<", el.type); - if (el.id) { - html(' id="', el.id.replace(/\$/g, i), '"'); - } - if (el.klass) { - html(' class="', el.klass.replace(/\$/g, i), '"'); - } - if (el.attributes) { - el.attributes.foreach(function(attr){ - html(" ", attr, '="|"'); - }); - } - html(">"); - if (el.child) { - html("\n"); - zen_render(el.child, html); - html("\n"); - } else { - html("|"); - } - html("</", el.type, ">"); - if (el.next) { - html("\n"); - zen_render(el.next, html); - } - } - }; - - function zen_parse(str, i) { - var el = { type: "" }, mode = MODE_TYPE; - OUTER: while (i < str.length) { - var ch = str.charAt(i++); - switch (ch) { - - case "#": - mode = MODE_ID; - el.id = ""; - break; - - case ".": - mode = MODE_CLASS; - if (el.klass != null) { - el.klass += " "; - } else { - el.klass = ""; - } - break; - - case ":": - mode = MODE_ATTR; - if (el.attributes == null) - el.attributes = []; - el.attributes.push(""); - break; - - case "*": - mode = MODE_REPEAT; - el.repeat = ""; - break; - - case ">": - el.child = zen_parse(str, i); - i = el.child.i; - break OUTER; - - case "(": - el.child = zen_parse(str, i); - i = el.child.i; - break; - - case ")": - break OUTER; - - case "+": - el.next = zen_parse(str, i); - i = el.next.i; - break OUTER; - - default: - switch (mode) { - case MODE_TYPE: - el.type += ch; - break; - case MODE_CLASS: - el.klass += ch; - break; - case MODE_ID: - el.id += ch; - break; - case MODE_REPEAT: - el.repeat = parseInt(String(el.repeat) + ch, 10); - break; - case MODE_ATTR: - el.attributes.push(el.attributes.pop() + ch); - break; - } - } - } - - el.i = i; - return el; - }; - - function maybe_stop_zen() { - var point = this.point(), - a = this.getq("xml_zen_markers"), - start = a[0], - end = a.peek(); - if (point < start.getPosition() || point > end.getPosition() || - end.getPosition() == a.peek(1).getPosition()) { - this.cmd("xml_zen_stop"); - } - }; - - Ymacs_Buffer.newCommands({ - - xml_close_tag: Ymacs_Interactive(function() { - this.cmd("close_last_xml_tag"); - this.cmd("indent_line"); - }), - - xml_zen_expand: Ymacs_Interactive(function() { - this.cmd("xml_zen_stop"); - var html = String.buffer(), - start = this.cmd("save_excursion", function() { - this.cmd("backward_whitespace"); - while (!this.cmd("looking_back", /[\x20\xa0\s\t\n;&]/)) - if (!this.cmd("backward_char")) - break; - return this.point(); - }), - point = this.point(); - - try { - zen_render( - zen_parse( - this.cmd("buffer_substring", start, point).trim(), 0 - ), - html - ); - } catch(ex) { - throw new Ymacs_Exception("The Zen is not strong today :-/"); - } - - html = html.get(); - this.cmd("delete_region", start, point); - this.cmd("insert", html); - start = this.createMarker(start, false, "xml_zen"); - - // locate points of interest - var end = this.createMarker(this.point(), true, "xml_zen"), markers = []; - this.cmd("goto_char", start.getPosition()); - while (this.cmd("search_forward", "|", end.getPosition())) { - this.cmd("backward_delete_char"); - markers.push(this.createMarker(this.point(), true, "xml_zen_start")); - markers.push(this.createMarker(this.point(), false, "xml_zen_end")); - } - - this.cmd("indent_region", start.getPosition(), end.getPosition()); - - var count = markers.length; - if (count > 0) { - // move to first POI - this.cmd("goto_char", markers[0]); - markers.unshift(start); - markers.push(end); - this.setq("xml_zen_markers", markers); - this.pushKeymap(Ymacs_Keymap_XML_Zen()); - this.addEventListener("afterInteractiveCommand", maybe_stop_zen); - } else { - start.destroy(); - end.destroy(); - } - }), - - xml_zen_stop: Ymacs_Interactive(function(){ - var tmp = this.getq("xml_zen_markers"); - if (tmp) { - tmp.map("destroy"); - this.setq("xml_zen_markers", null); - } - this.popKeymap(Ymacs_Keymap_XML_Zen()); - this.removeEventListener("afterInteractiveCommand", maybe_stop_zen); - }), - - xml_zen_next_poi: Ymacs_Interactive(function(){ - var markers = this.getq("xml_zen_markers"), pos = this.point(); - markers.foreach(function(m){ - if (m.getPosition() > pos) { - this.cmd("goto_char", m.getPosition()); - $BREAK(); - } - }, this); - }), - - xml_zen_prev_poi: Ymacs_Interactive(function(){ - var markers = this.getq("xml_zen_markers"), pos = this.point(); - markers.r_foreach(function(m){ - if (m.getPosition() < pos) { - this.cmd("goto_char", m.getPosition()); - $BREAK(); - } - }, this); - }) - - }); - -})(); diff --git a/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-regexp.js.svn-base b/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-regexp.js.svn-base deleted file mode 100644 index cf793af..0000000 --- a/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-regexp.js.svn-base +++ /dev/null @@ -1,96 +0,0 @@ -//> This file is part of Ymacs, an Emacs-like editor for the Web -//> http://www.ymacs.org/ -//> -//> Copyright (c) 2009-2010, Mihai Bazon, Dynarch.com. All rights reserved. -//> -//> Redistribution and use in source and binary forms, with or without -//> modification, are permitted provided that the following conditions are -//> met: -//> -//> * Redistributions of source code must retain the above copyright -//> notice, this list of conditions and the following disclaimer. -//> -//> * Redistributions in binary form must reproduce the above copyright -//> notice, this list of conditions and the following disclaimer in -//> the documentation and/or other materials provided with the -//> distribution. -//> -//> * Neither the name of Dynarch.com nor the names of its contributors -//> may be used to endorse or promote products derived from this -//> software without specific prior written permission. -//> -//> THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY -//> EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -//> IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -//> PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE -//> FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -//> CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -//> SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -//> INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -//> CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -//> ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF -//> THE POSSIBILITY OF SUCH DAMAGE. - -// @require ymacs.js - -window.Ymacs_Regexp = (function(){ - - var SEARCH_BACKWARD = {}; - - // var LOOKING_BACK = {}; - - function getPatternAndFlags(rx) { - if (rx instanceof RegExp) - rx = rx.toString(); - var pos = rx.lastIndexOf("/"), flags = ""; - flags = rx.substr(pos + 1); - rx = rx.substring(1, pos); - return { pattern: rx, flags: flags }; - }; - - return { - - // Prepends to the regexp a token that will greedily eat any characters in - // front of the pattern. This is useful to get the last occurrence of the - // pattern in a string. The returned regexp is cached, so it's not - // reconstructed a second time. - // - // A function using such regexp must be aware that m.index will always be zero, - // because it matches from the beginning of the string. To find the index of - // the real match, it should use m[0].length (where m is an array returned by - // rx.exec()). - search_backward: function(rx) { - var key = rx.toString(); - var cached = SEARCH_BACKWARD[key]; - if (!cached) { - rx = getPatternAndFlags(key); - rx.flags = rx.flags.replace(/g/g, "") + "g"; // make sure it's global - cached = new RegExp("([^]*)(" + rx.pattern + ")", rx.flags); - SEARCH_BACKWARD[key] = cached; - } - cached.lastIndex = 0; - return cached; - } - - // Returns a regexp that has the "$" appended, so that it would match only at - // the end of the string. This should be faster than using search_backward and - // checking the lastIndex, since the JS regexp engine can optimize it, knowing - // that it should match only at the end of the string. Well, I hope. - // - // Update: it's not faster, and it's buggy. Don't use this. - // - // looking_back: function(rx) { - // var key = rx.toString(); - // var cached = LOOKING_BACK[key]; - // if (!cached) { - // rx = getPatternAndFlags(key); - // rx.pattern = rx.pattern.replace(/\$*$/, "$"); - // cached = new RegExp(rx.pattern, rx.flags); - // LOOKING_BACK[key] = cached; - // } - // return cached; - // } - - }; - -})(); diff --git a/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-textprop.js.svn-base b/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-textprop.js.svn-base deleted file mode 100644 index 0290838..0000000 --- a/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-textprop.js.svn-base +++ /dev/null @@ -1,168 +0,0 @@ -//> This file is part of Ymacs, an Emacs-like editor for the Web -//> http://www.ymacs.org/ -//> -//> Copyright (c) 2009-2010, Mihai Bazon, Dynarch.com. All rights reserved. -//> -//> Redistribution and use in source and binary forms, with or without -//> modification, are permitted provided that the following conditions are -//> met: -//> -//> * Redistributions of source code must retain the above copyright -//> notice, this list of conditions and the following disclaimer. -//> -//> * Redistributions in binary form must reproduce the above copyright -//> notice, this list of conditions and the following disclaimer in -//> the documentation and/or other materials provided with the -//> distribution. -//> -//> * Neither the name of Dynarch.com nor the names of its contributors -//> may be used to endorse or promote products derived from this -//> software without specific prior written permission. -//> -//> THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY -//> EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -//> IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -//> PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE -//> FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -//> CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -//> SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -//> INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -//> CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -//> ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF -//> THE POSSIBILITY OF SUCH DAMAGE. - -DEFINE_CLASS("Ymacs_Text_Properties", DlEventProxy, function(D, P){ - - D.DEFAULT_EVENTS = [ "onChange" ]; - - D.DEFAULT_ARGS = { - buffer: [ "buffer", null ] - }; - - D.CONSTRUCT = P.reset = function() { - this.props = []; - }; - - P.insertLine = function(row) { - if (this.props.length < row) - this.props[row] = null; - else { - this.props.splice(row, 0, null); - } - }; - - P.deleteLine = function(row) { - this.props.splice(row, 1); - }; - - P.replaceLine = function(row, text) { - var p = this.props[row]; - if (p && p.length > text.length) { - // remove extra-properties - p.splice(text.length, p.length); - } - }; - - P.addLineProps = function(row, i, j, prop, val) { - var p = this.props, o, changed = false; - if (i < j) { - p = p[row] || (p[row] = []); - while (i < j) { - o = p[i] || (p[i] = {}); - if (o[prop] != val) - changed = true; - o[prop] = val; - ++i; - } - if (changed) - this.callHooks("onChange", row); - } - return changed; - }; - - P.removeLineProps = function(row, i, j, prop) { - var p = this.props[row], o, changed = false; - if (p && i < j) { - while (i < j) { - o = p[i]; - if (o && prop in o) { - changed = true; - delete o[prop]; - } - ++i; - } - if (changed) - this.callHooks("onChange", row); - } - return changed; - }; - - // this uses the "css" text property to intercalate <span class="$css"> ... </span> tags in the given text. - // "css" properties are added as the tokenizer parses the code and sends onFoundToken events. - // - // XXX: this function will be called a lot of times; seems complicated for what it does. Figure out if it can be - // optimized. - // - // Update: the mess got bigger once I decided to embed the caret in the text, rather than have it absolutely - // positioned (which seems to be the only practical way to position the cursor at the correct location). It is - // ESSENTIAL that the start tag of the element that defines the caret ends with "Ymacs-caret'>", so that the - // frame widget can find it. - P.getLineHTML = function(row, text, caret) { - var p = this.props[row]; - if (caret === null) { - if (text == "") - return "<br/>"; - if (!p || p.length == 0) { - return text.htmlEscape(); - } - } else { - if (text == "") - return "<span class='Ymacs-caret'> </span>"; - if (!p || p.length == 0) { - if (caret === text.length) - return text.htmlEscape() + "<span class='Ymacs-caret'> </span>"; - return text.substr(0, caret).htmlEscape() + - "<span class='Ymacs-caret'>" + - text.charAt(caret).htmlEscape() + - "</span>" + - text.substr(caret + 1).htmlEscape(); - } - } - var i = 0, n = text.length, last = null, o, ret = "", ch; - while (i < n) { - o = p[i]; - o = o && o.css; - if (i === caret) { - o = o ? o + " Ymacs-caret" : "Ymacs-caret"; - } - if (o && o != last) { - if (last) - ret += "</span>"; - ret += "<span class='" + o + "'>"; - } - else if (!o && last) { - ret += "</span>"; - } - last = o; - // XXX: Should have used a hash rather than a - // switch statement? I'm not sure but I have - // a feeling that switch is faster. - ch = text.charAt(i); - switch (ch) { - case "<" : ret += "<"; break; - case ">" : ret += ">"; break; - case "&" : ret += "&"; break; - default : ret += ch; break; - } - ++i; - } - if (last) - ret += "</span>"; - if (i === caret) { - // caret is at EOL - ret += "<span class='Ymacs-caret'> </span>"; - } - return ret; - }; - -}); diff --git a/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-tokenizer.js.svn-base b/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-tokenizer.js.svn-base deleted file mode 100644 index 4eed935..0000000 --- a/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs-tokenizer.js.svn-base +++ /dev/null @@ -1,337 +0,0 @@ -//> This file is part of Ymacs, an Emacs-like editor for the Web -//> http://www.ymacs.org/ -//> -//> Copyright (c) 2009-2010, Mihai Bazon, Dynarch.com. All rights reserved. -//> -//> Redistribution and use in source and binary forms, with or without -//> modification, are permitted provided that the following conditions are -//> met: -//> -//> * Redistributions of source code must retain the above copyright -//> notice, this list of conditions and the following disclaimer. -//> -//> * Redistributions in binary form must reproduce the above copyright -//> notice, this list of conditions and the following disclaimer in -//> the documentation and/or other materials provided with the -//> distribution. -//> -//> * Neither the name of Dynarch.com nor the names of its contributors -//> may be used to endorse or promote products derived from this -//> software without specific prior written permission. -//> -//> THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY -//> EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -//> IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -//> PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE -//> FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -//> CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -//> SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -//> INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -//> CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -//> ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF -//> THE POSSIBILITY OF SUCH DAMAGE. - -// @require ymacs-buffer.js - -DEFINE_CLASS("Ymacs_Stream", null, function(D, P){ - - D.DEFAULT_ARGS = { - buffer : [ "buffer" , null ], - line : [ "line" , 0 ], - col : [ "col" , 0] - }; - - P.nextCol = function() { - ++this.col; - }; - - P.prevCol = function() { - --this.col; - }; - - P.nextLine = function() { - ++this.line; - this.col = 0; - }; - - P.prevLine = function() { - --this.line; - this.col = 0; - }; - - P.peek = function(n) { - if (n == null) n = 0; - return this.buffer.code[this.line].charAt(this.col + n); - }; - - P.get = function() { - var ch = this.peek(); - this.nextCol(); - return ch; - }; - - P.lineText = function(row) { - if (row == null) - row = this.line; - return this.buffer.code[row]; - }; - - P.lineIndentation = function(row) { - return /^\s*/.exec(this.lineText(row))[0].length; - }; - - P.lookingAt = function(what) { - - var line = this.buffer.code[this.line]; - if (what instanceof RegExp) { - //what = 1; - return what.exec(line.substr(this.col + 1)); - } else { - return line.substr(this.col, what.length) == what; - } - }; - - P.textBefore = function(pos) { - if (pos == null) - pos = this.buffer._rowColToPosition(this.line, this.col); - return this.buffer.getCode().substr(0, pos); - }; - - P.textAfter = function(pos) { - if (pos == null) - pos = this.buffer._rowColToPosition(this.line, this.col); - return this.buffer.getCode().substr(pos); - }; - - P.substring = function(start, end) { - return this.buffer.getCode().substring(start, end); - }; - - P.substr = function(start, end) { - return this.buffer.getCode().substr(start, end); - }; - - P.eol = function() { - return this.col == this.buffer.code[this.line].length; - }; - - P.eof = function() { - var n = this.buffer.code.length, l = this.line; - return l >= n || l == n - 1 && this.eol(); - }; - - P.length = function() { - return this.buffer.code.length; - }; - - P.lineLength = function(line) { - if (line == null) - line = this.line; - return this.buffer.code[line].length; - }; - - P.save = function() { - return { buffer: this.buffer, line: this.line, col: this.col }; - }; - - P.restore = function(state) { - this.buffer = state.buffer; - this.line = state.line; - this.col = state.col; - }; - - P.checkStop = function() { - if (this.eof()) throw this.EOF; - if (this.eol()) throw this.EOL; - }; - - P.EOL = new (function(){}); - - P.EOF = new (function(){}); - -}); - -DEFINE_CLASS("Ymacs_Tokenizer", DlEventProxy, function(D, P){ - - var LANGUAGES = {}; - - D.define = function(name, func) { - LANGUAGES[name.toLowerCase()] = func; - }; - - D.DEFAULT_EVENTS = [ "onFoundToken" ]; - - D.DEFAULT_ARGS = { - buffer : [ "buffer", null ], - type : [ "type", null ] - }; - - D.FIXARGS = function(args) { - if (typeof args.type == "string") - args.type = LANGUAGES[args.type.toLowerCase()]; - }; - - D.CONSTRUCT = function() { - var smallest = null; - var timer = null; - this.quickUpdate = function(offset) { - var row = this.buffer._positionToRowCol(offset).row; - this.parsers.splice(row - 1, this.parsers.length + 1); - - if (smallest != null) { - smallest = Math.min(row, smallest); - } else { - smallest = row; - } - clearTimeout(timer); - timer = function(){ - this._do_quickUpdate(smallest); - smallest = null; - }.delayed(1, this); - }; - this._stopQuickUpdate = function() { - clearTimeout(timer); - clearTimeout(this.timerUpdate); - }; - this.reset(); - }; - - P.reset = function() { - this.stream = new Ymacs_Stream({ buffer: this.buffer }); - this.theParser = this.type(this.stream, this); - this.parsers = []; - this.parsers[-1] = this.theParser.copy(); - this.timerUpdate = null; - this.quickUpdate(0); - }; - - P.getLanguage = function(name) { - return LANGUAGES[name](this.stream, this); - }; - - P.showProgress = function(p) { - if (p != null) { - p = Math.round(p / this.stream.length() * 100) + "%"; - } - this.buffer.updateProgress("Syntax highlighting", p); - }; - - P._do_quickUpdate = function(row) { - this._stopQuickUpdate(); - var s = this.stream, p, a = this.parsers, n; - s.line = row - 1; - while (!(p = a[s.line])) - s.prevLine(); - s.nextLine(); - p = p(); - var iteration = 0; - var first = true; - var doit = function() { - this.buffer.preventUpdates(); - n = first ? 3 : 20; - if (++iteration > 10) - this.showProgress(this.stream.line); - while (true) { - try { - while (true) p.next(); - } - catch(ex) { - if (ex === s.EOL) { - a[s.line] = p.copy(); - s.nextLine(); - if (--n == 0) { - this.buffer.resumeUpdates(); - this.timerUpdate = setTimeout(doit, first ? 500 : 50); - first = false; - return; - } - } - else if (ex === s.EOF) { - a[s.line] = p.copy(); - this.buffer.resumeUpdates(); - if (p.on_EOF) - p.on_EOF(); - break; - } - else throw ex; - } - } - this.showProgress(); - }.$(this); - doit(); - }; - - P.quickInsertLine = function(row) { - this.parsers.splice(row, this.parsers.length + 1); - }; - - P.quickDeleteLine = function(row) { - this.parsers.splice(row, this.parsers.length + 1); - }; - - P.onToken = function(line, c1, c2, type) { - this.callHooks("onFoundToken", line, c1, c2, type); - }; - - P.getParserForLine = function(row) { - this._stopQuickUpdate(); - var s = this.stream, p, a = this.parsers, n; - var currentLine = s.line; - s.line = row - 1; - while (!(p = a[s.line])) - s.prevLine(); - s.nextLine(); - p = p(); - try { - this.buffer.preventUpdates(); - while (true) { - if (s.line == row) { - return p; - } - try { - while (true) p.next(); - } catch(ex) { - if (ex === s.EOL) { - a[s.line] = p.copy(); - s.nextLine(); - } - else if (ex === s.EOF) { - break; - } - else { - throw ex; - } - } - } - } finally { - this.buffer.resumeUpdates(); - // if (currentLine < s.length()) { - // // resume lazy tokenizer if it was interrupted - // this.timerUpdate = this._do_quickUpdate.delayed(50, this, Math.min(row, currentLine)); - // } - if (s.line < s.length()) - this.timerUpdate = this._do_quickUpdate.delayed(50, this, s.line); - } - }; - - P.reparseAll = function() { - this.parsers.splice(0, this.parsers.length); - return this.finishParsing(); - }; - - P.finishParsing = function() { - this.getParserForLine(this.stream.length()); - return this.getLastParser(); - }; - - P.getLastParser = function() { - return this.parsers.peek(); - }; - - P.getIndentation = function(row, buffer) { - var p = this.getParserForLine(row); - if (p && p.indentation instanceof Function) - return p.indentation(buffer); - }; - -}); diff --git a/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs.js.svn-base b/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs.js.svn-base deleted file mode 100644 index cf58706..0000000 --- a/gstudio/static/gstudio/js/Gnowmacs/src/js/.svn/text-base/ymacs.js.svn-base +++ /dev/null @@ -1,559 +0,0 @@ -//> This file is part of Ymacs, an Emacs-like editor for the Web -//> http://www.ymacs.org/ -//> -//> Copyright (c) 2009-2010, Mihai Bazon, Dynarch.com. All rights reserved. -//> -//> Redistribution and use in source and binary forms, with or without -//> modification, are permitted provided that the following conditions are -//> met: -//> -//> * Redistributions of source code must retain the above copyright -//> notice, this list of conditions and the following disclaimer. -//> -//> * Redistributions in binary form must reproduce the above copyright -//> notice, this list of conditions and the following disclaimer in -//> the documentation and/or other materials provided with the -//> distribution. -//> -//> * Neither the name of Dynarch.com nor the names of its contributors -//> may be used to endorse or promote products derived from this -//> software without specific prior written permission. -//> -//> THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY -//> EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -//> IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -//> PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE -//> FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -//> CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -//> SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -//> INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -//> CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -//> ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF -//> THE POSSIBILITY OF SUCH DAMAGE. - -DEFINE_CLASS("Ymacs", DlLayout, function(D, P, DOM){ - - D.DEFAULT_EVENTS = [ - "onBufferSwitch", - "onCreateBuffer", - "onDeleteBuffer" - ]; - - D.DEFAULT_ARGS = { - buffers : [ "buffers" , null ], - frames : [ "frames" , null ], - - // default options - cf_lineNumbers: [ "lineNumbers", false ], - - // override in DlWidget - _focusable : [ "focusable" , true ] - }; - - D.FIXARGS = function(args) { - if (!args.buffers) - args.buffers = []; - if (!args.frames) - args.frames = []; - }; - - D.CONSTRUCT = function() { - this.buffers.foreach(function(b){ - b.ymacs = this; - }, this); - - /* -----[ variables ]----- */ - this.killRing = []; - this.killMasterOfRings = []; - this.progress = {}; - - /* -----[ minibuffer ]----- */ - this.minibuffer = this.createBuffer({ hidden: true, isMinibuffer: true }); - this.minibuffer.cmd("minibuffer_mode"); - this.minibuffer_frame = this.createFrame({ - isMinibuffer : true, - buffer : this.minibuffer, - hidden : true, - highlightCurrentLine : false, - className : "Ymacs_Minibuffer" - }); - - /* -----[ main content ]----- */ - if (this.buffers.length == 0) - this.createBuffer(); - - var frame = this.createFrame({ buffer: this.buffers[0] }); - - this.packWidget(this.minibuffer_frame, { pos: "bottom" }); - this.packWidget(frame, { pos: "top", fill: "*" }); - - // this.__activeFrameEvents = { - // // onPointChange: this._on_activeFramePointChange.$(this) - // }; - - this.setActiveFrame(frame); - frame._redrawCaret(); - }; - - P.pushToKillRing = function(text, prepend) { - prepend ? this.killRing.unshift(text) - : this.killRing.push(text); - }; - - P.killRingToMaster = function() { - if (this.killRing.length && (this.killMasterOfRings.length == 0 || - this.killMasterOfRings.peek().join("") != this.killRing.join(""))) - this.killMasterOfRings.push(this.killRing); - this.killRing = []; - }; - - P.killRingText = function() { - return this.killRing.join(""); - }; - - P.rotateKillRing = function(push) { - if (push) { - this.killMasterOfRings.push(this.killRing); - this.killRing = this.killMasterOfRings.shift(); - } else { - this.killMasterOfRings.unshift(this.killRing); - this.killRing = this.killMasterOfRings.pop(); - } - }; - - P.getBuffer = function(buf) { - if (!(buf instanceof Ymacs_Buffer)) { - buf = this.buffers.grep_first(function(b){ - return b.name == buf; - }); - } - return buf; - }; - - P.killBuffer = function(buf) { - buf = this.getBuffer(buf); - this.callHooks("onDeleteBuffer", buf); - if (this.buffers.length > 1) { - if (this.getActiveBuffer() === buf) - this.switchToNextBuffer(); - } else { - // make a brand new buffer - this.switchToBuffer(this.createBuffer()); - } - this.buffers.remove(buf); - buf.destroy(); - }; - - P.renameBuffer = function(buf, name) { - buf = this.getBuffer(buf); - buf.name = name; - buf.callHooks("onProgressChange"); - }; - - P._do_switchToBuffer = function(buf) { - this.getActiveFrame().setBuffer(buf); - this.callHooks("onBufferSwitch", buf); - }; - - P.switchToBuffer = function(maybeName) { - var buf = this.getBuffer(maybeName), a = this.buffers; - if (!buf) { - // create new buffer - buf = this.createBuffer({ name: maybeName }); - } - a.remove(buf); - a.unshift(buf); - this._do_switchToBuffer(buf); - return buf; - }; - - P.switchToNextBuffer = function(n) { - var a = this.buffers; - if (a.length > 1) { - var buf = a.shift(); - a.push(buf); - this._do_switchToBuffer(a[0]); - } - }; - - P.switchToPreviousBuffer = function(n) { - var a = this.buffers; - if (a.length > 1) { - var buf = a.pop(); - a.unshift(buf); - this._do_switchToBuffer(buf); - } - }; - - P.getNextBuffer = function(buf, n) { - if (n == null) n = 1; - var a = this.buffers; - return a[a.rotateIndex(a.find(buf) + n)]; - }; - - P.getPrevBuffer = function(buf, n) { - if (n == null) n = 1; - var a = this.buffers; - return a[a.rotateIndex(a.find(buf) - n)]; - }; - - P.getBufferFrames = function(buf) { - buf = this.getBuffer(buf); - return this.frames.grep(function(f){ - return f.buffer === buf; - }); - }; - - P.createBuffer = function(args) { - if (!args) args = {}; - Object.merge(args, { ymacs: this }); - var buf = new Ymacs_Buffer(args); - if (!args.hidden) - this.buffers.push(buf); - // - // XXX: although this seems the right way to do it, - // instead of doing it in killBuffer, for some - // reason we never get this event. Should - // investigate. - // - // buf.addEventListener("onDestroy", function(buf){ - // console.log("got here, %s, %s", this.getActiveBuffer().name, buf.name); - // if (this.getActiveBuffer() === buf) - // this.switchToPreviousBuffer(); - // this.buffers.remove(buf); - // }.$(this, buf)); - // - - this.callHooks("onCreateBuffer", buf); - - return buf; - }; - - P.createFrame = function(args) { - if (!args) args = {}; - Object.merge(args, { ymacs: this }); - var frame = new Ymacs_Frame(args); - if (!args.hidden) - this.frames.unshift(frame); - frame.addEventListener("onDestroy", function(frame) { - this.frames.remove(frame); - }.$(this, frame)); - return frame; - }; - - P.keepOnlyFrame = function(frame) { - if (this.frames.length > 1) { - var p = frame.parent; - while (p.parent != this) - p = p.parent; - this.replaceWidget(p, frame); - p.destroy(); - this.setActiveFrame(frame); - this.doLayout(); - } - }; - - P.deleteFrame = function(frame) { - if (this.frames.length > 1) { - var p = frame.parent, other = p.children().grep_first(function(f){ - return f instanceof DlLayout || f instanceof Ymacs_Frame && f !== frame; - }); - p.parent.replaceWidget(p, other); - p.destroy(); - try { - DOM.walk(other.getElement(), function(el){ - el = DlWidget.getFromElement(el); - if (el && el instanceof Ymacs_Frame) - throw el; - }); - } catch(ex) { - if (!(ex instanceof Ymacs_Frame)) - throw ex; - other = ex; - } - this.setActiveFrame(other); - this.doLayout(); - } - }; - - P.focusOtherFrame = function() { - this.setActiveFrame(this.frames[0]); - }; - - P.focus = function() { - D.BASE.focus.apply(this, arguments); - this.frames.peek().focus(); - }; - - P.setActiveFrame = function(frame, nofocus) { - if (!frame.isMinibuffer) { - var old = this.getActiveFrame(); - if (old) { - old.delClass("Ymacs_Frame-active"); - } - this.frames.remove(frame); - this.frames.push(frame); - } - if (!nofocus) - frame.focus(); - }; - - P.getActiveFrame = function() { - return this.frames.peek(); - }; - - P.getActiveBuffer = function() { - var frame = this.getActiveFrame(); - return frame ? frame.buffer : this.buffers.peek(); - }; - - P.setColorTheme = function(themeId) { - this.delClass(/Ymacs-Theme-[^\s]*/g); - if (!(themeId instanceof Array)) - themeId = [ themeId ]; - themeId.foreach(function(themeId){ - this.addClass("Ymacs-Theme-" + themeId); - }, this); - }; - - P.getFrameInDirection = function(dir, pos, frame) { - if (!frame) - frame = this.getActiveFrame(); - var caret = frame.getCaretElement(); - if (!pos) - pos = DOM.getPos(caret); - if (!pos.sz) - pos.sz = DOM.getOuterSize(caret); - var byx = this.frames.mergeSort(function(a, b){ return a.getPos().x - b.getPos().x }); - var byy = this.frames.mergeSort(function(a, b){ return a.getPos().y - b.getPos().y }); - return this["_get_frameInDir_" + dir](byx, byy, pos, frame); - - }; - - function selectClosestFrameX(byx, pos) { - - if (byx.length > 0) { - var x = byx.peek().getPos().x, a = [ byx.pop() ]; - while (byx.length > 0 && byx.peek().getPos().x == x) - a.push(byx.pop()); - return a.minElement(function(f){ - return Math.abs(pos.y - f.getPos().y - f.getSize().y/2); - - }); - } - }; - - function selectClosestFrameY(byy, pos) { - if (byy.length > 0) { - var y = byy.peek().getPos().y, a = [ byy.pop() ]; - while (byy.length > 0 && byy.peek().getPos().y == y) - a.push(byy.pop()); - return a.minElement(function(f){ - return Math.abs(pos.x - f.getPos().x - f.getSize().x/2); - - }); - -} - }; - - P._get_frameInDir_left = function(byx, byy, pos, frame) { - byx = byx.grep(function(f){ - var p = f.getPos(), s = f.getSize(); - ymacs.getActiveBuffer().cmd("backward_delete_char"); - return (f !== frame) && (p.x < pos.x) && (p.y - pos.sz.y <= pos.y) && (p.y + s.y > pos.y); - }); - return selectClosestFrameX(byx, pos); - }; - - P._get_frameInDir_right = function(byx, byy, pos, frame) { - byx.reverse(); - byx = byx.grep(function(f){ - var p = f.getPos(), s = f.getSize(); - var temp = "*"; - ymacs.getActiveBuffer().cmd("insert",temp); - return (f !== frame) && (p.x > pos.x) && (p.y - pos.sz.y <= pos.y) && (p.y + s.y > pos.y); - }); - return selectClosestFrameX(byx, pos); - }; - - P._get_frameInDir_up = function(byx, byy, pos, frame) { - byy = byy.grep(function(f){ - var p = f.getPos(), s = f.getSize(); - var prefix1,prefix2,pretemp1,pretemp2; - var temp1; var p1; - var temp2; - ymacs.getActiveBuffer().cmd("beginning_of_line"); - if (ymacs.getActiveBuffer().cmd("looking_at", /[*]+/g)) - { - temp1 = ymacs.getActiveBuffer().matchData[0]; - // ymacs.getActiveBuffer().cmd("backward_paragraph"); - ymacs.getActiveBuffer().cmd("backward_paragraph"); - ymacs.getActiveBuffer().cmd("forward_char"); p1= ymacs.getActiveBuffer().point(); - if (ymacs.getActiveBuffer().cmd("looking_at", /[*]+/g)) - { - temp2 = ymacs.getActiveBuffer().matchData[0]; - if (temp1.length > temp2.length) - { - alert("Cannot move past superior level or buffer limit"); - } - else { - ymacs.getActiveBuffer().cmd("forward_paragraph"); - ymacs.getActiveBuffer().cmd("forward_char"); - ymacs.getActiveBuffer().cmd("forward_line"); - if (ymacs.getActiveBuffer().cmd("looking_at", /[^*]+/g)) - { - ymacs.getActiveBuffer().cmd("backward_line"); - ymacs.getActiveBuffer().cmd("transpose_para"); - ymacs.getActiveBuffer()._repositionCaret(p1); - ymacs.getActiveBuffer().cmd("beginning_of_line"); - } - else - { - ymacs.getActiveBuffer().cmd("backward_line"); - ymacs.getActiveBuffer().cmd("transpose_para"); - ymacs.getActiveBuffer()._repositionCaret(p1); - ymacs.getActiveBuffer().cmd("beginning_of_line"); - } - - } - } - } - else if (ymacs.getActiveBuffer().cmd("looking_at", /([0-9]+)(\.\s+)([a-z]+)+/g)) - { - ymacs.getActiveBuffer().cmd("beginning_of_line"); - ymacs.getActiveBuffer().cmd("transpose_text"); - ymacs.getActiveBuffer().cmd("beginning_of_line"); - ymacs.getActiveBuffer().cmd("backward_paragraph"); - ymacs.getActiveBuffer().cmd("forward_line"); - } - - - else - { - ymacs.getActiveBuffer().cmd("transpose_lines"); - ymacs.getActiveBuffer().cmd("backward_line"); - ymacs.getActiveBuffer().cmd("beginning_of_line"); - } - - return (f !== frame) && (p.y < pos.y) && (p.x - pos.sz.x <= pos.x) && (p.x + s.x > pos.x); - }); - return selectClosestFrameY(byy, pos); - }; - - P._get_frameInDir_down = function(byx, byy, pos, frame) { - byy.reverse(); - byy = byy.grep(function(f){ - var p = f.getPos(), s = f.getSize(); - - var p2; - var temp1; - var temp2; - ymacs.getActiveBuffer().cmd("beginning_of_line"); - if (ymacs.getActiveBuffer().cmd("looking_at", /[*]+/g)) - { - temp1 = ymacs.getActiveBuffer().matchData[0]; - // ymacs.getActiveBuffer().cmd("backward_paragraph"); - ymacs.getActiveBuffer().cmd("forward_paragraph"); - ymacs.getActiveBuffer().cmd("forward_char"); - p2= ymacs.getActiveBuffer().point(); - if (ymacs.getActiveBuffer().cmd("looking_at", /[*]+/g)) - { - temp2 = ymacs.getActiveBuffer().matchData[0]; - if (temp1.length > temp2.length) - { - alert("Cannot move past superior level or buffer limit"); - } - else { - /* ymacs.getActiveBuffer().cmd("backward_paragraph"); - ymacs.getActiveBuffer().cmd("forward_char"); */ - ymacs.getActiveBuffer().cmd("forward_line"); - if (ymacs.getActiveBuffer().cmd("looking_at", /[^*]+/g)) - { ymacs.getActiveBuffer().cmd("backward_line"); - ymacs.getActiveBuffer().cmd("transpose_para"); - ymacs.getActiveBuffer()._repositionCaret(p2); - ymacs.getActiveBuffer().cmd("beginning_of_line"); - } - else - { ymacs.getActiveBuffer().cmd("backward_line"); - ymacs.getActiveBuffer().cmd("transpose_para"); - ymacs.getActiveBuffer()._repositionCaret(p2); - ymacs.getActiveBuffer().cmd("beginning_of_line"); - } - -} }} - else if (ymacs.getActiveBuffer().cmd("looking_at", /([0-9]+)(\.\s+)([a-z]+)+/g)) - { - - ymacs.getActiveBuffer().cmd("forward_paragraph"); - ymacs.getActiveBuffer().cmd("forward_line"); - // ymacs.getActiveBuffer().cmd("beginning_of_line"); - ymacs.getActiveBuffer().cmd("transpose_text"); - - } - - - else - { - ymacs.getActiveBuffer().cmd("forward_line"); - ymacs.getActiveBuffer().cmd("transpose_lines"); - ymacs.getActiveBuffer().cmd("beginning_of_line"); - } - - return (f !== frame) && (p.y > pos.y) && (p.x - pos.sz.x <= pos.x) && (p.x + s.x > pos.x); - }); - return selectClosestFrameY(byy, pos); - }; - - /* -----[ local storage ]----- */ - - function ensureLocalStorage() { - if (!(window.localStorage && window.localStorage.getItem)) - throw new Ymacs_Exception("Local storage facility not available in this browser"); - }; - - P.ls_get = function() { - ensureLocalStorage(); - return DlJSON.decode(localStorage.getItem(".ymacs") || "{}", true); - }; - - P.ls_set = function(src) { - ensureLocalStorage(); - localStorage.setItem(".ymacs", DlJSON.encode(src)); - }; - - P.ls_getFileContents = function(name, nothrow) { - var info = this.ls_getFileDirectory(name), other = info.other, code; - if (other.length == 1) { - code = info.dir[other[0]]; - } - if (code == null && !nothrow) { - throw new Ymacs_Exception("File not found"); - } - return code; - }; - - P.ls_getFileDirectory = function(name, create) { - var store, dir = store = this.ls_get(); - name = name.replace(/^[~\x2f]+/, "").split(/\x2f+/); - var path = [], other = []; - while (name.length > 0) { - var part = name.shift(); - if (dir.hasOwnProperty(part) && (typeof dir[part] != "string")) { - dir = dir[part]; - path.push(part); - } - else { - other.push(part); - } - }; - if (create) { - var n = create == "file" ? 1 : 0; - while (other.length > n) { - dir = dir[other.shift()] = {}; - } - this.ls_set(store); - } - return { store: store, dir: dir, path: path, other: other }; - }; - -}); diff --git a/gstudio/static/gstudio/js/Gnowmacs/src/js/jquery.ui.gnowmacs.js b/gstudio/static/gstudio/js/Gnowmacs/src/js/jquery.ui.gnowmacs.js index 88caa1f..6fe35f1 100644 --- a/gstudio/static/gstudio/js/Gnowmacs/src/js/jquery.ui.gnowmacs.js +++ b/gstudio/static/gstudio/js/Gnowmacs/src/js/jquery.ui.gnowmacs.js @@ -171,44 +171,32 @@ var org_data = org.getCode(); document.getElementById("orgcontent").value = org_data; var encode_data = encodeURIComponent(org_data); - - - url = "/nodetypes/ajax/contentorgadd/?id=" + id + "&contentorg=" +encode_data; - $.get(url, - function(data){ - }) - url = "/nodetypes/ajax/contentorgadd/?id=" + id + "&contentorg=" +encode_data; - $.get(url, - function(data){ - }) - - url = "/nodetypes/ajax/ajaxcreatefile/?id=" +id+ "&content_org=" +encode_data; - $.get(url, - function(data){ - }) - - url = "/nodetypes/ajax/ajaxcreatehtml/"; - $.get(url, - function(data){ - }) - - url = "/nodetypes/ajax/contentadd/?id=" + id; - $.get(url, - function(data){ - }) - url = "/nodetypes/ajax/contentadd/?id=" + id; - $.get(url, - function(data){ - }) - url = "/nodetypes/ajax/contentadd/?id=" + id; - $.get(url, - function(data){ - }) - - - alert("Data Saved"); - window.location.reload(); - }); + url = "/nodetypes/ajax/contentorgadd/?id=" + id + "&contentorg=" +encode_data; + $.get(url, + function(data){ + + url1 = "/nodetypes/ajax/ajaxcreatefile/?id=" +id+ "&content_org=" +encode_data; + $.get(url1, + function(data){ + url2 = "/nodetypes/ajax/ajaxcreatehtml/"; + $.get(url2, + function(data){ + url3 = "/nodetypes/ajax/contentadd/?id=" + id; + $.get(url3, + function(data){ + alert("Data Saved"); + window.location.reload(); + + }) + + + }) + }) + + }) + + + }); var item = new DlMenuItem({ parent: menu, @@ -217,29 +205,13 @@ item.addEventListener("onSelect", function () { ymacs.getActiveBuffer().cmd("toggle_line_numbers"); }); - - /*------[ Wrap ]-------- - flag is a variable to store the current status of wrap.wrap itself switches On n Off depending on previous status. - so it is necessary to keep record of previous status*/ - - // var item = new DlMenuItem({ - // parent: menu, - // label: "Wrap".makeLabel() - // }); - // var flag = "False"; - // item.addEventListener("onSelect", function () { - // if (flag == "False") { - // flag = "True"; - // alert("Wrapping is ON"); - // ymacs.getActiveBuffer().cmd("wrap_text"); - // } else { - // flag = "False"; - // alert("Wrapping is OFF"); - // ymacs.getActiveBuffer().cmd("wrap_text"); - // } - - // }); - + var item = new DlMenuItem({ + parent: menu, + label: "Wrap".makeLabel() + }); + item.addEventListener("onSelect", function () { + ymacs.getActiveBuffer().cmd("wrap"); + }); /* -----[ insert - just a try] ----- */ diff --git a/gstudio/static/gstudio/js/Gnowmacs/src/js/ymacs-commands.js b/gstudio/static/gstudio/js/Gnowmacs/src/js/ymacs-commands.js index a44e1ff..10c2ab3 100644 --- a/gstudio/static/gstudio/js/Gnowmacs/src/js/ymacs-commands.js +++ b/gstudio/static/gstudio/js/Gnowmacs/src/js/ymacs-commands.js @@ -102,139 +102,43 @@ Ymacs_Buffer.newCommands({ var rc = this._rowcol; return this.cmd("goto_char", this._rowColToPosition(rc.row, this.code[rc.row].length)); }), - wrap : Ymacs_Interactive(function() { - var i = 0; - this.cmd("end_of_buffer"); - var st1 = this.caretMarker.getPosition(); - this.cmd("beginning_of_buffer"); - if(st1 != 0) - { - while(i < 50 ) - { - this.cmd("goto_line", i); - i= i+1; - rc = this._rowcol; - var line = this.code[rc.row]; - var line_size = line.length; - if(line_size > 112) - { - this.cmd("move_to_column", 111); - this.cmd("insert", "\n"); - this.cmd("forward_line"); - } - } - - } - - }), - - - wrap_at_edge : Ymacs_Interactive(function() { - rc = this._rowcol; - var line = this.code[rc.row]; - var str1 = line.length; - if(str1 > 112) - { - this.cmd("insert", "\n"); - } - }), - - wrap_status:Ymacs_Interactive(function() { - var one = flag; - //alert("inside wrap_status"); - return one; - }), - - word_wrap : Ymacs_Interactive(function() { - - var one1 = this.cmd("wrap_status"); - if(one1 == "Word Wrap") - { - var x = 112; - rc = this._rowcol; - var line = this.code[rc.row]; - var str1 = line.length; - if(str1 > x) - { - var str2 = line.slice(0,str1-2); - var str3 = str2.lastIndexOf(" "); - this.cmd("move_to_column", str3+1); - this.cmd("insert", "\n"); - this.cmd("end_of_line"); - this.cmd("insert", " "); - } - else - { - this.cmd("insert", " "); - } - } - else - { - - this.cmd("insert", " "); - } - - - }), - - - wrap1:Ymacs_Interactive(function() { - var i = 1; - this.cmd("end_of_buffer"); - var str1 = this.caretMarker.getPosition(); - //this.cmd("beginning_of_buffer"); - if(str1 != 0) - { - while(i < 50 ) - { - this.cmd("goto_line" ,i); - i=i+1; - rc = this._rowcol; - var line = this.code[rc.row]; - var str2 = line.lastIndexOf(" "); - if(str2 > 112) - { - var str2 = line.slice(0,115); - var str3 = str2.lastIndexOf(" "); - this.cmd("move_to_column", str3+1); - this.cmd("insert", "\n"); - this.cmd("forward_line"); - } - } - } - - }), + wrap : Ymacs_Interactive(function() { + + this.cmd("beginning_of_buffer"); + this.cmd("goto_line" ,1); + var i = 0,y = 0, x = 50; + while(i < 100) + { + i = i+1; + + + this.cmd("end_of_line"); + var ipos = this._positionToRowCol(this.point()); + var charpos = this.caretMarker.getPosition(); // It gives total number of character upto this position. + + + if(ipos.col > x ) //ipos.col gives the column number at this point. + { + y = ipos.col-50; + var z = charpos-y; + this.cmd("goto_char", z); + this.cmd("insert", "\n"); + } + else + { + this.cmd("forward_line"); + + } + + } + }), + beginning_of_buffer: Ymacs_Interactive(function() { return this.cmd("goto_char", 0); }), - export_as_html: Ymacs_Interactive(function() { - //jQuery.get('/ymacs/test.py', function(data) { - //alert("jquery"); - //window.location= "/home/supriya/ymacs/test.py" - //alert("test1"); - - //do stuff with the data - - - //var oShell = new AactiveXObject("WScript.Shell"); - //shell.Run("/h", 1, true); - // $.ajax({ - // type: "GET", - // url: "test.py", - // success: function() { alert("ajax"); } - //} ); - //} ); - //url = "~/test.py" - //$.get(url, - //function(data){ - //alert("ajax"); - //}); - - }), - end_of_buffer: Ymacs_Interactive(function() { return this.cmd("goto_char", this.getCodeSize()); @@ -340,9 +244,9 @@ Ymacs_Buffer.newCommands({ this.cmd("indent_line"); } }), - + -// tab is not working on the 1st position of the buffer + // tab is not working on the 1st position of the buffer // user should create table from 1st position only indent_line: Ymacs_Interactive("P", function(noEmpty) { @@ -496,7 +400,7 @@ Ymacs_Buffer.newCommands({ } this.cmd("insert", " ".x(this.getq("indent_line"))); }), - indent_region: Ymacs_Interactive("r", function(begin, end) { + indent_region: Ymacs_Interactive("r", function(begin, end) { if (end < begin) { var tmp = begin; begin = end; end = tmp; } this.cmd("save_excursion", function() { var m = this.createMarker(end); |