ver 2009.10.14 → 2009.11.28
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +1094 -0
- data/MANIFEST +227 -25
- data/README.textile +185 -0
- data/bin/ver +96 -12
- data/config/detect.rb +73 -21
- data/config/keymap/emacs.rb +66 -0
- data/config/keymap/vim.rb +250 -140
- data/config/preferences/ANTLR.json +10 -0
- data/config/preferences/ASP vb.NET.json +3 -0
- data/config/preferences/ASP.json +15 -0
- data/config/preferences/ActionScript.json +755 -0
- data/config/preferences/Active4D.json +89 -0
- data/config/preferences/Ada.json +23 -0
- data/config/preferences/Ant.json +356 -0
- data/config/preferences/Apache.json +644 -0
- data/config/preferences/AppleScript.json +92 -0
- data/config/preferences/Bison.json +3 -0
- data/config/preferences/Blogging.json +3 -0
- data/config/preferences/C.json +127 -0
- data/config/preferences/CMake.json +41 -0
- data/config/preferences/CSS.json +461 -0
- data/config/preferences/CTags.json +3 -0
- data/config/preferences/CVS.json +3 -0
- data/config/preferences/ColdFusion.json +32 -0
- data/config/preferences/D.json +58 -0
- data/config/preferences/Darcs.json +3 -0
- data/config/preferences/Diff.json +67 -0
- data/config/preferences/DokuWiki.json +19 -0
- data/config/preferences/Doxygen.json +3 -0
- data/config/preferences/Dylan.json +3 -0
- data/config/preferences/Eiffel.json +59 -0
- data/config/preferences/Erlang.json +72 -0
- data/config/preferences/Experimental.json +1356 -0
- data/config/preferences/F-Script.json +87 -0
- data/config/preferences/FXScript.json +78 -0
- data/config/preferences/FileMerge.json +3 -0
- data/config/preferences/Fortran.json +158 -0
- data/config/preferences/GTD2.json +11 -0
- data/config/preferences/GTDAlt.json +20 -0
- data/config/preferences/GetBundle.json +3 -0
- data/config/preferences/Gettext.json +24 -0
- data/config/preferences/Graphviz.json +42 -0
- data/config/preferences/Greasemonkey.json +3 -0
- data/config/preferences/Gri.json +34 -0
- data/config/preferences/HTML.json +492 -0
- data/config/preferences/Haskell.json +72 -0
- data/config/preferences/Hotkey.json +3 -0
- data/config/preferences/ImageBrowser.json +3 -0
- data/config/preferences/Inform.json +3 -0
- data/config/preferences/Ini.json +60 -0
- data/config/preferences/Installer.json +3 -0
- data/config/preferences/Io.json +64 -0
- data/config/preferences/JSON.json +3 -0
- data/config/preferences/Java.json +86 -0
- data/config/preferences/JavaDoc.json +3 -0
- data/config/preferences/JavaScript.json +76 -0
- data/config/preferences/LaTeX.json +267 -0
- data/config/preferences/Lex/Flex.json +3 -0
- data/config/preferences/Lighttpd.json +3 -0
- data/config/preferences/LilyPond.json +77 -0
- data/config/preferences/Lisp.json +63 -0
- data/config/preferences/Logo.json +58 -0
- data/config/preferences/Logtalk.json +236 -0
- data/config/preferences/Lua.json +24 -0
- data/config/preferences/MEL.json +19 -0
- data/config/preferences/MIPS Assembler.json +26 -0
- data/config/preferences/MacPorts.json +3 -0
- data/config/preferences/Mail.json +3 -0
- data/config/preferences/Make.json +16 -0
- data/config/preferences/Markdown.json +102 -0
- data/config/preferences/Math.json +3 -0
- data/config/preferences/Matlab.json +128 -0
- data/config/preferences/Maven.json +308 -0
- data/config/preferences/Mediawiki.json +73 -0
- data/config/preferences/Mercurial.json +3 -0
- data/config/preferences/Modula.json +37 -0
- data/config/preferences/MoinMoin.json +52 -0
- data/config/preferences/Navigation.json +3 -0
- data/config/preferences/Nemerle.json +3 -0
- data/config/preferences/OCaml Code Completion.json +3 -0
- data/config/preferences/OCaml.json +163 -0
- data/config/preferences/ODCompletion.json +3 -0
- data/config/preferences/Objective-C.json +84 -0
- data/config/preferences/OpenGL.json +3331 -0
- data/config/preferences/Outlines.json +3 -0
- data/config/preferences/Pascal.json +60 -0
- data/config/preferences/Perforce.json +3 -0
- data/config/preferences/Perl.json +15 -0
- data/config/preferences/PmWiki.json +27 -0
- data/config/preferences/Postscript.json +15 -0
- data/config/preferences/Processing.json +32 -0
- data/config/preferences/Prolog.json +3 -0
- data/config/preferences/Propel.json +3 -0
- data/config/preferences/Python.json +38 -0
- data/config/preferences/Quake.json +15 -0
- data/config/preferences/R.json +33 -0
- data/config/preferences/Ragel.json +15 -0
- data/config/preferences/Regular Expressions.json +3 -0
- data/config/preferences/Remind.json +15 -0
- data/config/preferences/Rez.json +46 -0
- data/config/preferences/Ruby.json +98 -0
- data/config/preferences/S5 Slide Show.json +20 -0
- data/config/preferences/SCons.json +3 -0
- data/config/preferences/SQL.json +32 -0
- data/config/preferences/SSH Config.json +15 -0
- data/config/preferences/SVK.json +3 -0
- data/config/preferences/SWIG.json +3 -0
- data/config/preferences/SWeave.json +32 -0
- data/config/preferences/Scheme.json +35 -0
- data/config/preferences/Scilab.json +15 -0
- data/config/preferences/Setext.json +3 -0
- data/config/preferences/Shell Script.json +25 -0
- data/config/preferences/Slate.json +113 -0
- data/config/preferences/Source.json +132 -0
- data/config/preferences/Subversion.json +10 -0
- data/config/preferences/TODO.json +3 -0
- data/config/preferences/Tabular.json +3 -0
- data/config/preferences/Tcl.json +82 -0
- data/config/preferences/TerminalMate.json +112 -0
- data/config/preferences/Text.json +89 -0
- data/config/preferences/TextMate.json +38 -0
- data/config/preferences/Textile.json +76 -0
- data/config/preferences/Thrift.json +56 -0
- data/config/preferences/Transmit.json +3 -0
- data/config/preferences/Twiki.json +51 -0
- data/config/preferences/Txt2tags.json +81 -0
- data/config/preferences/Vectorscript.json +1280 -0
- data/config/preferences/XML.json +60 -0
- data/config/preferences/Xcode.json +3 -0
- data/config/preferences/YAML.json +24 -0
- data/config/preferences/iCalendar.json +10 -0
- data/config/preferences/iTerm.json +36 -0
- data/config/preferences/reStructuredText.json +48 -0
- data/config/rc.rb +49 -0
- data/config/syntax/ANTLR.json +5 -5
- data/config/syntax/{ASP VB.net.json → ASP vb.NET.json } +3 -3
- data/config/syntax/ASP.json +1 -1
- data/config/syntax/ActionScript.json +6 -6
- data/config/syntax/Active4D Config.json +86 -0
- data/config/syntax/Active4D Library.json +20 -0
- data/config/syntax/Active4D.json +418 -0
- data/config/syntax/Ada.json +3 -3
- data/config/syntax/Ant.json +196 -0
- data/config/syntax/Apache.json +7 -7
- data/config/syntax/AppleScript.json +3 -3
- data/config/syntax/{Bibtex.json → BibTeX.json} +1 -1
- data/config/syntax/Bison.json +59 -0
- data/config/syntax/{Blog (HTML).json → Blog - HTML.json } +2 -2
- data/config/syntax/{Blog (Markdown).json → Blog - Markdown.json } +2 -2
- data/config/syntax/Blog (Text).json b/data/config/syntax/Blog - → Text.json +0 -0
- data/config/syntax/Blog (Textile).json b/data/config/syntax/Blog - → Textile.json +0 -0
- data/config/syntax/C++.json +3 -3
- data/config/syntax/C.json +13 -13
- data/config/syntax/CMake Listfile.json +171 -0
- data/config/syntax/CSS.json +6 -6
- data/config/syntax/CSV.json +108 -0
- data/config/syntax/ColdFusion.json +204 -0
- data/config/syntax/D.json +560 -0
- data/config/syntax/Diff.json +1 -1
- data/config/syntax/DokuWiki.json +412 -0
- data/config/syntax/Doxygen.json +80 -0
- data/config/syntax/Dylan.json +4 -4
- data/config/syntax/Erlang.json +5 -5
- data/config/syntax/F-Script.json +1 -1
- data/config/syntax/FXScript.json +5 -5
- data/config/syntax/Fortran - Modern.json +221 -0
- data/config/syntax/Fortran - Punchcard.json +468 -0
- data/config/syntax/GTD.json +39 -0
- data/config/syntax/GTDalt.json +233 -0
- data/config/syntax/Gettext.json +118 -0
- data/config/syntax/Go.json +555 -0
- data/config/syntax/{DOT.json → Graphviz (DOT).json } +3 -3
- data/config/syntax/Greasemonkey.json +56 -0
- data/config/syntax/Gri.json +4 -4
- data/config/syntax/{HTML-ASP.json → HTML (ASP).json } +1 -1
- data/config/syntax/{HTML for ASP.net.json → HTML (ASP.net).json } +19 -19
- data/config/syntax/HTML (Active4D).json +540 -0
- data/config/syntax/HTML (Erlang).json +31 -0
- data/config/syntax/HTML (Tcl).json +1 -1
- data/config/syntax/HTML.json +20 -20
- data/config/syntax/Haskell.json +3 -3
- data/config/syntax/Installer Distribution Script.json +135 -0
- data/config/syntax/Io.json +6 -6
- data/config/syntax/JSON.json +151 -0
- data/config/syntax/{JavaProperties.json → Java Properties.json } +2 -2
- data/config/syntax/Java Server Page (JSP).json +163 -0
- data/config/syntax/Java.json +7 -7
- data/config/syntax/JavaDoc.json +435 -0
- data/config/syntax/JavaScript.json +8 -8
- data/config/syntax/LaTeX Log.json +3 -3
- data/config/syntax/LaTeX Memoir.json +101 -0
- data/config/syntax/LaTeX.json +2 -2
- data/config/syntax/Lex-Flex.json +396 -0
- data/config/syntax/LilyPond.json +608 -0
- data/config/syntax/Logo.json +48 -0
- data/config/syntax/Logtalk.json +6 -6
- data/config/syntax/Lua.json +1 -1
- data/config/syntax/{M.json → MATLAB.json} +3 -3
- data/config/syntax/MEL.json +7 -7
- data/config/syntax/MIPS.json b/data/config/syntax/MIPS → Assembler.json +0 -0
- data/config/syntax/MacPorts Portfile.json +298 -0
- data/config/syntax/Mail.json +1 -1
- data/config/syntax/Markdown.json +6 -6
- data/config/syntax/Maven POM.json +774 -0
- data/config/syntax/Mediawiki.json +736 -0
- data/config/syntax/MoinMoin.json +335 -0
- data/config/syntax/MultiMarkdown.json +41 -0
- data/config/syntax/Nemerle.json +128 -0
- data/config/syntax/OCaml.json +4 -4
- data/config/syntax/OCamllex.json +307 -0
- data/config/syntax/OCamlyacc.json +346 -0
- data/config/syntax/Objective-C++.json +2 -2
- data/config/syntax/Objective-C.json +979 -0
- data/config/syntax/Octave.json +417 -0
- data/config/syntax/PHP.json +32 -32
- data/config/syntax/Pascal.json +1 -1
- data/config/syntax/Perl.json +8 -8
- data/config/syntax/{Plain text.json → Plain Text.json } +1 -1
- data/config/syntax/PmWiki.json +241 -0
- data/config/syntax/Postscript.json +206 -0
- data/config/syntax/Processing.json +8 -8
- data/config/syntax/Prolog.json +70 -0
- data/config/syntax/Python.json +1934 -0
- data/config/syntax/{Quake3 Config.json → Quake Style .cfg.json } +1 -1
- data/config/syntax/R.json +2 -2
- data/config/syntax/Ragel.json +362 -0
- data/config/syntax/Rd (R Documentation).json +119 -0
- data/config/syntax/Regular Expressions (Oniguruma).json +186 -0
- data/config/syntax/Regular Expressions (Python).json +188 -0
- data/config/syntax/Release Notes.json +78 -0
- data/config/syntax/Remind.json +461 -0
- data/config/syntax/Rez.json +5 -5
- data/config/syntax/Ruby Sass.json +497 -0
- data/config/syntax/Ruby.json +13 -13
- data/config/syntax/S5 Slide Show.json +85 -0
- data/config/syntax/SQL.json +11 -11
- data/config/syntax/SSH Config.json +55 -0
- data/config/syntax/SWIG.json +2 -2
- data/config/syntax/SWeave.json +139 -0
- data/config/syntax/Scheme.json +8 -8
- data/config/syntax/Scilab.json +69 -0
- data/config/syntax/Setext.json +247 -0
- data/config/syntax/{Shell-Unix-Generic.json → Shell Script (Bash).json } +4 -4
- data/config/syntax/Slate.json +5 -5
- data/config/syntax/Strings File.json +53 -0
- data/config/syntax/TSV.json +83 -0
- data/config/syntax/Tcl.json +1 -1
- data/config/syntax/TeX Math.json +2 -2
- data/config/syntax/TeX.json +2 -2
- data/config/syntax/Textile.json +9 -9
- data/config/syntax/Thrift.json +641 -0
- data/config/syntax/Twiki.json +1 -1
- data/config/syntax/Txt2tags.json +154 -0
- data/config/syntax/XML strict.json +4 -4
- data/config/syntax/XML.json +6 -6
- data/config/syntax/XSL.json +2 -2
- data/config/syntax/camlp4.json +63 -0
- data/config/syntax/mod_perl.json +72 -0
- data/config/syntax/reStructuredText.json +1 -1
- data/config/syntax/{Subversion commit message.json → svn-commit.tmp.json} +0 -0
- data/config/tutorial +23 -19
- data/config/welcome +3 -3
- data/lib/ver.rb +273 -62
- data/lib/ver/entry.rb +142 -26
- data/lib/ver/font.rb +51 -0
- data/lib/ver/help.rb +16 -0
- data/lib/ver/help/describe_key.rb +82 -0
- data/lib/ver/help/help_for_help.rb +39 -0
- data/lib/ver/hover_completion.rb +129 -0
- data/lib/ver/keymap.rb +95 -24
- data/lib/ver/layout.rb +107 -43
- data/lib/ver/methods.rb +24 -8
- data/lib/ver/methods/clipboard.rb +91 -0
- data/lib/ver/methods/completion.rb +146 -71
- data/lib/ver/methods/control.rb +203 -222
- data/lib/ver/methods/ctags.rb +55 -0
- data/lib/ver/methods/delete.rb +30 -0
- data/lib/ver/methods/help.rb +7 -0
- data/lib/ver/methods/insert.rb +233 -1
- data/lib/ver/methods/move.rb +181 -32
- data/lib/ver/methods/open.rb +208 -0
- data/lib/ver/methods/preview.rb +14 -0
- data/lib/ver/methods/save.rb +111 -0
- data/lib/ver/methods/search.rb +57 -7
- data/lib/ver/methods/select.rb +97 -17
- data/lib/ver/methods/shortcuts.rb +21 -0
- data/lib/ver/methods/views.rb +56 -1
- data/lib/ver/mode.rb +60 -14
- data/lib/ver/status.rb +97 -19
- data/lib/ver/syntax.rb +14 -6
- data/lib/ver/syntax/detector.rb +16 -5
- data/lib/ver/syntax/processor.rb +9 -3
- data/lib/ver/text.rb +258 -199
- data/lib/ver/text/index.rb +103 -0
- data/lib/ver/theme.rb +27 -16
- data/lib/ver/tooltip.rb +59 -0
- data/lib/ver/vendor/binary_search.rb +61 -0
- data/lib/ver/vendor/levenshtein.rb +57 -0
- data/lib/ver/{textpow.rb → vendor/textpow.rb} +31 -29
- data/lib/ver/view.rb +65 -41
- data/lib/ver/view/console.rb +171 -0
- data/lib/ver/view/entry.rb +9 -5
- data/lib/ver/view/list.rb +44 -29
- data/lib/ver/view/list/ex.rb +71 -0
- data/lib/ver/view/list/grep.rb +42 -0
- data/lib/ver/view/list/methods.rb +159 -0
- data/lib/ver/view/term.rb +249 -0
- data/tasks/syntax_list.rake +3 -2
- data/ver.gemspec +4 -4
- metadata +230 -28
- data/config/syntax/Bulletin Board.json +0 -428
- data/config/syntax/HTML (Mason).json +0 -207
- data/config/syntax/HTML (Rails).json +0 -52
- data/config/syntax/Movable Type.json +0 -348
- data/config/syntax/Ruby on Rails.json +0 -170
- data/config/syntax/SQL (Rails).json +0 -31
- data/config/syntax/Smarty.json +0 -110
- data/config/syntax/Standard ML.json +0 -322
@@ -0,0 +1,21 @@
|
|
1
|
+
module VER
|
2
|
+
module Methods
|
3
|
+
module Shortcuts
|
4
|
+
include Move, Save, Open, Views, Insert
|
5
|
+
|
6
|
+
alias q view_close
|
7
|
+
alias q! quit
|
8
|
+
alias w file_save
|
9
|
+
alias r insert_file_contents
|
10
|
+
alias e open_path
|
11
|
+
alias o view_find_or_create
|
12
|
+
alias bn view_focus_next
|
13
|
+
alias bp view_focus_prev
|
14
|
+
alias bd view_close
|
15
|
+
|
16
|
+
def wq
|
17
|
+
w and q
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/ver/methods/views.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
module VER
|
2
2
|
module Methods
|
3
3
|
module Views
|
4
|
+
def view_find_or_create(file)
|
5
|
+
view.find_or_create(file)
|
6
|
+
end
|
7
|
+
|
4
8
|
def view_create
|
5
9
|
view.create
|
6
10
|
end
|
@@ -16,6 +20,57 @@ module VER
|
|
16
20
|
def view_focus_prev
|
17
21
|
view.focus_prev
|
18
22
|
end
|
23
|
+
|
24
|
+
def view_push_up
|
25
|
+
view.push_up
|
26
|
+
end
|
27
|
+
|
28
|
+
def view_push_down
|
29
|
+
view.push_down
|
30
|
+
end
|
31
|
+
|
32
|
+
def view_push_top
|
33
|
+
view.push_top
|
34
|
+
end
|
35
|
+
|
36
|
+
def view_push_bottom
|
37
|
+
view.push_bottom
|
38
|
+
end
|
39
|
+
|
40
|
+
def view_one
|
41
|
+
layout.options.merge! master: 1, stacking: 0
|
42
|
+
layout.apply
|
43
|
+
end
|
44
|
+
|
45
|
+
def view_two
|
46
|
+
layout.options.merge! master: 1, stacking: 1
|
47
|
+
layout.apply
|
48
|
+
end
|
49
|
+
|
50
|
+
def view_slave_inc
|
51
|
+
stacking = layout.options[:stacking]
|
52
|
+
unless stacking >= layout.views.size
|
53
|
+
layout.options[:stacking] += 1
|
54
|
+
layout.apply
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def view_slave_dec
|
59
|
+
stacking = layout.options[:stacking]
|
60
|
+
layout.options[:stacking] -= 1 if stacking > 0
|
61
|
+
layout.apply
|
62
|
+
end
|
63
|
+
|
64
|
+
def view_master_inc
|
65
|
+
layout.options[:master] += 1
|
66
|
+
layout.apply
|
67
|
+
end
|
68
|
+
|
69
|
+
def view_master_dec
|
70
|
+
master = layout.options[:master]
|
71
|
+
layout.options[:master] -= 1 if master > 0
|
72
|
+
layout.apply
|
73
|
+
end
|
19
74
|
end
|
20
75
|
end
|
21
|
-
end
|
76
|
+
end
|
data/lib/ver/mode.rb
CHANGED
@@ -10,6 +10,10 @@ module VER
|
|
10
10
|
|
11
11
|
attr_accessor :callback, :name, :arguments
|
12
12
|
|
13
|
+
def inspect
|
14
|
+
"#<Mode #@name>"
|
15
|
+
end
|
16
|
+
|
13
17
|
def initialize(name, callback)
|
14
18
|
@name, @callback = name, callback
|
15
19
|
@stack = []
|
@@ -28,7 +32,11 @@ module VER
|
|
28
32
|
end
|
29
33
|
|
30
34
|
def find_ancestor(name)
|
31
|
-
callback.modes[name.to_sym]
|
35
|
+
if found = callback.modes[name.to_sym]
|
36
|
+
return found
|
37
|
+
else
|
38
|
+
raise "Mode #{name} is not specified yet"
|
39
|
+
end
|
32
40
|
end
|
33
41
|
|
34
42
|
def ancestors(*done, &block)
|
@@ -57,12 +65,16 @@ module VER
|
|
57
65
|
total = hash = {}
|
58
66
|
|
59
67
|
while key = keychain.shift
|
60
|
-
|
68
|
+
if key.is_a?(Symbol)
|
69
|
+
canonical = callback.modes[key]
|
70
|
+
else
|
71
|
+
canonical = register(key)
|
72
|
+
end
|
61
73
|
|
62
74
|
if keychain.empty?
|
63
|
-
hash[
|
75
|
+
hash[canonical] = block || action_name
|
64
76
|
else
|
65
|
-
hash = hash[
|
77
|
+
hash = hash[canonical] = {}
|
66
78
|
end
|
67
79
|
end
|
68
80
|
|
@@ -81,7 +93,7 @@ module VER
|
|
81
93
|
@stack << key
|
82
94
|
|
83
95
|
ancestors do |ancestor|
|
84
|
-
result = ancestor.attempt_execute(@stack)
|
96
|
+
result = ancestor.attempt_execute(@stack.dup)
|
85
97
|
|
86
98
|
case result
|
87
99
|
when nil # nothing matched yet, but possible in future
|
@@ -100,7 +112,7 @@ module VER
|
|
100
112
|
@stack.clear
|
101
113
|
enter_missing(key)
|
102
114
|
rescue => ex
|
103
|
-
|
115
|
+
VER.error(ex)
|
104
116
|
@stack.clear
|
105
117
|
end
|
106
118
|
|
@@ -108,7 +120,7 @@ module VER
|
|
108
120
|
execute(@missing, key) if @missing
|
109
121
|
end
|
110
122
|
|
111
|
-
def attempt_execute(original_stack)
|
123
|
+
def attempt_execute(original_stack, lookup = false)
|
112
124
|
if arguments
|
113
125
|
stack, arg = Mode.split_stack(original_stack)
|
114
126
|
else
|
@@ -118,15 +130,44 @@ module VER
|
|
118
130
|
if stack.empty?
|
119
131
|
arg ? nil : false
|
120
132
|
else
|
121
|
-
executable =
|
133
|
+
executable = @map
|
134
|
+
while key = stack.shift
|
135
|
+
previous = executable
|
136
|
+
executable = executable[key]
|
137
|
+
|
138
|
+
case executable
|
139
|
+
when nil
|
140
|
+
# FIXME: this allows only one mode
|
141
|
+
if found = previous.find{|prev_key, prev_value| prev_key.is_a?(Mode) }
|
142
|
+
mode, action = found
|
143
|
+
looked = mode.attempt_execute([key, *stack], true)
|
144
|
+
|
145
|
+
case looked
|
146
|
+
when false
|
147
|
+
return false
|
148
|
+
when nil
|
149
|
+
return nil
|
150
|
+
else
|
151
|
+
cmd, cmd_arg = looked
|
152
|
+
return nil if cmd.is_a?(Hash)
|
153
|
+
return execute(action, cmd, arg)
|
154
|
+
end
|
155
|
+
else
|
156
|
+
return false
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
122
160
|
|
123
|
-
|
161
|
+
if lookup
|
162
|
+
return executable, arg
|
163
|
+
else
|
164
|
+
execute(executable, *arg)
|
165
|
+
end
|
124
166
|
end
|
125
|
-
rescue KeyError
|
126
|
-
false
|
127
167
|
end
|
128
168
|
|
129
169
|
def execute(executable, *arg)
|
170
|
+
arg = [*arg].compact # doesn't allow nil
|
130
171
|
case executable
|
131
172
|
when Hash
|
132
173
|
return nil
|
@@ -140,18 +181,23 @@ module VER
|
|
140
181
|
return false
|
141
182
|
end
|
142
183
|
|
184
|
+
true
|
185
|
+
rescue ArgumentError => ex
|
186
|
+
callback.message("#{executable} : #{ex}")
|
143
187
|
true
|
144
188
|
end
|
145
189
|
|
146
190
|
def self.split_stack(stack)
|
147
|
-
|
191
|
+
first = stack[0]
|
192
|
+
return stack, nil if first == '0' || first == '<KeyPress-0>'
|
148
193
|
|
149
|
-
pivot = stack.index{|c| c !~
|
194
|
+
pivot = stack.index{|c| c !~ /^(<KeyPress-\d+>|\d+)$/ }
|
150
195
|
|
151
196
|
if pivot == 0
|
152
197
|
return stack, nil
|
153
198
|
elsif pivot
|
154
|
-
|
199
|
+
keys, args = stack[pivot..-1], stack[0..pivot]
|
200
|
+
return keys, args.join.scan(/\d+/).join.to_i
|
155
201
|
else
|
156
202
|
return [], stack.join.to_i
|
157
203
|
end
|
data/lib/ver/status.rb
CHANGED
@@ -4,12 +4,15 @@ module VER
|
|
4
4
|
attr_accessor :keymap, :view
|
5
5
|
attr_reader :mode
|
6
6
|
|
7
|
+
HISTORY = Hash.new{|k,v| k[v] = [] }
|
8
|
+
|
7
9
|
def initialize(view, options = {})
|
8
10
|
options[:style] ||= self.class.obtain_style_name
|
9
11
|
super
|
10
12
|
self.view = view
|
13
|
+
@question = ''
|
11
14
|
|
12
|
-
keymap_name = VER.options.
|
15
|
+
keymap_name = VER.options.keymap
|
13
16
|
self.keymap = Keymap.get(name: keymap_name, receiver: self)
|
14
17
|
end
|
15
18
|
|
@@ -28,40 +31,115 @@ module VER
|
|
28
31
|
view.text
|
29
32
|
end
|
30
33
|
|
31
|
-
def ask(question, &callback)
|
32
|
-
@
|
34
|
+
def ask(question, options = {}, &callback)
|
35
|
+
@backup_value, @callback = value, callback
|
36
|
+
@history_idx = -1
|
33
37
|
|
34
|
-
|
38
|
+
self.question = question
|
39
|
+
submit_when_taken(options[:take])
|
35
40
|
focus
|
36
41
|
end
|
37
42
|
|
43
|
+
def submit_when_taken(length)
|
44
|
+
return unless length
|
45
|
+
target = value.size + length
|
46
|
+
|
47
|
+
bind '<<Modified>>' do |event|
|
48
|
+
if value.size >= target
|
49
|
+
bind('<<Modified>>'){}
|
50
|
+
ask_submit
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
38
55
|
def ask_submit
|
39
|
-
answer = value
|
40
|
-
|
41
|
-
|
56
|
+
answer = value
|
57
|
+
history = HISTORY[@question]
|
58
|
+
history.uniq!
|
59
|
+
history << answer
|
60
|
+
self.question = ''
|
61
|
+
|
62
|
+
case result = @callback.call(answer)
|
63
|
+
when String
|
64
|
+
message result
|
65
|
+
when Symbol
|
66
|
+
result
|
67
|
+
else
|
68
|
+
message result.inspect
|
69
|
+
end
|
42
70
|
end
|
43
71
|
|
44
72
|
def ask_abort
|
45
|
-
|
73
|
+
self.question = ''
|
74
|
+
self.value = @backup_value
|
46
75
|
text.focus
|
47
76
|
end
|
48
77
|
|
49
|
-
def
|
50
|
-
|
51
|
-
|
78
|
+
def delete(from, to = Tk::None)
|
79
|
+
if from < @question.size
|
80
|
+
from = @question.size
|
81
|
+
end
|
82
|
+
|
83
|
+
super(from, to)
|
84
|
+
end
|
85
|
+
|
86
|
+
def value=(string)
|
87
|
+
super([@question, string].join)
|
88
|
+
end
|
89
|
+
|
90
|
+
def value
|
91
|
+
regex = Regexp.escape(@question)
|
92
|
+
get.sub(/^#{regex}/, '')
|
93
|
+
end
|
94
|
+
|
95
|
+
def question=(string)
|
96
|
+
execute_only(:delete, 0, :end)
|
97
|
+
execute_only(:insert, 0, string)
|
98
|
+
@question = string.to_s
|
99
|
+
Tk::Event.generate(self, '<<Modified>>')
|
52
100
|
end
|
53
101
|
|
54
|
-
def
|
55
|
-
return if @question.size
|
102
|
+
def cursor=(pos)
|
103
|
+
return if pos < @question.size
|
56
104
|
super
|
57
105
|
end
|
58
106
|
|
59
|
-
def
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
107
|
+
def history_prev
|
108
|
+
@history_idx -= 1
|
109
|
+
history = HISTORY[@question]
|
110
|
+
|
111
|
+
if @history_idx < 0
|
112
|
+
@history_idx = history.size - 1
|
113
|
+
end
|
114
|
+
|
115
|
+
p prev: [history, @history_idx]
|
116
|
+
answer = history[@history_idx]
|
117
|
+
return unless answer
|
118
|
+
self.value = answer
|
119
|
+
end
|
120
|
+
|
121
|
+
def history_next
|
122
|
+
@history_idx += 1
|
123
|
+
history = HISTORY[@question]
|
124
|
+
|
125
|
+
if @history_idx > history.size
|
126
|
+
@history_idx = 0
|
64
127
|
end
|
128
|
+
|
129
|
+
p next: [history, @history_idx]
|
130
|
+
answer = history[@history_idx]
|
131
|
+
return unless answer
|
132
|
+
self.value = answer
|
133
|
+
end
|
134
|
+
|
135
|
+
def history_complete
|
136
|
+
history = HISTORY[@question]
|
137
|
+
so_far = value.sub(@question, '')
|
138
|
+
needle = Regexp.escape(so_far)
|
139
|
+
list = history.grep(/#{needle}/i)
|
140
|
+
return if list.empty?
|
141
|
+
|
142
|
+
self.value = answer
|
65
143
|
end
|
66
144
|
end
|
67
|
-
end
|
145
|
+
end
|
data/lib/ver/syntax.rb
CHANGED
@@ -11,7 +11,7 @@ module VER
|
|
11
11
|
if syntax_name = Detector.detect(filename)
|
12
12
|
return new(syntax_name)
|
13
13
|
else
|
14
|
-
new
|
14
|
+
new(VER.options.filetype)
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -40,7 +40,7 @@ module VER
|
|
40
40
|
@theme = theme || Theme.find_and_load(VER.options[:theme])
|
41
41
|
end
|
42
42
|
|
43
|
-
def highlight(textarea, code, lineno = 0)
|
43
|
+
def highlight(textarea, code, lineno = nil, from = '1.0', to = 'end')
|
44
44
|
if @old_theme
|
45
45
|
@old_theme.delete_tags_on(textarea)
|
46
46
|
@old_theme = nil
|
@@ -51,12 +51,20 @@ module VER
|
|
51
51
|
@theme.apply_default_on(textarea)
|
52
52
|
@first_highlight = false
|
53
53
|
else
|
54
|
-
@theme.remove_tags_on(textarea)
|
54
|
+
@theme.remove_tags_on(textarea, from, to)
|
55
55
|
end
|
56
56
|
|
57
|
-
pr = Processor.new(textarea, @theme, lineno)
|
57
|
+
pr = Processor.new(textarea, @theme, lineno || 0)
|
58
58
|
|
59
|
-
|
59
|
+
if lineno
|
60
|
+
pr.start_parsing(parser.scopeName)
|
61
|
+
stack = [[parser, nil]]
|
62
|
+
parser.parse_line(stack, code, pr)
|
63
|
+
pr.end_parsing(parser.scopeName)
|
64
|
+
else
|
65
|
+
@theme.remove_tags_on(textarea, from, to)
|
66
|
+
parser.parse(code, pr)
|
67
|
+
end
|
60
68
|
end
|
61
69
|
|
62
70
|
def theme=(theme)
|
@@ -65,4 +73,4 @@ module VER
|
|
65
73
|
@first_highlight = true
|
66
74
|
end
|
67
75
|
end
|
68
|
-
end
|
76
|
+
end
|
data/lib/ver/syntax/detector.rb
CHANGED
@@ -22,8 +22,6 @@ module VER
|
|
22
22
|
path = Pathname(filename.to_s)
|
23
23
|
path = path.readlink if path.symlink?
|
24
24
|
|
25
|
-
return unless path.file?
|
26
|
-
|
27
25
|
VER.load('detect')
|
28
26
|
|
29
27
|
override_name || detect_ext(path) || detect_head(path)
|
@@ -33,11 +31,23 @@ module VER
|
|
33
31
|
basename = path.basename.to_s
|
34
32
|
return unless basename =~ /\./
|
35
33
|
|
36
|
-
|
34
|
+
scores = {}
|
35
|
+
|
36
|
+
EXTS_LIST.each do |name, exts|
|
37
|
+
lowest = nil
|
37
38
|
exts.find do |ext|
|
38
|
-
|
39
|
+
if basename.end_with?(ext)
|
40
|
+
distance = Levenshtein.distance(basename, ext)
|
41
|
+
lowest ||= distance
|
42
|
+
lowest = distance if lowest > distance
|
43
|
+
end
|
44
|
+
# return name if basename.end_with?(ext)
|
39
45
|
end
|
46
|
+
scores[name] = lowest if lowest
|
40
47
|
end
|
48
|
+
|
49
|
+
found = scores.sort_by{|k,v| v }.first
|
50
|
+
return found.first if found
|
41
51
|
end
|
42
52
|
|
43
53
|
def detect_head(path)
|
@@ -47,7 +57,8 @@ module VER
|
|
47
57
|
HEAD_LIST.find do |name, head|
|
48
58
|
return name if line =~ head
|
49
59
|
end
|
60
|
+
rescue Errno::ENOENT
|
50
61
|
end
|
51
62
|
end
|
52
63
|
end
|
53
|
-
end
|
64
|
+
end
|