2014-06-18 23:27:05 +02:00
ace . define ( "ace/keyboard/emacs" , [ "require" , "exports" , "module" , "ace/lib/dom" , "ace/incremental_search" , "ace/commands/incremental_search_commands" , "ace/keyboard/hash_handler" , "ace/lib/keys" ] , function ( e , t , n ) { var r = e ( "../lib/dom" ) ; e ( "../incremental_search" ) ; var i = e ( "../commands/incremental_search_commands" ) , s = function ( e , t ) { var n = this . scroller . getBoundingClientRect ( ) , r = Math . floor ( ( e + this . scrollLeft - n . left - this . $padding ) / this . characterWidth ) , i = Math . floor ( ( t + this . scrollTop - n . top ) / this . lineHeight ) ; return this . session . screenToDocumentPosition ( i , r ) } , o = e ( "./hash_handler" ) . HashHandler ; t . handler = new o , t . handler . isEmacs = ! 0 , t . handler . $id = "ace/keyboard/emacs" ; var u = ! 1 , a , f ; t . handler . attach = function ( e ) { u || ( u = ! 0 , r . importCssString ( " .emacs-mode .ace_cursor{ border: 2px rgba(50,250,50,0.8) solid!important; -moz-box-sizing: border-box!important; -webkit-box-sizing: border-box!important; box-sizing: border-box!important; background-color: rgba(0,250,0,0.9); opacity: 0.5; } .emacs-mode .ace_hidden-cursors .ace_cursor{ opacity: 1; background-color: transparent; } .emacs-mode .ace_overwrite-cursors .ace_cursor { opacity: 1; background-color: transparent; border-width: 0 0 2px 2px !important; } .emacs-mode .ace_text-layer { z-index: 4 } .emacs-mode .ace_cursor-layer { z-index: 2 }" , "emacsMode" ) ) , a = e . session . $selectLongWords , e . session . $selectLongWords = ! 0 , f = e . session . $useEmacsStyleLineStart , e . session . $useEmacsStyleLineStart = ! 0 , e . session . $emacsMark = null , e . session . $emacsMarkRing = e . session . $emacsMarkRing || [ ] , e . emacsMark = function ( ) { return this . session . $emacsMark } , e . setEmacsMark = function ( e ) { this . session . $emacsMark = e } , e . pushEmacsMark = function ( e , t ) { var n = this . session . $emacsMark ; n && this . session . $emacsMarkRing . push ( n ) , ! e || t ? this . setEmacsMark ( e ) : this . session . $emacsMarkRing . push ( e ) } , e . popEmacsMark = function ( ) { var e = this . emacsMark ( ) ; return e ? ( this . setEmacsMark ( null ) , e ) : this . session . $emacsMarkRing . pop ( ) } , e . getLastEmacsMark = function ( e ) { return this . session . $emacsMark || this . session . $emacsMarkRing . slice ( - 1 ) [ 0 ] } , e . on ( "click" , c ) , e . on ( "changeSession" , l ) , e . renderer . screenToTextCoordinates = s , e . setStyle ( "emacs-mode" ) , e . commands . addCommands ( v ) , t . handler . platform = e . commands . platform , e . $emacsModeHandler = this , e . addEventListener ( "copy" , this . onCopy ) , e . addEventListener ( "paste" , this . onPaste ) } , t . handler . detach = function ( e ) { delete e . renderer . screenToTextCoordinates , e . session . $selectLongWords = a , e . session . $useEmacsStyleLineStart = f , e . removeEventListener ( "click" , c ) , e . removeEventListener ( "changeSession" , l ) , e . unsetStyle ( "emacs-mode" ) , e . commands . removeCommands ( v ) , e . removeEventListener ( "copy" , this . onCopy ) , e . removeEventListener ( "paste" , this . onPaste ) } ; var l = function ( e ) { e . oldSession && ( e . oldSession . $selectLongWords = a , e . oldSession . $useEmacsStyleLineStart = f ) , a = e . session . $selectLongWords , e . session . $selectLongWords = ! 0 , f = e . session . $useEmacsStyleLineStart , e . session . $useEmacsStyleLineStart = ! 0 , e . session . hasOwnProperty ( "$emacsMark" ) || ( e . session . $emacsMark = null ) , e . session . hasOwnProperty ( "$emacsMarkRing" ) || ( e . session . $emacsMarkRing = [ ] ) } , c = function ( e ) { e . editor . session . $emacsMark = null } , h = e ( "../lib/keys" ) . KEY _MODS , p = { C : "ctrl" , S : "shift" , M : "alt" , CMD : "command" } , d = [ "C-S-M-CMD" , "S-M-CMD" , "C-M-CMD" , "C-S-CMD" , "C-S-M" , "M-CMD" , "S-CMD" , "S-M" , "C-CMD" , "C-M" , "C-S" , "CMD" , "M" , "S" , "C" ] ; d . forEach ( function ( e ) { var t = 0 ; e . split ( "-" ) . forEach ( function ( e ) { t |= h [ p [ e ] ] } ) , p [ t ] = e . toLowerCase ( ) + "-" } ) , t . handler . onCopy = function ( e , n ) { if ( n . $handlesEmacsOnCopy ) return ; n . $handlesEmacsOnCopy = ! 0 , t . handler . commands . killRingSave . exec ( n ) , delete n . $handlesEmacsOnCopy } , t . handler . onPaste = function ( e , t ) { t . pushEmacsMark ( t . getCursorPosition ( ) ) } , t . handler . bindKey = function ( e , t ) { if ( ! e ) return ; var n = this . commandKeyBinding ; e . split ( "|" ) . forEach ( function ( e ) { e = e . toLowerCase ( ) , n [ e ] = t ; var r = e . split ( " " ) . slice ( 0 , - 1 ) ; r . reduce ( function ( e , t , n ) { var r = e [ n - 1 ] ? e [ n - 1 ] + " " : "" ; re