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
data/lib/ver/layout.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module VER
|
2
|
-
class Layout <
|
3
|
-
attr_reader :strategy, :views
|
2
|
+
class Layout < Tk::Tile::Frame
|
3
|
+
attr_reader :strategy, :views, :options
|
4
4
|
|
5
5
|
def initialize(parent, options = {})
|
6
6
|
super
|
@@ -8,6 +8,7 @@ module VER
|
|
8
8
|
pack(fill: :both, expand: true)
|
9
9
|
|
10
10
|
@views = []
|
11
|
+
@options = {}
|
11
12
|
self.strategy = Layout::VerticalTiling
|
12
13
|
end
|
13
14
|
|
@@ -19,89 +20,152 @@ module VER
|
|
19
20
|
def create_view
|
20
21
|
view = View.new(self)
|
21
22
|
yield view
|
22
|
-
@views
|
23
|
+
@views.unshift view
|
23
24
|
|
24
25
|
apply
|
26
|
+
view.focus
|
25
27
|
end
|
26
28
|
|
27
29
|
def close_view(view)
|
28
30
|
@views.delete view
|
29
31
|
view.destroy
|
30
32
|
|
31
|
-
if previous = @views.
|
33
|
+
if previous = @views.first
|
32
34
|
apply
|
33
35
|
previous.focus
|
34
36
|
else
|
35
|
-
|
37
|
+
VER.exit
|
36
38
|
end
|
37
39
|
end
|
38
40
|
|
39
41
|
def focus_next(current)
|
40
|
-
|
42
|
+
visible = head_tail_hidden.first(2).flatten
|
43
|
+
return unless index = visible.index(current)
|
41
44
|
|
42
|
-
found =
|
45
|
+
found = visible[index + 1] || visible[0]
|
43
46
|
found.focus
|
44
47
|
end
|
45
48
|
|
46
49
|
def focus_prev(current)
|
47
|
-
|
50
|
+
visible = head_tail_hidden.first(2).flatten
|
51
|
+
|
52
|
+
return unless index = visible.index(current)
|
48
53
|
|
49
|
-
found =
|
54
|
+
found = visible[index - 1]
|
50
55
|
found.focus
|
51
56
|
end
|
52
57
|
|
58
|
+
# called on #3
|
59
|
+
# +-----+-----+ > +-----+-----+ > +-----+-----+ > +-----+-----+
|
60
|
+
# | | 2 | > | | 3 | > | | 1 | > | | 1 |
|
61
|
+
# | 1 +-----+ > | 1 +-----+ > | 3 +-----+ > | 3 +-----+
|
62
|
+
# | | 3 | > | | 2 | > | | 2 | > | | 2 |
|
63
|
+
# +-----+-----+ > +-----+-----+ > +-----+-----+ > +-----+-----+
|
64
|
+
def push_up(current)
|
65
|
+
return unless index = @views.index(current)
|
66
|
+
previous = @views[index - 1]
|
67
|
+
current.raise(previous)
|
68
|
+
@views[index - 1], @views[index] = current, previous
|
69
|
+
|
70
|
+
apply
|
71
|
+
end
|
72
|
+
|
73
|
+
# called on #3
|
74
|
+
# +-----+-----+ > +-----+-----+ > +-----+-----+ > +-----+-----+
|
75
|
+
# | | 2 | > | | 1 | > | | 3 | > | | 2 |
|
76
|
+
# | 1 +-----+ > | 3 +-----+ > | 1 +-----+ > | 1 +-----+
|
77
|
+
# | | 3 | > | | 2 | > | | 2 | > | | 3 |
|
78
|
+
# +-----+-----+ > +-----+-----+ > +-----+-----+ > +-----+-----+
|
79
|
+
def push_down(current)
|
80
|
+
return unless index = @views.index(current)
|
81
|
+
following = @views[index + 1] || @views[0]
|
82
|
+
current.raise(following)
|
83
|
+
@views[@views.index(following)], @views[index] = current, following
|
84
|
+
|
85
|
+
apply
|
86
|
+
end
|
87
|
+
|
88
|
+
def push_top(current)
|
89
|
+
@views.unshift(@views.delete(current))
|
90
|
+
apply
|
91
|
+
end
|
92
|
+
|
93
|
+
def push_bottom(view)
|
94
|
+
@views.push(@views.delete(view))
|
95
|
+
apply
|
96
|
+
end
|
97
|
+
|
53
98
|
def apply(options = {})
|
54
|
-
|
99
|
+
@options.merge!(options)
|
100
|
+
strategy.apply(self, @options)
|
101
|
+
end
|
102
|
+
|
103
|
+
def head_tail_hidden(options = {})
|
104
|
+
@options.merge!(options)
|
105
|
+
strategy.prepare(self, @options)
|
106
|
+
end
|
107
|
+
|
108
|
+
module Tiling
|
109
|
+
DEFAULT = { master: 1, stacking: 3 }
|
110
|
+
|
111
|
+
def prepare(layout, options)
|
112
|
+
slaves = layout.views
|
113
|
+
master, stacking = DEFAULT.merge(options).values_at(:master, :stacking)
|
114
|
+
options.merge! master: master, stacking: stacking
|
115
|
+
head, tail, hidden = slaves[0...master], slaves[master..stacking], slaves[stacking..-1]
|
116
|
+
end
|
117
|
+
|
118
|
+
def apply(layout, options = {})
|
119
|
+
masters, stacked, hidden = prepare(layout, options)
|
120
|
+
|
121
|
+
limit = stacked.size == 0 ? 1.0 : 0.5
|
122
|
+
|
123
|
+
apply_hidden(hidden) if hidden
|
124
|
+
apply_masters(masters, limit) if masters
|
125
|
+
apply_stacked(stacked, limit) if stacked
|
126
|
+
end
|
127
|
+
|
128
|
+
def apply_hidden(windows)
|
129
|
+
windows.each(&:place_forget)
|
130
|
+
end
|
55
131
|
end
|
56
132
|
|
57
133
|
module VerticalTiling
|
58
|
-
|
134
|
+
extend Tiling
|
59
135
|
|
60
136
|
module_function
|
61
137
|
|
62
|
-
def
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
head_step = 1.0 / head.size
|
68
|
-
tail_step = 1.0 / tail.size
|
69
|
-
|
70
|
-
head.each_with_index do |slave, idx|
|
71
|
-
slave.place(relx: 0.0, rely: (head_step * idx),
|
72
|
-
relheight: head_step, relwidth: width)
|
73
|
-
end
|
138
|
+
def apply_masters(windows, width, step = 1.0 / windows.size)
|
139
|
+
windows.each_with_index{|window, idx|
|
140
|
+
window.place(relx: 0.0, rely: (step * idx),
|
141
|
+
relheight: step, relwidth: width) }
|
142
|
+
end
|
74
143
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
144
|
+
def apply_stacked(windows, width, step = 1.0 / windows.size)
|
145
|
+
windows.each_with_index{|window, idx|
|
146
|
+
window.place(relx: 0.5, rely: (step * idx),
|
147
|
+
relheight: step, relwidth: width) }
|
79
148
|
end
|
80
149
|
end
|
81
150
|
|
82
151
|
module HorizontalTiling
|
83
|
-
|
152
|
+
extend Tiling
|
84
153
|
|
85
154
|
module_function
|
86
155
|
|
87
|
-
def
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
height = tail.size == 0 ? 1.0 : 0.5
|
92
|
-
head_step = 1.0 / head.size
|
93
|
-
tail_step = 1.0 / tail.size
|
94
|
-
|
95
|
-
head.each_with_index do |slave, idx|
|
96
|
-
slave.place(relx: (head_step * idx), rely: 0.0,
|
97
|
-
relheight: height, relwidth: head_step)
|
156
|
+
def apply_masters(windows, height, step = 1.0 / windows.size)
|
157
|
+
windows.each_with_index do |window, idx|
|
158
|
+
window.place(relx: (step * idx), rely: 0.0,
|
159
|
+
relheight: height, relwidth: step)
|
98
160
|
end
|
161
|
+
end
|
99
162
|
|
100
|
-
|
101
|
-
|
102
|
-
|
163
|
+
def apply_stacked(windows, height, step = 1.0 / windows.size)
|
164
|
+
windows.each_with_index do |window, idx|
|
165
|
+
window.place(relx: (step * idx), rely: 0.5,
|
166
|
+
relheight: height, relwidth: step)
|
103
167
|
end
|
104
168
|
end
|
105
169
|
end
|
106
170
|
end
|
107
|
-
end
|
171
|
+
end
|
data/lib/ver/methods.rb
CHANGED
@@ -1,19 +1,35 @@
|
|
1
|
-
require 'ver/methods/
|
2
|
-
require 'ver/methods/
|
3
|
-
require 'ver/methods/insert'
|
1
|
+
require 'ver/methods/completion'
|
2
|
+
require 'ver/methods/clipboard'
|
4
3
|
require 'ver/methods/control'
|
4
|
+
require 'ver/methods/ctags'
|
5
|
+
require 'ver/methods/delete'
|
6
|
+
require 'ver/methods/help'
|
7
|
+
require 'ver/methods/insert'
|
8
|
+
require 'ver/methods/move'
|
9
|
+
require 'ver/methods/open'
|
10
|
+
require 'ver/methods/preview'
|
11
|
+
require 'ver/methods/save'
|
5
12
|
require 'ver/methods/search'
|
6
13
|
require 'ver/methods/select'
|
7
|
-
require 'ver/methods/
|
14
|
+
require 'ver/methods/views'
|
15
|
+
require 'ver/methods/shortcuts'
|
8
16
|
|
9
17
|
module VER
|
10
18
|
module Methods
|
11
|
-
include
|
12
|
-
include Views
|
13
|
-
include Insert
|
19
|
+
include Completion
|
14
20
|
include Control
|
21
|
+
include Ctags
|
22
|
+
include Delete
|
23
|
+
include Help
|
24
|
+
include Insert
|
25
|
+
include Move
|
26
|
+
include Open
|
27
|
+
include Preview
|
28
|
+
include Save
|
15
29
|
include Search
|
16
30
|
include Select
|
17
|
-
include
|
31
|
+
include Shortcuts
|
32
|
+
include Clipboard
|
33
|
+
include Views
|
18
34
|
end
|
19
35
|
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
module VER
|
2
|
+
module Methods
|
3
|
+
module Clipboard
|
4
|
+
def copy_line
|
5
|
+
copy get('insert linestart', 'insert lineend + 1 chars')
|
6
|
+
end
|
7
|
+
|
8
|
+
def copy_right_word
|
9
|
+
copy get('insert', 'insert wordend')
|
10
|
+
end
|
11
|
+
|
12
|
+
def copy_left_word
|
13
|
+
copy get('insert', 'insert wordstart')
|
14
|
+
end
|
15
|
+
|
16
|
+
def copy(text)
|
17
|
+
if text.respond_to?(:to_str)
|
18
|
+
copy_string(text)
|
19
|
+
elsif text.respond_to?(:to_ary)
|
20
|
+
copy_array(text)
|
21
|
+
else
|
22
|
+
copy_fallback(text)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def copy_string(text)
|
27
|
+
clipboard_set(text = text.to_str, type: 'STRING')
|
28
|
+
|
29
|
+
copy_message text.count("\n"), text.size
|
30
|
+
end
|
31
|
+
|
32
|
+
def copy_array(text)
|
33
|
+
array = text.to_ary
|
34
|
+
string = array.map(&:to_tcl).join(' ')
|
35
|
+
clipboard_set(string, type: 'ARRAY')
|
36
|
+
|
37
|
+
copy_message text.size, text.reduce(0){|s,v| s + v.size }
|
38
|
+
end
|
39
|
+
|
40
|
+
def copy_fallback(text)
|
41
|
+
clipboard_set(text)
|
42
|
+
|
43
|
+
message "Copied unkown entity of class %p" % [text.class]
|
44
|
+
end
|
45
|
+
|
46
|
+
def copy_message(lines, chars)
|
47
|
+
lines_desc = lines == 1 ? 'line' : 'lines'
|
48
|
+
chars_desc = chars == 1 ? 'character' : 'characters'
|
49
|
+
|
50
|
+
msg = "copied %d %s of %d %s" % [lines, lines_desc, chars, chars_desc]
|
51
|
+
message msg
|
52
|
+
end
|
53
|
+
|
54
|
+
def paste_continous(text)
|
55
|
+
if text =~ /\A([^\n]*)\n\Z/
|
56
|
+
mark_set :insert, 'insert lineend'
|
57
|
+
insert :insert, "\n#{$1}"
|
58
|
+
elsif text =~ /\n/
|
59
|
+
mark_set :insert, 'insert lineend'
|
60
|
+
insert :insert, "\n"
|
61
|
+
text.each_line{|line| insert(:insert, line) }
|
62
|
+
else
|
63
|
+
insert :insert, text
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def paste_tk_array(chunks)
|
68
|
+
insert_y, insert_x = index(:insert).split
|
69
|
+
|
70
|
+
chunks.each_with_index do |chunk, idx|
|
71
|
+
y = insert_y + idx
|
72
|
+
insert "#{y}.#{insert_x}", chunk
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
# FIXME: nasty hack or neccesary?
|
77
|
+
def paste
|
78
|
+
text = clipboard_get
|
79
|
+
paste_continous text.to_s
|
80
|
+
|
81
|
+
rescue RuntimeError => ex
|
82
|
+
if ex.message =~ /form "STRING" not defined/
|
83
|
+
array = clipboard_get('ARRAY')
|
84
|
+
paste_tk_array array.to_a
|
85
|
+
else
|
86
|
+
Kernel.raise ex
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -1,26 +1,156 @@
|
|
1
1
|
module VER
|
2
2
|
module Methods
|
3
3
|
module Completion
|
4
|
+
# TODO: use the tag names at the location to customize completion choices
|
5
|
+
# the textmate bundles have quite some stuff for that.
|
6
|
+
def smart_tab
|
7
|
+
context = get('insert - 1 chars', 'insert + 1 chars')
|
8
|
+
|
9
|
+
if context =~ /^\S\W/
|
10
|
+
if @complete_last_used
|
11
|
+
complete_again
|
12
|
+
else
|
13
|
+
complete_word
|
14
|
+
end
|
15
|
+
else
|
16
|
+
indent = ' ' * VER.options.shiftwidth
|
17
|
+
insert :insert, indent
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def complete_again
|
22
|
+
send(@complete_last_used) if @complete_last_used
|
23
|
+
end
|
24
|
+
|
25
|
+
def complete_tm
|
26
|
+
return unless load_preferences
|
27
|
+
require 'set'
|
28
|
+
require 'tempfile'
|
29
|
+
|
30
|
+
@complete_last_used = :complete_tm
|
31
|
+
|
32
|
+
from, to = 'insert - 1 chars wordstart', 'insert - 1 chars wordend'
|
33
|
+
|
34
|
+
complete{ [from, to, tm_completions(from, to)] }
|
35
|
+
end
|
36
|
+
|
37
|
+
def tm_completions(from, to)
|
38
|
+
tags = Set.new(tag_names(to))
|
39
|
+
completions = []
|
40
|
+
|
41
|
+
@preferences.each do |key, value|
|
42
|
+
name, scope, settings, uuid =
|
43
|
+
value.values_at('name', 'scope', 'settings', 'uuid')
|
44
|
+
scopes = Set.new(scope.split(/\s*,\s*|\s+/))
|
45
|
+
|
46
|
+
next unless completion_command = settings['completionCommand']
|
47
|
+
next unless scope_compare(tags, scopes)
|
48
|
+
|
49
|
+
current_word = get(from, to).strip
|
50
|
+
ENV['TM_CURRENT_WORD'] = current_word
|
51
|
+
|
52
|
+
tmp = Tempfile.new('ver/complete_tm')
|
53
|
+
tmp.print(completion_command)
|
54
|
+
tmp.close
|
55
|
+
begin
|
56
|
+
FileUtils.chmod(0700, tmp.path)
|
57
|
+
result = `exec '#{tmp.path}'`
|
58
|
+
completions = result.scan(/[^\r\n]+/)
|
59
|
+
ensure
|
60
|
+
tmp.close!
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
completions
|
65
|
+
rescue => ex
|
66
|
+
VER.error(ex)
|
67
|
+
end
|
68
|
+
|
69
|
+
def scope_compare(tags, scopes)
|
70
|
+
scopes.all?{|scope| tags.any?{|tag| scope.start_with?(tag) }}
|
71
|
+
end
|
72
|
+
|
73
|
+
def complete_line
|
74
|
+
@complete_last_used = :complete_line
|
75
|
+
|
76
|
+
from, to = 'insert linestart', 'insert lineend'
|
77
|
+
lines = line_completions(from, to)
|
78
|
+
|
79
|
+
complete{ [from, to, lines] }
|
80
|
+
end
|
81
|
+
|
82
|
+
def line_completions(from, to)
|
83
|
+
line = get(from, to).to_s.strip
|
84
|
+
|
85
|
+
return [] if line.empty?
|
86
|
+
needle = Regexp.escape(line)
|
87
|
+
search_all(/^.*#{needle}.*$/).map{|match, *_| match }.uniq
|
88
|
+
end
|
89
|
+
|
4
90
|
def complete_file
|
5
|
-
|
6
|
-
|
91
|
+
@complete_last_used = :complete_file
|
92
|
+
|
93
|
+
complete continue: true do
|
94
|
+
file_completions('insert linestart', 'insert')
|
95
|
+
end
|
7
96
|
end
|
8
97
|
|
9
|
-
def
|
10
|
-
|
11
|
-
|
98
|
+
def file_completions(from, to)
|
99
|
+
y = index(from).y
|
100
|
+
line = get(from, to)
|
101
|
+
|
102
|
+
return [] unless match = line.match(/(?<pre>.*?)(?<path>\/[^\s"'{}()\[\]]*)(?<post>.*?)/)
|
103
|
+
from, to = match.offset(:path)
|
104
|
+
path = match[:path]
|
105
|
+
|
106
|
+
path.sub!(/\/*$/, '/') if File.directory?(path)
|
107
|
+
|
108
|
+
list = Dir["#{path}*"].uniq - [path]
|
109
|
+
|
110
|
+
list.map! do |item|
|
111
|
+
item << '/' if File.directory?(item)
|
112
|
+
item.sub(path, '/')
|
113
|
+
end
|
114
|
+
|
115
|
+
return "#{y}.#{to - 1}", "#{y}.#{to}", list
|
116
|
+
end
|
117
|
+
|
118
|
+
def complete_word
|
119
|
+
@complete_last_used = :complete_word
|
120
|
+
|
121
|
+
y, x = index('insert').split
|
122
|
+
x = (x - 1).abs
|
123
|
+
from, to = index("#{y}.#{x} wordstart"), index("#{y}.#{x} wordend")
|
124
|
+
|
125
|
+
words = word_completions(from, to)
|
126
|
+
|
127
|
+
complete{ [from, to, words] }
|
128
|
+
end
|
129
|
+
|
130
|
+
def word_completions(from, to)
|
131
|
+
prefix = get(from, to).strip
|
132
|
+
return [] if prefix.empty?
|
133
|
+
prefix = Regexp.escape(prefix)
|
134
|
+
|
135
|
+
found = search_all(/(^|\W)(#{prefix}[\w-]*)/).
|
136
|
+
sort_by{|match, mf, mt| [Text::Index.new(self, mf).delta(from), match] }.
|
137
|
+
map{|match, *_| match.strip[/[\w-]+/] }.uniq
|
138
|
+
found.delete prefix
|
139
|
+
found
|
12
140
|
end
|
13
141
|
|
14
|
-
def
|
15
|
-
|
142
|
+
def complete_aspell
|
143
|
+
@complete_last_used = :complete_aspell
|
16
144
|
|
17
|
-
|
18
|
-
|
19
|
-
|
145
|
+
complete do
|
146
|
+
pos = index('insert - 1 chars')
|
147
|
+
from, to = pos.wordstart, pos.wordend
|
148
|
+
[from, to, aspell_completions(from, to)]
|
149
|
+
end
|
20
150
|
end
|
21
151
|
|
22
|
-
def aspell_completions
|
23
|
-
word = get(
|
152
|
+
def aspell_completions(from, to)
|
153
|
+
word = get(from, to)
|
24
154
|
|
25
155
|
if result = aspell_execute(word)[word]
|
26
156
|
result[:suggestions]
|
@@ -52,65 +182,10 @@ module VER
|
|
52
182
|
return results
|
53
183
|
end
|
54
184
|
|
55
|
-
def complete(
|
56
|
-
|
57
|
-
|
58
|
-
x, y = caret.values_at('x', 'y')
|
59
|
-
longest_word = words.map{|word| word.size }.max
|
60
|
-
|
61
|
-
list = Tk::Listbox.new(self){
|
62
|
-
borderwidth 0
|
63
|
-
width longest_word + 2
|
64
|
-
height words.size
|
65
|
-
place x: x, y: y
|
66
|
-
focus
|
67
|
-
}
|
68
|
-
|
69
|
-
list.value = words
|
70
|
-
list.selection_set 0
|
71
|
-
|
72
|
-
# go down
|
73
|
-
list.bind('j'){|event|
|
74
|
-
index = list.curselection.first + 1
|
75
|
-
max = list.size
|
76
|
-
|
77
|
-
if index < max
|
78
|
-
list.selection_clear(0, 'end')
|
79
|
-
list.selection_set(index)
|
80
|
-
list.activate(index)
|
81
|
-
end
|
82
|
-
|
83
|
-
Tk.callback_break
|
84
|
-
}
|
85
|
-
|
86
|
-
# go up
|
87
|
-
list.bind('k'){|event|
|
88
|
-
index = list.curselection.first - 1
|
89
|
-
|
90
|
-
if index >= 0
|
91
|
-
list.selection_clear(0, 'end')
|
92
|
-
list.selection_set(index)
|
93
|
-
list.activate(index)
|
94
|
-
end
|
95
|
-
|
96
|
-
Tk.callback_break
|
97
|
-
}
|
98
|
-
|
99
|
-
list.bind('Return'){|event|
|
100
|
-
index = list.curselection.first
|
101
|
-
replacement = list.get(index)
|
102
|
-
replace('insert wordstart', 'insert wordend', replacement)
|
103
|
-
focus
|
104
|
-
list.destroy
|
105
|
-
Tk.callback_break
|
106
|
-
}
|
107
|
-
|
108
|
-
list.bind('Escape'){|event|
|
109
|
-
focus
|
110
|
-
list.destroy
|
111
|
-
Tk.callback_break
|
112
|
-
}
|
185
|
+
def complete(options = {}, &block)
|
186
|
+
edit_separator
|
187
|
+
HoverCompletion.new(self, options, &block)
|
113
188
|
end
|
114
189
|
end
|
115
190
|
end
|
116
|
-
end
|
191
|
+
end
|