~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to www/media/common/codepress/engines/gecko.js

  • Committer: wagrant
  • Date: 2008-08-09 05:55:58 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:998
editor: Add a hook to CodePress to catch Ctrl+S. Use that to trigger
        a save.

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
                window.addEventListener('scroll', function() { if(!CodePress.scrolling) CodePress.syntaxHighlight('scroll') }, false);
33
33
                completeChars = this.getCompleteChars();
34
34
                completeEndingChars =  this.getCompleteEndingChars();
35
 
                document.changehandlers = Array()
 
35
                document.changehandlers = Array();
 
36
                document.savehandlers = Array();
36
37
        },
37
38
 
38
39
        // treat key bindings
41
42
                charCode = evt.charCode;
42
43
                fromChar = String.fromCharCode(charCode);
43
44
                // Arrow keys, Pg{Up,Dn}, Home, End won't mutate the content.
44
 
                if ([33, 34, 35, 36, 37, 38, 39, 40].indexOf(keyCode) == -1)
 
45
                if ([33, 34, 35, 36, 37, 38, 39, 40].indexOf(keyCode) == -1 && (charCode!=115 || !evt.ctrlKey))
45
46
                {
46
47
                        for (var handler in this.changehandlers)
47
48
                        {
49
50
                        }
50
51
                }
51
52
 
52
 
                if((evt.ctrlKey || evt.metaKey) && evt.shiftKey && charCode!=90)  { // shortcuts = ctrl||appleKey+shift+key!=z(undo) 
 
53
                else if((evt.ctrlKey || evt.metaKey) && evt.shiftKey && charCode!=90)  { // shortcuts = ctrl||appleKey+shift+key!=z(undo) 
53
54
                        CodePress.shortcuts(charCode?charCode:keyCode);
54
55
                }
55
56
                else if( (completeEndingChars.indexOf('|'+fromChar+'|')!= -1 || completeChars.indexOf('|'+fromChar+'|')!=-1) && CodePress.autocomplete) { // auto complete
77
78
                else if(charCode==99 && evt.ctrlKey)  { // handle cut
78
79
                        //alert(window.getSelection().getRangeAt(0).toString().replace(/\t/g,'FFF'));
79
80
                }
80
 
 
 
81
                else if(charCode==115 && evt.ctrlKey)  { // handle save
 
82
                        evt.preventDefault();
 
83
                        for (var handler in this.savehandlers)
 
84
                        {
 
85
                                document.savehandlers[handler]();
 
86
                        }
 
87
                }
81
88
        },
82
89
 
83
90
        // put cursor back to its original position after every parsing
272
279
                document.changehandlers.push(handler);
273
280
        },
274
281
 
 
282
        addSaveHandler : function(handler) {
 
283
                document.savehandlers.push(handler);
 
284
        },
 
285
 
275
286
        // undo and redo methods
276
287
        actions : {
277
288
                pos : -1, // actual history position