ver 2010.02 → 2010.08
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/.yardopts +1 -1
- data/AUTHORS +2 -2
- data/CHANGELOG +1160 -0
- data/MANIFEST +212 -62
- data/README.textile +68 -9
- data/Rakefile +2 -2
- data/bin/ver +33 -8
- data/config/commands/ANTLR.rb +11 -0
- data/config/commands/ActionScript.rb +102 -0
- data/config/commands/Active4D.rb +30 -0
- data/config/commands/Ada.rb +11 -0
- data/config/commands/Ant.rb +90 -0
- data/config/commands/Apache.rb +98 -0
- data/config/commands/AppleScript.rb +169 -0
- data/config/commands/Blogging.rb +72 -0
- data/config/commands/Bulletin Board.rb +10 -0
- data/config/commands/Bundle Development.rb +83 -0
- data/config/commands/C++ Qt.rb +158 -0
- data/config/commands/C.rb +82 -0
- data/config/commands/CMake.rb +32 -0
- data/config/commands/CSS.rb +76 -0
- data/config/commands/CTags.rb +29 -0
- data/config/commands/CVS.rb +114 -0
- data/config/commands/CoffeeScript.rb +58 -0
- data/config/commands/Context Free.rb +20 -0
- data/config/commands/Cucumber.rb +94 -0
- data/config/commands/D.rb +47 -0
- data/config/commands/Darcs.rb +72 -0
- data/config/commands/Diff.rb +76 -0
- data/config/commands/Doxygen.rb +9 -0
- data/config/commands/Experimental Wiki.rb +9 -0
- data/config/commands/Experimental.rb +172 -0
- data/config/commands/F-Script.rb +13 -0
- data/config/commands/FXScript.rb +11 -0
- data/config/commands/FileMerge.rb +42 -0
- data/config/commands/Fortran.rb +58 -0
- data/config/commands/GTD2.rb +134 -0
- data/config/commands/GTDAlt.rb +225 -0
- data/config/commands/GetBundle.rb +41 -0
- data/config/commands/Go.rb +29 -0
- data/config/commands/Graphviz.rb +11 -0
- data/config/commands/Greasemonkey.rb +158 -0
- data/config/commands/Gri.rb +11 -0
- data/config/commands/Groovy Grails.rb +174 -0
- data/config/commands/Groovy.rb +66 -0
- data/config/commands/HTML.rb +206 -0
- data/config/commands/Haskell.rb +48 -0
- data/config/commands/Hotkey.rb +50 -0
- data/config/commands/Hyperlink Helper.rb +81 -0
- data/config/commands/ImageBrowser.rb +10 -0
- data/config/commands/Io.rb +11 -0
- data/config/commands/JSFL.rb +29 -0
- data/config/commands/JSON.rb +11 -0
- data/config/commands/Java.rb +45 -0
- data/config/commands/JavaDoc.rb +12 -0
- data/config/commands/JavaScript Prototype & Script.aculo.us.rb +51 -0
- data/config/commands/JavaScript YUI.rb +12 -0
- data/config/commands/JavaScript jQuery.rb +12 -0
- data/config/commands/JavaScript.rb +50 -0
- data/config/commands/LaTeX.rb +423 -0
- data/config/commands/Lisp.rb +20 -0
- data/config/commands/Logo.rb +10 -0
- data/config/commands/Logtalk.rb +34 -0
- data/config/commands/Lua.rb +29 -0
- data/config/commands/MEL.rb +20 -0
- data/config/commands/Mail.rb +73 -0
- data/config/commands/Make.rb +20 -0
- data/config/commands/Man Pages.rb +20 -0
- data/config/commands/Markdown.rb +194 -0
- data/config/commands/Math.rb +79 -0
- data/config/commands/Matlab.rb +188 -0
- data/config/commands/Maven.rb +162 -0
- data/config/commands/Mediawiki.rb +12 -0
- data/config/commands/Mercurial.rb +185 -0
- data/config/commands/MoinMoin.rb +74 -0
- data/config/commands/Movable Type.rb +68 -0
- data/config/commands/Nemerle.rb +29 -0
- data/config/commands/OCaml Experimental Completions.rb +22 -0
- data/config/commands/OCaml.rb +99 -0
- data/config/commands/Objective-C.rb +181 -0
- data/config/commands/Outlines.rb +54 -0
- data/config/commands/PHP Smarty.rb +10 -0
- data/config/commands/Pascal.rb +11 -0
- data/config/commands/Perforce.rb +102 -0
- data/config/commands/Perl.rb +78 -0
- data/config/commands/Processing.rb +11 -0
- data/config/commands/Prolog.rb +11 -0
- data/config/commands/Property List.rb +38 -0
- data/config/commands/Python Django.rb +11 -0
- data/config/commands/Python.rb +131 -0
- data/config/commands/R Console (R.app).rb +80 -0
- data/config/commands/R Console (Rdaemon).rb +414 -0
- data/config/commands/R.rb +337 -0
- data/config/commands/Ragel.rb +10 -0
- data/config/commands/Regular Expressions.rb +18 -0
- data/config/commands/Remind.rb +44 -0
- data/config/commands/Ruby RSpec.rb +40 -0
- data/config/commands/Ruby on Rails.rb +331 -0
- data/config/commands/Ruby.rb +220 -0
- data/config/commands/S5 Slide Show.rb +37 -0
- data/config/commands/SCons.rb +24 -0
- data/config/commands/SQL.rb +60 -0
- data/config/commands/SVK.rb +83 -0
- data/config/commands/SWeave.rb +63 -0
- data/config/commands/Scheme.rb +30 -0
- data/config/commands/Scilab.rb +28 -0
- data/config/commands/Setext.rb +20 -0
- data/config/commands/Shell Script.rb +59 -0
- data/config/commands/Slate.rb +9 -0
- data/config/commands/Source.rb +84 -0
- data/config/commands/Standard ML.rb +38 -0
- data/config/commands/Subversion.rb +181 -0
- data/config/commands/TODO.rb +32 -0
- data/config/commands/Tcl.rb +21 -0
- data/config/commands/TerminalMate.rb +30 -0
- data/config/commands/Text.rb +137 -0
- data/config/commands/TextMate.rb +100 -0
- data/config/commands/Textile.rb +58 -0
- data/config/commands/Thrift.rb +20 -0
- data/config/commands/Transmit.rb +34 -0
- data/config/commands/Txt2tags.rb +213 -0
- data/config/commands/Vectorscript.rb +19 -0
- data/config/commands/Widget Creator.rb +23 -0
- data/config/commands/XML.rb +29 -0
- data/config/commands/Xcode.rb +106 -0
- data/config/commands/YAML.rb +39 -0
- data/config/commands/YARD.rb +12 -0
- data/config/commands/iTerm.rb +26 -0
- data/config/commands/reStructuredText.rb +126 -0
- data/config/detect.rb +13 -1
- data/config/keymap/diakonos.rb +113 -115
- data/config/keymap/emacs.rb +6 -2
- data/config/keymap/nano.rb +104 -112
- data/config/keymap/vim.rb +329 -258
- data/config/plugin/autosave.rb +3 -6
- data/config/plugin/git.rb +18 -12
- data/config/plugin/soma.rb +1 -1
- data/config/preferences/Apache.rb +17 -17
- data/config/preferences/AppleScript.rb +5 -5
- data/config/preferences/Bundle Development.rb +10 -10
- data/config/preferences/C.rb +38 -30
- data/config/preferences/CoffeeScript.rb +28 -0
- data/config/preferences/ColdFusion.rb +6 -6
- data/config/preferences/Cucumber.rb +40 -0
- data/config/preferences/Diff.rb +4 -4
- data/config/preferences/Eiffel.rb +6 -6
- data/config/preferences/Erlang.rb +16 -16
- data/config/preferences/F-Script.rb +12 -12
- data/config/preferences/FXScript.rb +5 -5
- data/config/preferences/Fortran.rb +17 -17
- data/config/preferences/Go.rb +23 -0
- data/config/preferences/Groovy.rb +29 -0
- data/config/preferences/HTML.rb +44 -44
- data/config/preferences/Haskell.rb +14 -14
- data/config/preferences/Io.rb +11 -11
- data/config/preferences/Java.rb +8 -8
- data/config/preferences/LaTeX.rb +24 -24
- data/config/preferences/Logo.rb +6 -6
- data/config/preferences/Logtalk.rb +5 -5
- data/config/preferences/Markdown.rb +43 -0
- data/config/preferences/Maven.rb +42 -42
- data/config/preferences/Mediawiki.rb +8 -8
- data/config/preferences/Movable Type.rb +14 -14
- data/config/preferences/OCaml.rb +15 -15
- data/config/preferences/Objective-C.rb +5 -5
- data/config/preferences/PHP.rb +2564 -0
- data/config/preferences/Property List.rb +8 -8
- data/config/preferences/R.rb +5 -5
- data/config/preferences/Ruby.rb +24 -24
- data/config/preferences/Source.rb +13 -13
- data/config/preferences/Standard ML.rb +9 -9
- data/config/preferences/Tcl.rb +5 -5
- data/config/preferences/Text.rb +14 -14
- data/config/preferences/TextMate.rb +5 -5
- data/config/preferences/Textile.rb +8 -8
- data/config/preferences/YARD.rb +9 -0
- data/config/preferences/iTerm.rb +9 -9
- data/config/rc.rb +5 -2
- data/config/snippets/ASP vb.NET.rb +203 -54
- data/config/snippets/ASP.rb +51 -36
- data/config/snippets/ActionScript.rb +332 -205
- data/config/snippets/Active4D.rb +325 -256
- data/config/snippets/Ada.rb +106 -60
- data/config/snippets/Ant.rb +7 -5
- data/config/snippets/Apache.rb +24 -20
- data/config/snippets/AppleScript.rb +213 -82
- data/config/snippets/Blogging.rb +41 -18
- data/config/snippets/Bulletin Board.rb +56 -21
- data/config/snippets/Bundle Development.rb +108 -63
- data/config/snippets/C++ Qt.rb +72 -57
- data/config/snippets/C.rb +128 -100
- data/config/snippets/CMake.rb +42 -32
- data/config/snippets/CSS.rb +515 -115
- data/config/snippets/CoffeeScript.rb +85 -0
- data/config/snippets/ColdFusion.rb +2228 -1547
- data/config/snippets/Context Free.rb +35 -28
- data/config/snippets/Cucumber.rb +55 -0
- data/config/snippets/D.rb +164 -111
- data/config/snippets/DokuWiki.rb +103 -54
- data/config/snippets/Doxygen.rb +87 -40
- data/config/snippets/Eiffel.rb +121 -18
- data/config/snippets/Erlang.rb +109 -68
- data/config/snippets/F-Script.rb +30 -24
- data/config/snippets/FXScript.rb +364 -210
- data/config/snippets/Fortran.rb +462 -280
- data/config/snippets/GTDAlt.rb +10 -4
- data/config/snippets/Gettext.rb +10 -8
- data/config/snippets/Go.rb +52 -0
- data/config/snippets/Greasemonkey.rb +52 -42
- data/config/snippets/Gri.rb +12 -10
- data/config/snippets/Groovy Grails.rb +313 -0
- data/config/snippets/Groovy.rb +685 -0
- data/config/snippets/HTML.rb +325 -126
- data/config/snippets/Haskell.rb +32 -24
- data/config/snippets/Io.rb +53 -42
- data/config/snippets/Java.rb +204 -92
- data/config/snippets/JavaDoc.rb +105 -56
- data/config/snippets/JavaScript MooTools.rb +208 -13
- data/config/snippets/JavaScript Objective-J.rb +18 -15
- data/config/snippets/JavaScript Prototype & Script.aculo.us.rb +362 -107
- data/config/snippets/JavaScript YUI.rb +1245 -186
- data/config/snippets/JavaScript jQuery.rb +693 -375
- data/config/snippets/JavaScript.rb +71 -53
- data/config/snippets/LaTeX.rb +188 -0
- data/config/snippets/Lisp.rb +59 -40
- data/config/snippets/Logo.rb +12 -6
- data/config/snippets/Logtalk.rb +131 -60
- data/config/snippets/Lua.rb +43 -33
- data/config/snippets/MIPS Assembler.rb +7 -5
- data/config/snippets/Mail.rb +10 -1
- data/config/snippets/Markdown.rb +7 -0
- data/config/snippets/Matlab.rb +232 -178
- data/config/snippets/Maven.rb +6 -5
- data/config/snippets/Mediawiki.rb +43 -12
- data/config/snippets/MoinMoin.rb +50 -10
- data/config/snippets/Movable Type.rb +368 -53
- data/config/snippets/Nemerle.rb +127 -79
- data/config/snippets/OCaml Code Completion Misc.rb +1716 -72
- data/config/snippets/OCaml Code Completion Unix.rb +2128 -203
- data/config/snippets/OCaml.rb +107 -73
- data/config/snippets/ODCompletion.rb +169 -118
- data/config/snippets/Objective-C.rb +281 -193
- data/config/snippets/PHP Smarty.rb +149 -79
- data/config/snippets/PHP.rb +186 -0
- data/config/snippets/Pascal.rb +47 -33
- data/config/snippets/Perl HTML-Template.rb +33 -0
- data/config/snippets/Perl Mason.rb +50 -30
- data/config/snippets/Perl Template Toolkit.rb +25 -20
- data/config/snippets/Perl.rb +91 -72
- data/config/snippets/Processing.rb +55 -33
- data/config/snippets/Propel.rb +36 -30
- data/config/snippets/Property List.rb +57 -24
- data/config/snippets/Python Django Templates.rb +381 -95
- data/config/snippets/Python Django.rb +159 -132
- data/config/snippets/Python.rb +88 -0
- data/config/snippets/R Console (Rdaemon).rb +11 -9
- data/config/snippets/R.rb +96 -77
- data/config/snippets/Remind.rb +18 -15
- data/config/snippets/Ruby RSpec.rb +343 -238
- data/config/snippets/Ruby on Rails.rb +1116 -765
- data/config/snippets/Ruby.rb +770 -545
- data/config/snippets/S5 Slide Show.rb +32 -24
- data/config/snippets/SSH Config.rb +21 -17
- data/config/snippets/SWIG.rb +30 -18
- data/config/snippets/Scilab.rb +98 -79
- data/config/snippets/Setext.rb +10 -8
- data/config/snippets/Shell Script.rb +52 -42
- data/config/snippets/Slate.rb +62 -48
- data/config/snippets/Source.rb +24 -1
- data/config/snippets/Standard ML.rb +37 -27
- data/config/snippets/Tcl.rb +32 -26
- data/config/snippets/Text.rb +28 -15
- data/config/snippets/Textile.rb +130 -45
- data/config/snippets/Thrift.rb +22 -18
- data/config/snippets/Twiki.rb +158 -105
- data/config/snippets/Txt2tags.rb +166 -79
- data/config/snippets/Vectorscript.rb +47 -38
- data/config/snippets/Widget Creator.rb +5 -5
- data/config/snippets/XML.rb +30 -18
- data/config/snippets/YAML.rb +5 -4
- data/config/snippets/YARD.rb +93 -0
- data/config/snippets/reStructuredText.rb +25 -20
- data/config/syntax/ANTLR.rb +17 -15
- data/config/syntax/ASP vb.NET.rb +27 -24
- data/config/syntax/ASP.rb +21 -19
- data/config/syntax/ActionScript.rb +16 -16
- data/config/syntax/Active4D Config.rb +5 -5
- data/config/syntax/Active4D Library.rb +2 -2
- data/config/syntax/Active4D.rb +32 -30
- data/config/syntax/Ada.rb +13 -10
- data/config/syntax/Ant.rb +9 -7
- data/config/syntax/Apache.rb +22 -18
- data/config/syntax/AppleScript.rb +486 -192
- data/config/syntax/AsciiDoc.rb +21 -0
- data/config/syntax/BibTeX.rb +7 -7
- data/config/syntax/Blog - HTML.rb +7 -7
- data/config/syntax/Blog - Markdown.rb +6 -6
- data/config/syntax/Blog - Text.rb +2 -2
- data/config/syntax/Blog - Textile.rb +2 -2
- data/config/syntax/Bulletin Board.rb +33 -32
- data/config/syntax/C++ Qt.rb +7 -6
- data/config/syntax/C++.rb +31 -28
- data/config/syntax/C.rb +55 -51
- data/config/syntax/CMake Listfile.rb +12 -11
- data/config/syntax/CSS.rb +24 -23
- data/config/syntax/CSV.rb +3 -3
- data/config/syntax/CoffeeScript.rb +161 -0
- data/config/syntax/ColdFusion.rb +8 -8
- data/config/syntax/Context Free.rb +18 -16
- data/config/syntax/Cucumber Steps.rb +108 -0
- data/config/syntax/D.rb +70 -69
- data/config/syntax/Diff.rb +13 -10
- data/config/syntax/DokuWiki.rb +22 -18
- data/config/syntax/Doxygen.rb +1 -1
- data/config/syntax/Dylan.rb +8 -8
- data/config/syntax/Eiffel.rb +12 -12
- data/config/syntax/Erlang.rb +96 -89
- data/config/syntax/F-Script.rb +11 -9
- data/config/syntax/FXScript.rb +16 -14
- data/config/syntax/Fortran - Modern.rb +25 -24
- data/config/syntax/Fortran - Punchcard.rb +43 -40
- data/config/syntax/GTD.rb +1 -1
- data/config/syntax/GTDalt.rb +14 -11
- data/config/syntax/Gettext.rb +10 -9
- data/config/syntax/Gherkin.rb +65 -0
- data/config/syntax/Go.rb +256 -0
- data/config/syntax/Grails Server Page.rb +108 -0
- data/config/syntax/Graphviz (DOT).rb +6 -6
- data/config/syntax/Greasemonkey.rb +3 -3
- data/config/syntax/Gri.rb +12 -12
- data/config/syntax/Groovy.rb +502 -0
- data/config/syntax/HTML (ASP).rb +3 -3
- data/config/syntax/HTML (ASP.net).rb +31 -31
- data/config/syntax/HTML (Active4D).rb +19 -19
- data/config/syntax/HTML (Django).rb +6 -6
- data/config/syntax/HTML (Erlang).rb +4 -4
- data/config/syntax/HTML (Mason).rb +13 -13
- data/config/syntax/HTML (Rails).rb +5 -5
- data/config/syntax/HTML (Tcl).rb +3 -3
- data/config/syntax/HTML (Template Toolkit).rb +9 -9
- data/config/syntax/HTML.rb +27 -27
- data/config/syntax/Haskell.rb +31 -28
- data/config/syntax/Inform.rb +5 -5
- data/config/syntax/Ini.rb +4 -4
- data/config/syntax/Installer Distribution Script.rb +19 -18
- data/config/syntax/Io.rb +17 -15
- data/config/syntax/JSFL.rb +7 -6
- data/config/syntax/Java Properties.rb +3 -3
- data/config/syntax/Java Server Page (JSP).rb +5 -4
- data/config/syntax/Java.rb +40 -33
- data/config/syntax/JavaDoc.rb +24 -22
- data/config/syntax/JavaScript (Rails).rb +1 -1
- data/config/syntax/JavaScript.rb +41 -34
- data/config/syntax/Javascript YUI.rb +109 -101
- data/config/syntax/LaTeX Beamer.rb +3 -3
- data/config/syntax/LaTeX Log.rb +3 -3
- data/config/syntax/LaTeX Memoir.rb +7 -5
- data/config/syntax/LaTeX Rdaemon.rb +1 -1
- data/config/syntax/LaTeX.rb +52 -47
- data/config/syntax/Language Grammar.rb +58 -55
- data/config/syntax/Lex-Flex.rb +13 -13
- data/config/syntax/Lighttpd.rb +7 -7
- data/config/syntax/Lisp.rb +6 -5
- data/config/syntax/Literate Haskell.rb +2 -2
- data/config/syntax/Logo.rb +4 -4
- data/config/syntax/Logtalk.rb +64 -49
- data/config/syntax/Lua.rb +12 -12
- data/config/syntax/MATLAB.rb +71 -70
- data/config/syntax/MEL.rb +16 -15
- data/config/syntax/MIPS Assembler.rb +11 -11
- data/config/syntax/MacPorts Portfile.rb +16 -15
- data/config/syntax/Mail.rb +5 -4
- data/config/syntax/Makefile.rb +3 -3
- data/config/syntax/Man.rb +2 -2
- data/config/syntax/Markdown.rb +440 -0
- data/config/syntax/Maven POM.rb +17 -16
- data/config/syntax/Mediawiki.rb +46 -46
- data/config/syntax/Modula-3.rb +7 -6
- data/config/syntax/MoinMoin.rb +16 -16
- data/config/syntax/MooTools.rb +75 -65
- data/config/syntax/Movable Type (MT only).rb +18 -18
- data/config/syntax/Movable Type.rb +20 -20
- data/config/syntax/MultiMarkdown.rb +35 -0
- data/config/syntax/Nemerle.rb +12 -12
- data/config/syntax/OCaml.rb +79 -71
- data/config/syntax/OCamllex.rb +14 -14
- data/config/syntax/OCamlyacc.rb +14 -12
- data/config/syntax/Objective-C++.rb +2 -2
- data/config/syntax/Objective-C.rb +76 -70
- data/config/syntax/Objective-J.rb +30 -29
- data/config/syntax/Octave.rb +27 -27
- data/config/syntax/OpenGL.rb +4 -4
- data/config/syntax/PHP.rb +1154 -0
- data/config/syntax/Pascal.rb +8 -8
- data/config/syntax/Perl HTML-Template.rb +5 -5
- data/config/syntax/Perl.rb +80 -76
- data/config/syntax/Plain Text.rb +5 -5
- data/config/syntax/Postscript.rb +6 -6
- data/config/syntax/Processing.rb +20 -20
- data/config/syntax/Prolog.rb +2 -2
- data/config/syntax/Property List.rb +50 -47
- data/config/syntax/Prototype & Script.aculo.us (JavaScript) Bracketed.rb +15 -13
- data/config/syntax/Prototype & Script.aculo.us (JavaScript).rb +9 -8
- data/config/syntax/Python Django.rb +6 -6
- data/config/syntax/Python.rb +94 -87
- data/config/syntax/Quake Style .cfg.rb +4 -4
- data/config/syntax/R Console (Rdaemon) Plain.rb +2 -2
- data/config/syntax/R Console (Rdaemon).rb +2 -2
- data/config/syntax/R.rb +21 -20
- data/config/syntax/RSpec.rb +15 -15
- data/config/syntax/Ragel.rb +14 -13
- data/config/syntax/Rd (R Documentation).rb +4 -4
- data/config/syntax/Regular Expressions (Oniguruma).rb +11 -10
- data/config/syntax/Regular Expressions (Python).rb +9 -9
- data/config/syntax/Release Notes.rb +7 -6
- data/config/syntax/Remind.rb +19 -17
- data/config/syntax/Rez.rb +10 -9
- data/config/syntax/Ruby Haml.rb +11 -11
- data/config/syntax/Ruby on Rails.rb +26 -24
- data/config/syntax/Ruby.rb +73 -71
- data/config/syntax/S5 Slide Show.rb +9 -9
- data/config/syntax/SQL.rb +29 -27
- data/config/syntax/SSH Config.rb +4 -4
- data/config/syntax/SWIG.rb +12 -11
- data/config/syntax/SWeave.rb +8 -7
- data/config/syntax/Scheme.rb +56 -54
- data/config/syntax/Scilab.rb +7 -6
- data/config/syntax/Setext.rb +14 -13
- data/config/syntax/Shell Script (Bash).rb +42 -42
- data/config/syntax/Slate.rb +24 -19
- data/config/syntax/Smarty.rb +11 -10
- data/config/syntax/Standard ML - CM.rb +2 -2
- data/config/syntax/Standard ML.rb +26 -23
- data/config/syntax/Strings File.rb +6 -6
- data/config/syntax/TSV.rb +2 -2
- data/config/syntax/Tcl.rb +10 -9
- data/config/syntax/TeX Math.rb +7 -6
- data/config/syntax/TeX.rb +7 -7
- data/config/syntax/Textile.rb +33 -27
- data/config/syntax/Thrift.rb +37 -29
- data/config/syntax/Twiki.rb +19 -18
- data/config/syntax/Txt2tags.rb +26 -23
- data/config/syntax/Vectorscript.rb +9 -7
- data/config/syntax/XML strict.rb +6 -4
- data/config/syntax/XML.rb +55 -30
- data/config/syntax/XSL.rb +5 -5
- data/config/syntax/YAML.rb +14 -12
- data/config/syntax/camlp4.rb +5 -5
- data/config/syntax/iCalendar.rb +3 -3
- data/config/syntax/jQuery (JavaScript).rb +9 -9
- data/config/syntax/mod_perl.rb +6 -6
- data/config/syntax/qmake Project file.rb +16 -15
- data/config/syntax/reStructuredText.rb +23 -21
- data/config/syntax/svn-commit.tmp.rb +5 -5
- data/lib/ver.rb +169 -85
- data/lib/ver/action.rb +39 -30
- data/lib/ver/buffer.rb +962 -144
- data/lib/ver/buffer/frame.rb +23 -0
- data/lib/ver/buffer/invalid_trailing_whitespace.rb +17 -0
- data/lib/ver/buffer/markup_underline_link.rb +30 -0
- data/lib/ver/buffer/matching_brace.rb +22 -0
- data/lib/ver/buffer/term.rb +1 -1
- data/lib/ver/clipboard.rb +107 -0
- data/lib/ver/digraphs.rb +1373 -0
- data/lib/ver/entry.rb +54 -43
- data/lib/ver/event.rb +335 -0
- data/lib/ver/exception_view.rb +3 -1
- data/lib/ver/executor.rb +7 -7
- data/lib/ver/executor/buffer.rb +4 -4
- data/lib/ver/executor/encoding.rb +19 -0
- data/lib/ver/executor/entry.rb +9 -9
- data/lib/ver/executor/fuzzy_file_finder.rb +1 -1
- data/lib/ver/executor/label.rb +2 -0
- data/lib/ver/executor/method.rb +2 -3
- data/lib/ver/help/describe_key.rb +44 -44
- data/lib/ver/hover_completion.rb +11 -6
- data/lib/ver/keymap.rb +68 -39
- data/lib/ver/layout/paned.rb +56 -44
- data/lib/ver/layout/toplevel.rb +68 -0
- data/lib/ver/layout/vim.rb +919 -0
- data/lib/ver/major_mode.rb +49 -49
- data/lib/ver/methods.rb +22 -25
- data/lib/ver/methods/basic.rb +49 -20
- data/lib/ver/methods/bookmark.rb +33 -33
- data/lib/ver/methods/clipboard.rb +186 -49
- data/lib/ver/methods/completion.rb +5 -5
- data/lib/ver/methods/control.rb +47 -66
- data/lib/ver/methods/delete.rb +5 -122
- data/lib/ver/methods/help.rb +2 -2
- data/lib/ver/methods/insert.rb +101 -29
- data/lib/ver/methods/layout.rb +62 -64
- data/lib/ver/methods/macro.rb +45 -0
- data/lib/ver/methods/move.rb +63 -349
- data/lib/ver/methods/nano.rb +99 -71
- data/lib/ver/methods/open.rb +8 -7
- data/lib/ver/methods/preview.rb +34 -14
- data/lib/ver/methods/save.rb +194 -163
- data/lib/ver/methods/search.rb +169 -81
- data/lib/ver/methods/search_and_replace.rb +62 -49
- data/lib/ver/methods/selection.rb +26 -54
- data/lib/ver/methods/snippet.rb +79 -54
- data/lib/ver/methods/undo.rb +12 -16
- data/lib/ver/minibuffer.rb +283 -134
- data/lib/ver/minor_mode.rb +36 -47
- data/lib/ver/mode_resolving.rb +71 -0
- data/lib/ver/platform.rb +41 -0
- data/lib/ver/plist.rb +16 -4
- data/lib/ver/register.rb +86 -0
- data/lib/ver/status.rb +44 -6
- data/lib/ver/status/battery.rb +1 -1
- data/lib/ver/status/buffer_position.rb +2 -2
- data/lib/ver/status/diakonos_position.rb +3 -3
- data/lib/ver/status/encoding.rb +1 -1
- data/lib/ver/status/filename.rb +1 -1
- data/lib/ver/status/label.rb +20 -20
- data/lib/ver/status/mode.rb +1 -1
- data/lib/ver/status/nano_help.rb +3 -14
- data/lib/ver/status/nano_position.rb +6 -6
- data/lib/ver/status/percent.rb +2 -2
- data/lib/ver/status/position.rb +2 -2
- data/lib/ver/status/short_filename.rb +1 -1
- data/lib/ver/status/syntax.rb +1 -1
- data/lib/ver/struct.rb +28 -0
- data/lib/ver/syntax/processor.rb +2 -1
- data/lib/ver/text.rb +48 -520
- data/lib/ver/text/end.rb +14 -0
- data/lib/ver/text/index.rb +16 -101
- data/lib/ver/text/insert.rb +138 -0
- data/lib/ver/text/mark.rb +559 -0
- data/lib/ver/text/position.rb +240 -0
- data/lib/ver/text/range.rb +74 -0
- data/lib/ver/text/selection.rb +402 -0
- data/lib/ver/text/selection/block.rb +69 -0
- data/lib/ver/text/selection/char.rb +93 -0
- data/lib/ver/text/selection/line.rb +64 -0
- data/lib/ver/text/tag.rb +322 -0
- data/lib/ver/undo.rb +109 -34
- data/lib/ver/vendor/eval_completer.rb +184 -0
- data/lib/ver/vendor/json_store.rb +23 -0
- data/lib/ver/vendor/open3.rb +729 -0
- data/lib/ver/vendor/pathname.rb +73 -0
- data/lib/ver/vendor/textpow.rb +1 -1
- data/lib/ver/version.rb +1 -1
- data/lib/ver/widget_event.rb +9 -5
- data/lib/ver/widget_major_mode.rb +69 -23
- data/spec/helper.rb +124 -8
- data/spec/ver/action.rb +160 -46
- data/spec/ver/buffer.rb +23 -0
- data/spec/ver/clipboard.rb +92 -0
- data/spec/ver/keymap.rb +63 -61
- data/spec/ver/keymap/diakonos.rb +88 -0
- data/spec/ver/keymap/emacs.rb +65 -0
- data/spec/ver/keymap/general.rb +98 -0
- data/spec/ver/keymap/nano.rb +84 -0
- data/spec/ver/keymap/vim.rb +205 -0
- data/spec/ver/keymap/vim/changing_text.rb +489 -0
- data/spec/ver/keymap/vim/complex_changes.rb +53 -0
- data/spec/ver/keymap/vim/copying_and_moving_text.rb +258 -0
- data/spec/ver/keymap/vim/deleting_text.rb +188 -0
- data/spec/ver/keymap/vim/digraphs.rb +52 -0
- data/spec/ver/keymap/vim/external_commands.rb +21 -0
- data/spec/ver/keymap/vim/inserting_mode_keys.rb +115 -0
- data/spec/ver/keymap/vim/inserting_mode_special.rb +168 -0
- data/spec/ver/keymap/vim/inserting_text.rb +108 -0
- data/spec/ver/keymap/vim/left_right_motion.rb +120 -0
- data/spec/ver/keymap/vim/mark_motion.rb +73 -0
- data/spec/ver/keymap/vim/repeating_commands.rb +64 -0
- data/spec/ver/keymap/vim/text_object_motion.rb +137 -0
- data/spec/ver/keymap/vim/text_objects.rb +101 -0
- data/spec/ver/keymap/vim/undo_redo.rb +21 -0
- data/spec/ver/keymap/vim/up_down_motion.rb +94 -0
- data/spec/ver/keymap/vim/various_motion.rb +33 -0
- data/spec/ver/keysyms.rb +13 -0
- data/spec/ver/major_mode.rb +37 -37
- data/spec/ver/minor_mode.rb +21 -20
- data/spec/ver/plugin/smart_autoindent.rb +2 -2
- data/spec/ver/text/index.rb +122 -0
- data/spec/ver/text/insert.rb +299 -0
- data/spec/ver/text/mark.rb +94 -0
- data/spec/ver/text/range.rb +71 -0
- data/spec/ver/text/selection.rb +315 -0
- data/spec/ver/text/tag.rb +93 -0
- data/spec/ver/undo.rb +133 -0
- data/spec/ver/undo/record_sanitize.rb +85 -0
- data/spec/ver/vendor/eval_completer.rb +91 -0
- data/spec/ver/widget_major_mode.rb +4 -3
- data/ver.gemspec +8 -8
- metadata +234 -72
- data/.todo +0 -102
- data/ROADMAP.textile +0 -187
- data/config/snippets/ANTLR.rb +0 -3
- data/config/snippets/Bison.rb +0 -3
- data/config/snippets/CTags.rb +0 -3
- data/config/snippets/CVS.rb +0 -3
- data/config/snippets/Darcs.rb +0 -3
- data/config/snippets/Diff.rb +0 -3
- data/config/snippets/Dylan.rb +0 -3
- data/config/snippets/Experimental Wiki.rb +0 -3
- data/config/snippets/Experimental.rb +0 -3
- data/config/snippets/FileMerge.rb +0 -3
- data/config/snippets/GTD2.rb +0 -3
- data/config/snippets/GetBundle.rb +0 -3
- data/config/snippets/Graphviz.rb +0 -3
- data/config/snippets/Hotkey.rb +0 -3
- data/config/snippets/Hyperlink Helper.rb +0 -3
- data/config/snippets/ImageBrowser.rb +0 -3
- data/config/snippets/Inform.rb +0 -3
- data/config/snippets/Ini.rb +0 -3
- data/config/snippets/Installer.rb +0 -3
- data/config/snippets/JSFL.rb +0 -3
- data/config/snippets/JSON.rb +0 -3
- data/config/snippets/Lex-Flex.rb +0 -3
- data/config/snippets/Lighttpd.rb +0 -3
- data/config/snippets/MEL.rb +0 -3
- data/config/snippets/MacPorts.rb +0 -3
- data/config/snippets/Make.rb +0 -3
- data/config/snippets/Man Pages.rb +0 -3
- data/config/snippets/Math.rb +0 -3
- data/config/snippets/Mercurial.rb +0 -3
- data/config/snippets/Modula.rb +0 -3
- data/config/snippets/Navigation.rb +0 -3
- data/config/snippets/OCaml Experimental Completions.rb +0 -3
- data/config/snippets/OpenGL.rb +0 -3
- data/config/snippets/Outlines.rb +0 -3
- data/config/snippets/Perforce.rb +0 -3
- data/config/snippets/Perl HTML::Template.rb +0 -27
- data/config/snippets/Postscript.rb +0 -3
- data/config/snippets/Prolog.rb +0 -3
- data/config/snippets/Quake.rb +0 -3
- data/config/snippets/R Console (R.app).rb +0 -3
- data/config/snippets/Ragel.rb +0 -3
- data/config/snippets/Regular Expressions.rb +0 -3
- data/config/snippets/Rez.rb +0 -3
- data/config/snippets/Ruby Haml.rb +0 -3
- data/config/snippets/SCons.rb +0 -3
- data/config/snippets/SQL.rb +0 -3
- data/config/snippets/SVK.rb +0 -3
- data/config/snippets/SWeave.rb +0 -3
- data/config/snippets/Scheme.rb +0 -3
- data/config/snippets/Subversion.rb +0 -3
- data/config/snippets/TODO.rb +0 -3
- data/config/snippets/Tabular.rb +0 -3
- data/config/snippets/TerminalMate.rb +0 -3
- data/config/snippets/TextMate.rb +0 -3
- data/config/snippets/Transmit.rb +0 -3
- data/config/snippets/Xcode.rb +0 -3
- data/config/snippets/iCalendar.rb +0 -3
- data/config/snippets/iTerm.rb +0 -3
- data/lib/ver/keysyms.rb +0 -104
- data/spec/ver/methods/move.rb +0 -150
data/lib/ver/action.rb
CHANGED
@@ -1,43 +1,52 @@
|
|
1
1
|
module VER
|
2
|
-
class Action < Struct.new(:
|
3
|
-
def initialize(receiver = nil, method = nil, args = [], &block)
|
4
|
-
self.receiver = receiver
|
5
|
-
self.method = method || :call
|
6
|
-
self.args = args
|
7
|
-
self.block = block
|
8
|
-
self.last = [self.receiver, self.method, self.args]
|
9
|
-
end
|
10
|
-
|
2
|
+
class Action < Struct.new(:invocation, :handler, :mode)
|
11
3
|
def call(widget, *given_args)
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
self.last = [widget.tk_pathname, method, widget, args]
|
23
|
-
widget.send(method, widget, *args)
|
24
|
-
end
|
4
|
+
case handler
|
5
|
+
when Symbol
|
6
|
+
widget.send(handler).send(*invocation, *given_args)
|
7
|
+
when Module
|
8
|
+
method, *args = *invocation
|
9
|
+
handler.send(method, widget, *args, *given_args)
|
10
|
+
when nil
|
11
|
+
widget.send(*invocation, *given_args)
|
12
|
+
else
|
13
|
+
raise ArgumentError
|
25
14
|
end
|
26
15
|
rescue => ex
|
27
|
-
|
28
|
-
|
16
|
+
VER.error("Exception from %p" % [self])
|
17
|
+
VER.error(ex)
|
29
18
|
end
|
30
19
|
|
31
20
|
def combine(action)
|
32
|
-
|
33
|
-
self.class.new(
|
21
|
+
invocation = [*self.invocation, action]
|
22
|
+
self.class.new(invocation, handler, mode)
|
34
23
|
end
|
35
24
|
|
36
|
-
def
|
37
|
-
|
38
|
-
|
25
|
+
def to_proc
|
26
|
+
Proc.new{|widget, *args| call(widget, *args) }
|
27
|
+
end
|
39
28
|
|
40
|
-
|
29
|
+
def to_method(widget)
|
30
|
+
case handler
|
31
|
+
when Symbol
|
32
|
+
method = [*invocation].first
|
33
|
+
widget.send(handler).method(method)
|
34
|
+
when Module
|
35
|
+
method, *args = *invocation
|
36
|
+
handler.method(method)
|
37
|
+
when nil
|
38
|
+
method = [*invocation].first
|
39
|
+
widget.method(method)
|
40
|
+
else
|
41
|
+
raise ArgumentError
|
42
|
+
end
|
41
43
|
end
|
44
|
+
|
45
|
+
def to_a
|
46
|
+
[mode, self]
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
class Fallback < Action
|
42
51
|
end
|
43
52
|
end
|
data/lib/ver/buffer.rb
CHANGED
@@ -1,229 +1,1047 @@
|
|
1
1
|
module VER
|
2
|
-
class Buffer <
|
3
|
-
|
2
|
+
class Buffer < Text
|
3
|
+
include Keymapped
|
4
|
+
extend Forwardable
|
4
5
|
|
5
|
-
|
6
|
-
|
6
|
+
autoload :Frame, 'ver/buffer/frame'
|
7
|
+
autoload :InvalidTrailingWhitespace, 'ver/buffer/invalid_trailing_whitespace'
|
8
|
+
autoload :MarkupUnderlineLink, 'ver/buffer/markup_underline_link'
|
9
|
+
autoload :MatchingBrace, 'ver/buffer/matching_brace'
|
10
|
+
|
11
|
+
OPTIONS = {
|
12
|
+
autoseparators: false,
|
13
|
+
background: '#000',
|
14
|
+
blockcursor: false,
|
15
|
+
borderwidth: 0,
|
16
|
+
exportselection: true, # provide selection to X automatically
|
17
|
+
foreground: '#fff', # when first showing, it's not highlighted...
|
18
|
+
highlightbackground: '#000', # this specifies the colors
|
19
|
+
highlightcolor: '#fff', # that are used when the widget
|
20
|
+
highlightthickness: 1, # has input focus.
|
21
|
+
insertbackground: '#fff',
|
22
|
+
relief: :solid,
|
23
|
+
setgrid: false,
|
24
|
+
tabstyle: :wordprocessor,
|
25
|
+
takefocus: true,
|
26
|
+
undo: false,
|
27
|
+
wrap: :word
|
28
|
+
}
|
29
|
+
|
30
|
+
MODE_STYLES = {
|
31
|
+
:control => {blockcursor: false},
|
32
|
+
:insert => {blockcursor: false, insertbackground: 'red'},
|
33
|
+
/select/ => {blockcursor: true, insertbackground: 'yellow'},
|
34
|
+
/replace/ => {blockcursor: true, insertbackground: 'orange'},
|
35
|
+
}
|
36
|
+
|
37
|
+
TAG_ALL_MATCHING_OPTIONS = { from: '1.0', to: 'end - 1 chars' }
|
38
|
+
|
39
|
+
PROJECT_DIRECTORY_GLOB = '{.git/,.hg/,_darcs/,_FOSSIL_}'
|
40
|
+
|
41
|
+
MODELINES = {
|
42
|
+
/\s+(?:ver|vim?|ex):\s*.*$/ => /\s+(?:ver|vim?|ex):\s*(.*)$/,
|
43
|
+
/\s+(?:ver|vim?|ex):[^:]+:/ => /\s+(?:ver|vim?|ex):([^:]+):/,
|
44
|
+
/^(?:ver|vim?):[^:]+:/ => /^(?:ver|vim?):([^:]+):/,
|
45
|
+
}
|
46
|
+
|
47
|
+
REPEAT_BREAK_CMD = [
|
48
|
+
:repeat_action,
|
49
|
+
:undo,
|
50
|
+
:redo,
|
51
|
+
]
|
52
|
+
|
53
|
+
REPEAT_BREAK_MODE = [
|
54
|
+
:move,
|
55
|
+
:search,
|
56
|
+
]
|
57
|
+
|
58
|
+
None = Object.new
|
59
|
+
|
60
|
+
def self.[](uri, line = nil, char = nil)
|
61
|
+
find_or_create(uri, line, char)
|
7
62
|
end
|
8
63
|
|
9
|
-
def self.create(path = nil, line = nil,
|
64
|
+
def self.create(path = nil, line = nil, char = nil)
|
10
65
|
VER.layout.create_buffer do |buffer|
|
11
|
-
|
12
|
-
when nil
|
13
|
-
buffer.open_empty
|
14
|
-
when Symbol
|
15
|
-
buffer.open_symbolic(path, line, column)
|
16
|
-
when Pathname
|
17
|
-
buffer.open_path(path, line, column)
|
18
|
-
else
|
19
|
-
raise ArgumentError, "invalid path: %p" % [path]
|
20
|
-
end
|
21
|
-
|
22
|
-
VER.buffers[buffer.name] = buffer
|
66
|
+
buffer.open(path, line, char)
|
23
67
|
yield(buffer) if block_given?
|
24
68
|
buffer
|
25
69
|
end
|
26
70
|
end
|
27
71
|
|
28
|
-
def self.find_or_create(
|
29
|
-
case
|
72
|
+
def self.find_or_create(uri, line = nil, char = nil, &block)
|
73
|
+
case uri
|
30
74
|
when Pathname, Symbol
|
31
|
-
if buffer = VER.buffers
|
32
|
-
buffer.
|
75
|
+
if buffer = VER.buffers.find{|buf| buf.uri == uri }
|
76
|
+
buffer.show
|
77
|
+
buffer.focus
|
78
|
+
buffer.at_insert.go_line_char(line, char)
|
79
|
+
yield buffer if block_given?
|
80
|
+
buffer
|
33
81
|
else
|
34
|
-
create(
|
82
|
+
create(uri, line, char, &block)
|
35
83
|
end
|
36
84
|
when String
|
37
|
-
path = Pathname(
|
38
|
-
find_or_create(path, line,
|
85
|
+
path = Pathname(uri.to_str).expand_path
|
86
|
+
find_or_create(path, line, char, &block)
|
39
87
|
else
|
40
88
|
raise ArgumentError, "Invalid path: %p" % [path]
|
41
89
|
end
|
42
90
|
end
|
43
91
|
|
44
|
-
attr_reader :
|
92
|
+
attr_reader :frame, :status, :options, :at_current, :at_insert, :at_end,
|
93
|
+
:theme_config, :matching_brace, :layout, :syntax, :minibuf,
|
94
|
+
:snippets
|
95
|
+
attr_accessor :uri, :project_root, :project_repo, :undoer, :pristine,
|
96
|
+
:prefix_arg, :readonly, :encoding, :filename, :at_sel,
|
97
|
+
:symbolic, :locked, :register, :skip_prefix_count_once
|
45
98
|
|
46
|
-
|
47
|
-
|
48
|
-
options[:style] ||= VER.obtain_style_name('Buffer', 'TFrame')
|
49
|
-
super
|
99
|
+
# Hack for smoother minibuf completion
|
100
|
+
public :binding, :local_variables, :global_variables
|
50
101
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
setup(peer)
|
102
|
+
alias pristine? pristine
|
103
|
+
alias symbolic? symbolic
|
104
|
+
alias locked? locked
|
55
105
|
|
56
|
-
|
57
|
-
|
106
|
+
def initialize(parent = VER.layout, given_options = {})
|
107
|
+
@layout = parent
|
108
|
+
@frame = Frame.new(parent, self)
|
109
|
+
|
110
|
+
font, tabstop = VER.options.font, VER.options.tabstop
|
111
|
+
tabs = font.measure('0') * tabstop
|
112
|
+
|
113
|
+
default_options = OPTIONS.merge(
|
114
|
+
font: font,
|
115
|
+
insertofftime: VER.options.insertofftime,
|
116
|
+
insertontime: VER.options.insertontime,
|
117
|
+
tabs: tabs
|
118
|
+
)
|
58
119
|
|
59
|
-
|
60
|
-
|
61
|
-
|
120
|
+
super(frame, default_options.merge(given_options))
|
121
|
+
|
122
|
+
setup
|
62
123
|
end
|
63
124
|
|
64
|
-
|
65
|
-
|
66
|
-
# | | y |
|
67
|
-
# | @text | b |
|
68
|
-
# | | a |
|
69
|
-
# | | r |
|
70
|
-
# +-------+---+
|
71
|
-
# | @xbar | |
|
72
|
-
# +-------+---+
|
73
|
-
# | @status |
|
74
|
-
# +-----------+
|
75
|
-
def setup(peer)
|
76
|
-
setup_widgets(peer)
|
77
|
-
setup_grid
|
125
|
+
def setup
|
126
|
+
setup_tags
|
78
127
|
setup_misc
|
128
|
+
setup_widgets
|
129
|
+
setup_layout
|
130
|
+
setup_binds
|
131
|
+
layout.bind('<Map>'){ Tk.update }
|
132
|
+
end
|
133
|
+
|
134
|
+
def setup_widgets
|
135
|
+
@status = Status.new(frame, self)
|
136
|
+
@minibuf = VER.minibuf.peer_create(frame, self)
|
137
|
+
|
138
|
+
if options.horizontal_scrollbar
|
139
|
+
@xbar = Tk::Tile::XScrollbar.new(frame)
|
140
|
+
xscrollbar(@xbar)
|
141
|
+
end
|
142
|
+
|
143
|
+
if options.vertical_scrollbar
|
144
|
+
@ybar = Tk::Tile::YScrollbar.new(frame)
|
145
|
+
yscrollbar(@ybar)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
def setup_layout
|
150
|
+
self. grid_configure row: 0, column: 0, sticky: :nsew
|
151
|
+
@ybar. grid_configure row: 0, column: 1, sticky: :ns if @ybar
|
152
|
+
@xbar. grid_configure row: 1, column: 0, sticky: :ew if @xbar
|
153
|
+
status. grid_configure row: 2, column: 0, sticky: :ew
|
154
|
+
@minibuf.grid_configure row: 3, column: 0, sticky: :ew
|
155
|
+
|
156
|
+
frame.grid_columnconfigure 0, weight: 1
|
157
|
+
frame.grid_columnconfigure 1, weight: 0
|
158
|
+
frame.grid_rowconfigure 0, weight: 1
|
159
|
+
frame.grid_rowconfigure 1, weight: 0
|
160
|
+
frame.grid_rowconfigure 2, weight: 0
|
161
|
+
frame.grid_rowconfigure 3, weight: 0
|
79
162
|
end
|
80
163
|
|
81
|
-
def
|
82
|
-
|
83
|
-
|
164
|
+
def setup_misc
|
165
|
+
@store_hash = Hash.new{|h,k| h[k] = {} }
|
166
|
+
@options = Options.new(:text, VER.options)
|
167
|
+
@at_current = Mark.new(self, :current)
|
168
|
+
@at_insert = Insert.new(self)
|
169
|
+
@at_end = End.new(self)
|
170
|
+
@at_sel = Selection::Char.new(self, false)
|
171
|
+
@theme_config = nil
|
172
|
+
@highlighter = nil
|
173
|
+
@pristine = true
|
174
|
+
self.register = Register['*']
|
175
|
+
self.major_mode = :Fundamental
|
176
|
+
end
|
177
|
+
|
178
|
+
def setup_binds
|
179
|
+
bind('<<EnterMinorMode>>', &method(:on_enter_minor_mode))
|
180
|
+
bind('<<Modified>>', &method(:on_modified))
|
181
|
+
bind('<<Movement>>', &method(:on_movement))
|
182
|
+
bind('<FocusIn>', &method(:on_focus_in))
|
183
|
+
bind('<FocusOut>', &method(:on_focus_out))
|
184
|
+
bind('<Destroy>', &method(:on_destroy))
|
185
|
+
end
|
186
|
+
|
187
|
+
def setup_tags
|
188
|
+
@invalid_trailing_whitespace = InvalidTrailingWhitespace.new(self)
|
189
|
+
@markup_underline_link = MarkupUnderlineLink.new(self)
|
190
|
+
@matching_brace = MatchingBrace.new(self)
|
191
|
+
end
|
192
|
+
|
193
|
+
def on_enter_minor_mode(event)
|
194
|
+
sync_mode_status
|
195
|
+
sync_mode_style(event.detail)
|
196
|
+
end
|
197
|
+
|
198
|
+
def on_modified(event)
|
199
|
+
on_movement(event)
|
200
|
+
end
|
201
|
+
|
202
|
+
def on_movement(event)
|
203
|
+
at_insert.see
|
204
|
+
at_sel.refresh
|
205
|
+
@matching_brace.refresh
|
206
|
+
sync_position_status
|
207
|
+
end
|
208
|
+
|
209
|
+
def on_focus_in(event)
|
210
|
+
if @minibuf.asking
|
211
|
+
@minibuf.focus
|
84
212
|
else
|
85
|
-
|
213
|
+
Dir.chdir(filename.dirname.to_s) if filename && options.auto_chdir
|
214
|
+
on_movement(event)
|
86
215
|
end
|
87
216
|
|
88
|
-
|
89
|
-
setup_horizontal_scrollbar if VER.options.horizontal_scrollbar
|
90
|
-
setup_status
|
217
|
+
Tk.callback_break
|
91
218
|
end
|
92
219
|
|
93
|
-
def
|
94
|
-
|
220
|
+
def on_focus_out(event)
|
221
|
+
Tk.callback_break
|
95
222
|
end
|
96
223
|
|
97
|
-
def
|
98
|
-
|
99
|
-
|
224
|
+
def on_destroy(event)
|
225
|
+
@lock = true
|
226
|
+
frame.destroy
|
227
|
+
VER.cancel_block(@highlighter)
|
228
|
+
VER.buffers.delete(self)
|
229
|
+
unlock_uri(uri)
|
230
|
+
ensure
|
231
|
+
VER.defer{ VER.exit if VER.buffers.empty? }
|
232
|
+
end
|
100
233
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
)
|
234
|
+
# This has to be called _before_ <Destroy> is received, otherwise the Buffer
|
235
|
+
# is half-dead.
|
236
|
+
def persist_info
|
237
|
+
file = VER.loadpath.first/'buffer_info.json'
|
238
|
+
l "Persisting Buffer info into: #{file}"
|
239
|
+
|
240
|
+
JSON::Store.new(file.to_s, true).transaction do |buffer_info|
|
241
|
+
syntax_name = @syntax.name if @syntax
|
242
|
+
|
243
|
+
buffer_info[uri.to_s] = {
|
244
|
+
'insert' => index('insert').to_s,
|
245
|
+
'syntax' => syntax_name
|
246
|
+
}
|
247
|
+
end
|
116
248
|
end
|
117
249
|
|
118
|
-
def
|
119
|
-
|
120
|
-
|
250
|
+
def load_info
|
251
|
+
file = VER.loadpath.first/'buffer_info.json'
|
252
|
+
l "Loading Buffer info from: #{file}"
|
253
|
+
JSON::Store.new(file.to_s, true).transaction do |buffer_info|
|
254
|
+
if info = buffer_info[uri.to_s]
|
255
|
+
return info
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
return {}
|
121
260
|
end
|
122
261
|
|
123
|
-
def
|
124
|
-
|
125
|
-
@text.xscrollbar(@xbar)
|
262
|
+
def sync_mode_status
|
263
|
+
status.event :mode
|
126
264
|
end
|
127
265
|
|
128
|
-
def
|
129
|
-
|
266
|
+
def sync_position_status
|
267
|
+
status.event :position, :percent
|
130
268
|
end
|
131
269
|
|
132
|
-
def
|
133
|
-
|
134
|
-
|
135
|
-
@xbar.grid_configure row: 1, column: 0, sticky: :ew if @xbar
|
136
|
-
@status.grid_configure row: 2, column: 0, sticky: :ew, columnspan: 2 if @status
|
270
|
+
def sync_encoding_status
|
271
|
+
status.event :encoding
|
272
|
+
end
|
137
273
|
|
138
|
-
|
139
|
-
|
140
|
-
grid_rowconfigure 0, weight: 1
|
141
|
-
grid_rowconfigure 1, weight: 0
|
142
|
-
grid_rowconfigure 2, weight: 0
|
274
|
+
def sync_percent_status
|
275
|
+
status.event :percent
|
143
276
|
end
|
144
277
|
|
145
|
-
def
|
146
|
-
|
147
|
-
|
278
|
+
def sync_mode_style(given_mode = nil)
|
279
|
+
config = (theme_config || {}).merge(blockcursor: false)
|
280
|
+
|
281
|
+
modes = given_mode ? [given_mode] : major_mode.minors
|
282
|
+
|
283
|
+
modes.each do |mode|
|
284
|
+
mode = MinorMode[mode]
|
285
|
+
|
286
|
+
MODE_STYLES.each do |pattern, style|
|
287
|
+
config.merge!(style) if pattern === mode.name
|
288
|
+
end
|
289
|
+
end
|
290
|
+
|
291
|
+
configure(config)
|
292
|
+
return unless status && color = config[:insertbackground]
|
293
|
+
|
294
|
+
status.style = {
|
295
|
+
background: cget(:background),
|
296
|
+
foreground: color,
|
297
|
+
}
|
148
298
|
end
|
149
299
|
|
150
|
-
def
|
151
|
-
|
300
|
+
def events
|
301
|
+
major_mode.event_history
|
152
302
|
end
|
153
303
|
|
154
|
-
def
|
155
|
-
|
304
|
+
def actions
|
305
|
+
major_mode.action_history
|
156
306
|
end
|
157
307
|
|
158
|
-
def
|
159
|
-
|
308
|
+
def message(*args)
|
309
|
+
@minibuf.message(*args)
|
160
310
|
end
|
161
311
|
|
162
|
-
def
|
163
|
-
|
312
|
+
def warn(*args)
|
313
|
+
@minibuf.warn(*args)
|
164
314
|
end
|
165
315
|
|
166
|
-
def
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
316
|
+
def persisted?
|
317
|
+
return false unless filename
|
318
|
+
return false unless filename.file?
|
319
|
+
require 'digest/md5'
|
320
|
+
|
321
|
+
on_disk = Digest::MD5.hexdigest(filename.read)
|
322
|
+
in_memory = Digest::MD5.hexdigest(value)
|
323
|
+
on_disk == in_memory
|
172
324
|
end
|
173
325
|
|
174
|
-
def
|
175
|
-
|
176
|
-
text.mark_set(:insert, "#{line || insert.y}.#{column || insert.x}")
|
326
|
+
def type(string)
|
327
|
+
major_mode.fake(string)
|
177
328
|
end
|
178
329
|
|
179
|
-
def
|
180
|
-
|
181
|
-
|
330
|
+
def short_filename
|
331
|
+
if filename
|
332
|
+
if root = @project_root
|
333
|
+
filename.relative_path_from(root).to_s
|
334
|
+
else
|
335
|
+
filename.sub(Dir.pwd + '/', '').to_s
|
336
|
+
end
|
337
|
+
elsif uri
|
338
|
+
uri.to_s
|
182
339
|
end
|
183
340
|
end
|
184
341
|
|
185
|
-
def
|
186
|
-
|
187
|
-
|
342
|
+
def filename=(path)
|
343
|
+
@filename = Pathname(path.to_s).expand_path
|
344
|
+
status.event :filename if status
|
345
|
+
end
|
346
|
+
|
347
|
+
def encoding=(enc)
|
348
|
+
@encoding = enc
|
349
|
+
status.event :encoding if enc && status
|
350
|
+
end
|
351
|
+
|
352
|
+
def name=(name)
|
353
|
+
@name = name
|
354
|
+
status.event :filename if status
|
355
|
+
end
|
356
|
+
|
357
|
+
def syntax=(syn)
|
358
|
+
@syntax = syn
|
359
|
+
status.event :syntax if syn && status
|
360
|
+
end
|
361
|
+
|
362
|
+
def insert=(position)
|
363
|
+
at_insert.index = position
|
364
|
+
end
|
365
|
+
|
366
|
+
def delete(*indices)
|
367
|
+
return super unless undoer
|
368
|
+
|
369
|
+
undo_record do |record|
|
370
|
+
record.delete(*indices)
|
371
|
+
end
|
372
|
+
end
|
373
|
+
|
374
|
+
def replace(*args)
|
375
|
+
return super unless undoer
|
376
|
+
|
377
|
+
undo_record do |record|
|
378
|
+
record.replace(*args)
|
188
379
|
end
|
189
380
|
end
|
190
381
|
|
191
|
-
def
|
192
|
-
|
382
|
+
def insert(*args)
|
383
|
+
return super unless undoer
|
384
|
+
|
385
|
+
undo_record do |record|
|
386
|
+
record.insert(*args)
|
387
|
+
end
|
193
388
|
end
|
194
389
|
|
195
|
-
def
|
196
|
-
|
390
|
+
def open(uri, line = 1, char = 0)
|
391
|
+
case uri
|
392
|
+
when Symbol
|
393
|
+
open_symbolic(uri, line, char)
|
394
|
+
when Pathname
|
395
|
+
open_pathname(uri, line, char)
|
396
|
+
when String, URI
|
397
|
+
open_uri(uri, line, char)
|
398
|
+
else
|
399
|
+
raise ArgumentError, "Invalid uri: %p" % [uri]
|
400
|
+
end
|
401
|
+
|
402
|
+
true
|
197
403
|
end
|
198
404
|
|
199
|
-
def
|
200
|
-
|
201
|
-
|
405
|
+
def open_symbolic(symbol, line, char)
|
406
|
+
self.uri = symbol
|
407
|
+
self.symbolic = true
|
408
|
+
|
409
|
+
case symbol
|
410
|
+
when :Scratch
|
411
|
+
self.value = <<-TEXT
|
412
|
+
# This buffer is for notes you don't want to save, and for Ruby evaluation.
|
413
|
+
# If you want to create a file, visit that file with :o.
|
414
|
+
# then enter the text in that file's own buffer.
|
415
|
+
TEXT
|
416
|
+
syntax = 'Ruby'
|
417
|
+
when :Messages
|
418
|
+
clear
|
419
|
+
tag(:info).configure(foreground: '#aaf')
|
420
|
+
tag(:warn).configure(foreground: '#faa')
|
421
|
+
syntax = 'Plain Text'
|
422
|
+
when :Completions
|
423
|
+
clear
|
424
|
+
self.major_mode = :Completions
|
425
|
+
tag('ver.minibuf.completion').configure(foreground: '#fff')
|
426
|
+
syntax = 'Plain Text'
|
427
|
+
else
|
428
|
+
clear
|
429
|
+
syntax = 'Plain Text'
|
430
|
+
end
|
431
|
+
|
432
|
+
after_open(Syntax.new(syntax), line, char)
|
433
|
+
end
|
434
|
+
|
435
|
+
def open_pathname(pathname, line, char)
|
436
|
+
lock_uri(pathname) do |answer|
|
437
|
+
begin
|
438
|
+
case answer
|
439
|
+
when :single, :shared, :read_only
|
440
|
+
self.uri = self.filename = pathname
|
441
|
+
|
442
|
+
content, encoding = pathname.read_encoded_file
|
443
|
+
self.encoding = encoding
|
444
|
+
self.value = content.chomp
|
445
|
+
self.readonly = answer == :read_only || pathname.readonly?
|
446
|
+
self.locked = answer == :single
|
447
|
+
detect_project_paths
|
448
|
+
update_mtime
|
449
|
+
after_open(nil, line, char)
|
450
|
+
when :abort
|
451
|
+
close
|
452
|
+
:abort
|
453
|
+
when :quit
|
454
|
+
VER.exit
|
455
|
+
end
|
456
|
+
rescue Errno::ENOENT => ex
|
457
|
+
VER.error(ex)
|
458
|
+
open_empty(line, char)
|
459
|
+
end
|
460
|
+
end
|
461
|
+
end
|
462
|
+
|
463
|
+
def open_empty(line, char)
|
464
|
+
self.uri = '<empty>'
|
465
|
+
self.value = ''
|
466
|
+
self.encoding = value.encoding
|
467
|
+
self.readonly = false
|
468
|
+
after_open(nil, line, char)
|
469
|
+
end
|
470
|
+
|
471
|
+
def open_uri(uri, line, char)
|
472
|
+
self.uri = uri
|
473
|
+
self.value = Kernel.open(uri){|io| io.read.chomp }
|
474
|
+
after_open(nil, line, char)
|
475
|
+
end
|
476
|
+
|
477
|
+
def after_open(syntax = nil, line = nil, char = nil)
|
478
|
+
@undoer = VER::Undo::Tree.new(self)
|
479
|
+
VER.opened_file(self)
|
480
|
+
layout.wm_title = uri.to_s
|
481
|
+
|
482
|
+
info = load_info
|
483
|
+
|
484
|
+
if line || char
|
485
|
+
self.insert = "#{line || 1}.#{char || 0}"
|
486
|
+
else
|
487
|
+
self.insert = info['insert'] || '1.0'
|
488
|
+
end
|
489
|
+
|
490
|
+
VER.buffers << self
|
491
|
+
message "Opened #{uri}"
|
492
|
+
|
493
|
+
# Don't rely on the <Map> event, since it's prone to race-conditions.
|
494
|
+
finalize_open(syntax || info['syntax'])
|
495
|
+
rescue => ex
|
496
|
+
VER.error(ex)
|
497
|
+
end
|
498
|
+
|
499
|
+
def finalize_open(syntax)
|
500
|
+
VER.defer do
|
501
|
+
syntax ? setup_highlight_for(syntax) : setup_highlight
|
502
|
+
load_preferences
|
503
|
+
apply_modeline
|
504
|
+
end
|
505
|
+
bind('<Map>'){ at_insert.see }
|
506
|
+
end
|
507
|
+
|
508
|
+
def lock_uri(uri, &block)
|
509
|
+
lock = uri_lockfile(uri)
|
510
|
+
|
511
|
+
if lock.file? # omg, someone is using it!
|
512
|
+
info = Hash[lock.read.scan(/^(\w+):\s*(.*)$/)]
|
513
|
+
ctime = lock.ctime
|
514
|
+
pid = info['pid']
|
515
|
+
user = info['user']
|
516
|
+
uri = info['uri']
|
517
|
+
alive = info
|
518
|
+
|
519
|
+
prompt = <<-TEXT.chomp
|
520
|
+
Found a lock file at: #{lock}
|
521
|
+
owned by: #{user}
|
522
|
+
used by: #{pid}
|
523
|
+
dated: #{ctime}
|
524
|
+
for: #{uri}
|
525
|
+
|
526
|
+
Another program may be editing the same file.
|
527
|
+
If this is the case, be careful not to end up with two different instances of the same file when making changes.
|
528
|
+
Close this buffer or continue with caution.
|
529
|
+
|
530
|
+
[O]pen Read-Only, [E]dit anyway, [D]elete lock, [Q]uit, [A]bort:
|
531
|
+
TEXT
|
532
|
+
|
533
|
+
ask(prompt) do |answer, action|
|
534
|
+
case action
|
535
|
+
when :modified
|
536
|
+
case answer
|
537
|
+
when /o/i
|
538
|
+
yield :read_only
|
539
|
+
:abort
|
540
|
+
when /e/i
|
541
|
+
yield :shared
|
542
|
+
:abort
|
543
|
+
when /q/i
|
544
|
+
yield :quit
|
545
|
+
:abort
|
546
|
+
when /a/i
|
547
|
+
yield :abort
|
548
|
+
:abort
|
549
|
+
when /d/i
|
550
|
+
VER.defer do
|
551
|
+
lock.rm
|
552
|
+
lock_uri(uri, &block)
|
553
|
+
end
|
554
|
+
:abort
|
555
|
+
else
|
556
|
+
warn('invalid answer')
|
557
|
+
minibuf.answer = ''
|
558
|
+
end
|
559
|
+
end
|
560
|
+
end
|
561
|
+
else
|
562
|
+
File.open(lock, 'w+') do |file|
|
563
|
+
file.puts(
|
564
|
+
"pid: #{Process.pid}",
|
565
|
+
"uid: #{Process.uid}",
|
566
|
+
"uri: #{uri}"
|
567
|
+
)
|
568
|
+
end
|
569
|
+
|
570
|
+
yield :single
|
571
|
+
end
|
572
|
+
end
|
573
|
+
|
574
|
+
def unlock_uri(uri = self.uri)
|
575
|
+
return unless locked?
|
576
|
+
uri_lockfile(uri).rm_f
|
577
|
+
end
|
578
|
+
|
579
|
+
def uri_lockfile(uri = self.uri)
|
580
|
+
require 'tmpdir'
|
581
|
+
hash = Digest::SHA1.hexdigest(uri.to_s)
|
582
|
+
lock = Pathname.tmpdir/'ver/lock'/hash
|
583
|
+
lock.dirname.mkpath
|
584
|
+
lock
|
585
|
+
end
|
586
|
+
|
587
|
+
def update_mtime
|
588
|
+
store(:stat, :mtime, filename.mtime) if filename
|
589
|
+
rescue Errno::ENOENT
|
590
|
+
end
|
591
|
+
|
592
|
+
def detect_project_paths
|
593
|
+
return unless filename
|
594
|
+
parent = filename.expand_path.dirname
|
595
|
+
|
596
|
+
begin
|
597
|
+
(parent/PROJECT_DIRECTORY_GLOB).glob do |repo|
|
598
|
+
self.project_repo = repo
|
599
|
+
self.project_root = repo.dirname
|
600
|
+
return
|
601
|
+
end
|
602
|
+
|
603
|
+
parent = parent.dirname
|
604
|
+
end until parent.root?
|
605
|
+
end
|
606
|
+
|
607
|
+
def apply_modeline
|
608
|
+
MODELINES.each do |search_pattern, extract_pattern|
|
609
|
+
found = search(search_pattern, 1.0, :end, :count)
|
610
|
+
next if found.empty?
|
611
|
+
|
612
|
+
pos, count = found
|
613
|
+
line = get(pos, "#{pos} + #{count} chars")
|
614
|
+
|
615
|
+
line =~ extract_pattern
|
616
|
+
$1.scan(/[^:\s]+/) do |option|
|
617
|
+
apply_modeline_option(option)
|
618
|
+
end
|
619
|
+
end
|
620
|
+
end
|
621
|
+
|
622
|
+
def apply_modeline_option(option)
|
623
|
+
negative = option.gsub!(/^no/, '')
|
624
|
+
boolean = !negative
|
625
|
+
|
626
|
+
case option
|
627
|
+
when 'ai', 'autoindent'
|
628
|
+
set :autoindent, boolean
|
629
|
+
when 'et', 'expandtab'
|
630
|
+
set :expandtab, boolean
|
631
|
+
when /(?:tw|textwidth)=(\d+)/
|
632
|
+
set :textwidth, $1.to_i
|
633
|
+
when /(?:ts|tabstop)=(\d+)/
|
634
|
+
set :tabstop, $1.to_i
|
635
|
+
when /(?:sw|shiftwidth)=(\d+)/
|
636
|
+
set :shiftwidth, $1.to_i
|
637
|
+
when /(?:ft|filetype)=(\w+)/
|
638
|
+
set :filetype, $1
|
639
|
+
else
|
640
|
+
VER.warn "Unknown modeline: %p" % [option]
|
641
|
+
end
|
642
|
+
end
|
643
|
+
|
644
|
+
def set(option, value)
|
645
|
+
method = "set_#{option}"
|
646
|
+
|
647
|
+
if respond_to?(method)
|
648
|
+
if block_given?
|
649
|
+
__send__(method, value, &Proc.new)
|
650
|
+
else
|
651
|
+
__send__(method, value)
|
652
|
+
end
|
653
|
+
else
|
654
|
+
options[option] = value
|
655
|
+
yield(value) if block_given?
|
656
|
+
end
|
657
|
+
end
|
658
|
+
|
659
|
+
def set_filetype(type)
|
660
|
+
syntax = VER::Syntax.from_filename(Pathname("foo.#{type}"))
|
661
|
+
|
662
|
+
if load_syntax(syntax)
|
663
|
+
options.filetype = type
|
664
|
+
end
|
202
665
|
end
|
203
666
|
|
204
667
|
def hide
|
205
|
-
|
206
|
-
|
668
|
+
layout.hide
|
669
|
+
end
|
670
|
+
|
671
|
+
def show
|
672
|
+
layout.show
|
207
673
|
end
|
208
674
|
|
209
|
-
def
|
210
|
-
|
211
|
-
|
212
|
-
|
675
|
+
def close
|
676
|
+
may_close do
|
677
|
+
persist_info
|
678
|
+
layout.destroy
|
679
|
+
end
|
680
|
+
end
|
681
|
+
|
682
|
+
def touch!(*indices)
|
683
|
+
tag_add('ver.highlight.pending', *indices.flatten)
|
684
|
+
Tk::Event.generate(self, '<<Modified>>')
|
685
|
+
end
|
686
|
+
|
687
|
+
def undo
|
688
|
+
undoer.undo if undoer
|
689
|
+
end
|
690
|
+
|
691
|
+
def redo
|
692
|
+
undoer.redo if undoer
|
693
|
+
end
|
213
694
|
|
214
|
-
|
695
|
+
# Use this method in commands that do multiple insert, delete, replace
|
696
|
+
def undo_record(&block)
|
697
|
+
VER.warn "Buffer is Read-only" if readonly
|
698
|
+
undoer ? undoer.record_multi(&block) : yield(self)
|
215
699
|
ensure
|
216
|
-
|
217
|
-
VER.return_style_name(style_name)
|
700
|
+
self.pristine = false
|
218
701
|
end
|
219
702
|
|
220
|
-
def
|
221
|
-
|
222
|
-
|
703
|
+
def store(namespace, key, value = None)
|
704
|
+
if None == value
|
705
|
+
@store_hash[namespace][key]
|
706
|
+
else
|
707
|
+
@store_hash[namespace][key] = value
|
708
|
+
end
|
223
709
|
end
|
224
710
|
|
225
|
-
def
|
226
|
-
|
711
|
+
def change_register
|
712
|
+
major_mode.read(1) do |name|
|
713
|
+
if unicode = name.unicode
|
714
|
+
if unicode.empty?
|
715
|
+
warn "invalid name for register: %p" % [name]
|
716
|
+
else
|
717
|
+
self.register = Register[unicode]
|
718
|
+
end
|
719
|
+
else
|
720
|
+
warn "invalid name for register: %p" % [name]
|
721
|
+
end
|
722
|
+
end
|
723
|
+
end
|
724
|
+
|
725
|
+
def with_register
|
726
|
+
@with_register_level ||= 0
|
727
|
+
@with_register_level += 1
|
728
|
+
value = yield(register)
|
729
|
+
@with_register_level -= 1
|
730
|
+
ensure
|
731
|
+
self.register = Register['*'] if @with_register_level == 0
|
732
|
+
end
|
733
|
+
|
734
|
+
def update_prefix_arg
|
735
|
+
numbers = []
|
736
|
+
|
737
|
+
events.reverse_each do |event|
|
738
|
+
break unless event.keysym =~ /^(\d+)$/
|
739
|
+
numbers << $1
|
740
|
+
end
|
741
|
+
|
742
|
+
if numbers.any? && numbers != ['0']
|
743
|
+
self.prefix_arg = numbers.reverse.join.to_i
|
744
|
+
else
|
745
|
+
self.prefix_arg = nil
|
746
|
+
end
|
747
|
+
end
|
748
|
+
|
749
|
+
# Same as [prefix_arg], but returns 1 if there is no argument.
|
750
|
+
#
|
751
|
+
# The return value in case there is no argument can be changed by passing
|
752
|
+
# a +default+ argument.
|
753
|
+
#
|
754
|
+
# Useful for [Move] methods and the like.
|
755
|
+
# Please note that calling this method is destructive.
|
756
|
+
# It will reset the state of the prefix_arg in order to avoid persistent
|
757
|
+
# arguments.
|
758
|
+
# So use it only once while your action is running, and store the result in a
|
759
|
+
# variable if you need it more than once.
|
760
|
+
def prefix_count(default = 1)
|
761
|
+
if skip_prefix_count_once
|
762
|
+
self.skip_prefix_count_once = false
|
763
|
+
update_prefix_arg
|
764
|
+
return default
|
765
|
+
end
|
766
|
+
|
767
|
+
count = prefix_arg || default
|
768
|
+
update_prefix_arg
|
769
|
+
count
|
770
|
+
end
|
771
|
+
|
772
|
+
def repeat_action
|
773
|
+
stack = []
|
774
|
+
|
775
|
+
actions.reverse_each do |event, mode, action|
|
776
|
+
if stack.empty?
|
777
|
+
next if REPEAT_BREAK_CMD.include?(action.to_method(self).name)
|
778
|
+
next if REPEAT_BREAK_MODE.include?(mode.name)
|
779
|
+
else
|
780
|
+
break if REPEAT_BREAK_CMD.include?(action.to_method(self).name)
|
781
|
+
break if REPEAT_BREAK_MODE.include?(mode.name)
|
782
|
+
end
|
783
|
+
|
784
|
+
stack << [event, action]
|
785
|
+
end
|
786
|
+
|
787
|
+
return if stack.empty?
|
788
|
+
|
789
|
+
# make the argument the same for all called actions
|
790
|
+
prefix_arg = self.prefix_arg
|
791
|
+
|
792
|
+
stack.reverse_each do |event, action|
|
793
|
+
self.prefix_arg = prefix_arg
|
794
|
+
action.call(event)
|
795
|
+
end
|
796
|
+
end
|
797
|
+
|
798
|
+
def tag_exists?(given_path)
|
799
|
+
tag_names.include?(given_path)
|
800
|
+
rescue RuntimeError => ex
|
801
|
+
false
|
802
|
+
end
|
803
|
+
|
804
|
+
def tag_all_matching(name, regexp, options = {})
|
805
|
+
name = name.to_s
|
806
|
+
options = TAG_ALL_MATCHING_OPTIONS.merge(options)
|
807
|
+
from, to = options.values_at(:from, :to)
|
808
|
+
|
809
|
+
if tag_exists?(name)
|
810
|
+
tag_remove(name, from, to)
|
811
|
+
else
|
812
|
+
fg, bg = options.values_at(:foreground, :background)
|
813
|
+
tag_configure(name, foreground: fg, background: bg)
|
814
|
+
end
|
815
|
+
|
816
|
+
search_all(regexp, from, to) do |match, match_from, match_to|
|
817
|
+
name = yield(match, match_from, match_to) if block_given?
|
818
|
+
tag_add name, match_from, match_to
|
819
|
+
end
|
820
|
+
end
|
821
|
+
|
822
|
+
def search_all(regexp, start = '1.0', stop = 'end - 1 chars')
|
823
|
+
unless block_given?
|
824
|
+
return Enumerator.new(self, :search_all, regexp, start, stop)
|
825
|
+
end
|
826
|
+
|
827
|
+
while result = search(regexp, start, stop, :count)
|
828
|
+
pos, len = result
|
829
|
+
return if !pos || len == 0
|
830
|
+
|
831
|
+
from = index(pos)
|
832
|
+
to = index("#{pos} + #{len} chars")
|
833
|
+
match = get(from, to)
|
834
|
+
|
835
|
+
yield(match, from, to)
|
836
|
+
|
837
|
+
start = to
|
838
|
+
end
|
839
|
+
end
|
840
|
+
|
841
|
+
def rsearch_all(regexp, start = 'end', stop = '1.0')
|
842
|
+
unless block_given?
|
843
|
+
return Enumerator.new(self, :rsearch_all, regexp, start, stop)
|
844
|
+
end
|
845
|
+
|
846
|
+
while result = rsearch(regexp, start, stop, :count)
|
847
|
+
pos, len = result
|
848
|
+
break if !pos || len == 0
|
849
|
+
|
850
|
+
from = index(pos)
|
851
|
+
to = index("#{pos} + #{len} chars")
|
852
|
+
match = get(from, to)
|
853
|
+
|
854
|
+
yield(match, from, to)
|
855
|
+
|
856
|
+
start = from
|
857
|
+
end
|
858
|
+
end
|
859
|
+
|
860
|
+
# OK, finally found the issue.
|
861
|
+
#
|
862
|
+
# the implementation of tk::TextUpDownLine is smart, but not smart enough.
|
863
|
+
# It doesn't assume large deltas between the start of up/down movement and
|
864
|
+
# the last other modification of the insert mark.
|
865
|
+
#
|
866
|
+
# This means that, after scrolling with up/down for a few hundred lines, it
|
867
|
+
# has to calculate the amount of display lines in between, which is a very
|
868
|
+
# expensive calculation and time increases O(delta_lines).
|
869
|
+
#
|
870
|
+
# We'll try to solve this another way, by assuming that there are at least a
|
871
|
+
# few other lines of same or greater length in between, we simply compare
|
872
|
+
# against a closer position and make delta_lines as small as possible.
|
873
|
+
#
|
874
|
+
#
|
875
|
+
# Now, if you go to, like column 100 of a line, and there is never a line as
|
876
|
+
# long for the rest of the file, the scrolling will still slow down a lot.
|
877
|
+
# This is an issue we can fix if we "forget" the @udl_pos_orig after a
|
878
|
+
# user-defined maximum delta (something around 200 should do), will
|
879
|
+
# implement that on demand.
|
880
|
+
def up_down_displayline(count)
|
881
|
+
insert = at_insert
|
882
|
+
|
883
|
+
@udl_pos_orig = insert if @udl_pos_prev != insert
|
884
|
+
|
885
|
+
lines = count(@udl_pos_orig, insert, :displaylines)
|
886
|
+
target = index("#@udl_pos_orig + #{lines + count} displaylines")
|
887
|
+
@udl_pos_prev = target
|
888
|
+
|
889
|
+
@udl_pos_orig = target if target.char == @udl_pos_orig.char
|
890
|
+
target
|
891
|
+
end
|
892
|
+
|
893
|
+
# This method goes up and down lines, not taking line wrapping into account.
|
894
|
+
# To go a line down, pass 1, to go one up -1, you get the idea.
|
895
|
+
# Tries to maintain the same char position across lines.
|
896
|
+
def up_down_line(count)
|
897
|
+
insert = at_insert
|
898
|
+
|
899
|
+
# if the last movement was not done by up_down_*, set new origin.
|
900
|
+
@udl_pos_orig = insert if @udl_pos_prev != insert
|
901
|
+
|
902
|
+
# count lines between origin and current insert position.
|
903
|
+
lines = count(@udl_pos_orig, insert, :lines)
|
904
|
+
# now get the target count lines below.
|
905
|
+
target = index("#@udl_pos_orig + #{lines + count} lines")
|
906
|
+
|
907
|
+
@udl_pos_prev = target
|
908
|
+
|
909
|
+
# if target has the same char pos as the previous one, use it as origin.
|
910
|
+
@udl_pos_orig = target if target.char == @udl_pos_orig.char
|
911
|
+
target
|
912
|
+
end
|
913
|
+
|
914
|
+
def setup_highlight
|
915
|
+
setup_highlight_for(Syntax.from_filename(filename)) if filename
|
916
|
+
end
|
917
|
+
|
918
|
+
def setup_highlight_for(syntax)
|
919
|
+
return if encoding == Encoding::BINARY
|
920
|
+
return unless syntax
|
921
|
+
syntax = Syntax.new(syntax) unless syntax.is_a?(Syntax)
|
922
|
+
|
923
|
+
self.syntax = syntax
|
924
|
+
VER.cancel_block(@highlighter)
|
925
|
+
|
926
|
+
interval = options.syntax_highlight_interval.to_int
|
927
|
+
@highlighter = VER.when_inactive_for(interval){
|
928
|
+
handle_pending_syntax_highlights
|
929
|
+
}
|
930
|
+
|
931
|
+
touch!('1.0', 'end')
|
932
|
+
handle_pending_syntax_highlights
|
933
|
+
|
934
|
+
sync_mode_status
|
935
|
+
end
|
936
|
+
|
937
|
+
def load_theme(name)
|
938
|
+
return unless syntax
|
939
|
+
return unless found = Theme.find(name)
|
940
|
+
|
941
|
+
syntax.theme = Theme.load(found)
|
942
|
+
touch!('1.0', 'end')
|
943
|
+
|
944
|
+
message "Theme #{found} loaded"
|
945
|
+
end
|
946
|
+
|
947
|
+
def load_syntax(name)
|
948
|
+
return false unless syntax
|
949
|
+
|
950
|
+
theme = syntax.theme
|
951
|
+
|
952
|
+
if name.is_a?(Syntax)
|
953
|
+
self.syntax = Syntax.new(name.name, theme)
|
954
|
+
elsif found = Syntax.find(name)
|
955
|
+
self.syntax = Syntax.new(name, theme)
|
956
|
+
else
|
957
|
+
return false
|
958
|
+
end
|
959
|
+
|
960
|
+
message "Syntax #{syntax.name} loaded"
|
961
|
+
end
|
962
|
+
|
963
|
+
def load_snippets
|
964
|
+
return unless syntax
|
965
|
+
|
966
|
+
name = syntax.name
|
967
|
+
return unless file = VER.find_in_loadpath("snippets/#{name}.rb")
|
968
|
+
@snippets = eval(file.read)
|
969
|
+
rescue Errno::ENOENT, TypeError => ex
|
970
|
+
VER.error(ex)
|
971
|
+
end
|
972
|
+
|
973
|
+
def load_preferences
|
974
|
+
return unless syntax
|
975
|
+
|
976
|
+
name = syntax.name
|
977
|
+
return unless file = VER.find_in_loadpath("preferences/#{name}.rb")
|
978
|
+
@preferences = eval(file.read)
|
979
|
+
apply_preferences
|
980
|
+
rescue Errno::ENOENT, TypeError => ex
|
981
|
+
VER.error(ex)
|
982
|
+
end
|
983
|
+
|
984
|
+
def apply_preferences
|
985
|
+
return unless @preferences
|
986
|
+
|
987
|
+
@preferences.each do |preference|
|
988
|
+
next unless preference[:name] == "Comments"
|
989
|
+
if settings = preference[:settings]
|
990
|
+
if shell_variables = settings[:shellVariables]
|
991
|
+
shell_variables.each do |variable|
|
992
|
+
name, value = variable.values_at(:name, :value)
|
993
|
+
ENV[name] = value
|
994
|
+
|
995
|
+
case name
|
996
|
+
when 'TM_COMMENT_START'
|
997
|
+
options.comment_line = value
|
998
|
+
end
|
999
|
+
end
|
1000
|
+
end
|
1001
|
+
end
|
1002
|
+
end
|
1003
|
+
end
|
1004
|
+
|
1005
|
+
def handle_pending_syntax_highlights
|
1006
|
+
ignore_tags = %w[ver.highlight.pending sel]
|
1007
|
+
|
1008
|
+
tag_ranges('ver.highlight.pending').each do |range|
|
1009
|
+
from, to = range.first, range.last
|
1010
|
+
|
1011
|
+
(tag_names(from) - ignore_tags).each do |tag_name|
|
1012
|
+
tag_from, _ = tag_prevrange(tag_name, from)
|
1013
|
+
from = tag_from if tag_from && from > tag_from
|
1014
|
+
end
|
1015
|
+
|
1016
|
+
(tag_names(to) - ignore_tags).each do |tag_name|
|
1017
|
+
_, tag_to = tag_nextrange(tag_name, to)
|
1018
|
+
to = tag_to if tag_to && to < tag_to
|
1019
|
+
end
|
1020
|
+
|
1021
|
+
from, to = index("#{from} linestart"), index("#{to} lineend")
|
1022
|
+
syntax.highlight(self, from.line - 1, from, to) if syntax
|
1023
|
+
@invalid_trailing_whitespace.refresh(from: from, to: to)
|
1024
|
+
@markup_underline_link.refresh(from: from, to: to)
|
1025
|
+
tag_remove('ver.highlight.pending', from, to)
|
1026
|
+
end
|
1027
|
+
end
|
1028
|
+
|
1029
|
+
def default_theme_config=(config)
|
1030
|
+
@theme_config = config
|
1031
|
+
sync_mode_style
|
1032
|
+
end
|
1033
|
+
|
1034
|
+
def ask(prompt, options = {}, &action)
|
1035
|
+
options[:caller] ||= self
|
1036
|
+
@minibuf.ask(prompt, options, &action)
|
1037
|
+
end
|
1038
|
+
|
1039
|
+
class HighlightPending < Tag
|
1040
|
+
NAME = 'ver.highlight.pending'.freeze
|
1041
|
+
|
1042
|
+
def initialize(buffer, name = NAME)
|
1043
|
+
super
|
1044
|
+
end
|
227
1045
|
end
|
228
1046
|
end
|
229
1047
|
end
|