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/view.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
module VER
|
2
|
-
class View <
|
3
|
-
autoload :Entry,
|
4
|
-
autoload :List,
|
2
|
+
class View < Tk::Frame
|
3
|
+
autoload :Entry, 'ver/view/entry'
|
4
|
+
autoload :List, 'ver/view/list'
|
5
|
+
autoload :Console, 'ver/view/console'
|
5
6
|
|
6
7
|
attr_reader :layout, :text, :status
|
7
8
|
|
@@ -9,6 +10,7 @@ module VER
|
|
9
10
|
super
|
10
11
|
@layout = layout
|
11
12
|
@text = @status = @ybar = @xbar = nil
|
13
|
+
configure takefocus: false
|
12
14
|
setup
|
13
15
|
end
|
14
16
|
|
@@ -33,19 +35,20 @@ module VER
|
|
33
35
|
end
|
34
36
|
|
35
37
|
def setup_text
|
36
|
-
font = VER.options
|
37
|
-
|
38
|
+
font, tabstop = VER.options.font, VER.options.tabstop
|
39
|
+
tabs = font.measure('0') * tabstop
|
38
40
|
|
39
41
|
@text = VER::Text.new(
|
40
42
|
self,
|
41
43
|
autoseparators: true, # insert separators into the undo flow
|
42
44
|
borderwidth: 0,
|
43
45
|
exportselection: true, # copy into X11 buffer automatically
|
44
|
-
insertbackground: '#0f0', # initial value (hardcoded for control mode)
|
45
46
|
font: font,
|
46
|
-
insertofftime:
|
47
|
+
insertofftime: VER.options.insertofftime,
|
48
|
+
insertontime: VER.options.insertontime,
|
47
49
|
setgrid: true, # tell the wm that this is a griddy window
|
48
|
-
|
50
|
+
takefocus: true,
|
51
|
+
tabs: tabs,
|
49
52
|
tabstyle: :wordprocessor,
|
50
53
|
undo: true, # enable undo capabilities
|
51
54
|
wrap: :word
|
@@ -54,45 +57,44 @@ module VER
|
|
54
57
|
|
55
58
|
def setup_scrollbars
|
56
59
|
# vertical scrollbar
|
57
|
-
@ybar =
|
60
|
+
@ybar = Tk::Tile::YScrollbar.new(self)
|
58
61
|
@text.yscrollbar(@ybar)
|
59
62
|
|
60
63
|
# horizontal scrollbar
|
61
|
-
@xbar =
|
64
|
+
@xbar = Tk::Tile::XScrollbar.new(self)
|
62
65
|
@text.xscrollbar(@xbar)
|
63
66
|
end
|
64
67
|
|
65
68
|
def setup_status
|
66
|
-
@status = Status.new(self, font: VER.options[:font], takefocus:
|
69
|
+
@status = Status.new(self, font: VER.options[:font], takefocus: false)
|
67
70
|
end
|
68
71
|
|
69
72
|
def setup_grid
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
73
|
+
@text.grid_configure row: 0, column: 0, sticky: :nsew if @text
|
74
|
+
@ybar.grid_configure row: 0, column: 1, sticky: :ns if @ybar
|
75
|
+
@xbar.grid_configure row: 1, column: 0, sticky: :ew if @xbar
|
76
|
+
@status.grid_configure row: 2, column: 0, sticky: :ew, columnspan: 2 if @status
|
74
77
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
78
|
+
grid_columnconfigure 0, weight: 1
|
79
|
+
grid_columnconfigure 1, weight: 0
|
80
|
+
grid_rowconfigure 0, weight: 1
|
81
|
+
grid_rowconfigure 1, weight: 0
|
79
82
|
end
|
80
83
|
|
81
84
|
def setup_misc
|
82
85
|
@text.status = @status
|
83
86
|
@text.view = self
|
84
|
-
@text.start_control_mode
|
85
87
|
@status.mode = :status_query
|
86
88
|
end
|
87
89
|
|
88
90
|
def setup_events
|
89
|
-
%w[
|
90
|
-
@text.bind("
|
91
|
+
%w[Modified Focus Movement].each do |name|
|
92
|
+
@text.bind("<<#{name}>>"){|event| __send__("on_#{name.downcase}", event) }
|
91
93
|
end
|
92
94
|
end
|
93
95
|
|
94
|
-
def open_path(path)
|
95
|
-
@text.open_path(path)
|
96
|
+
def open_path(path, line = 1)
|
97
|
+
@text.open_path(path, line)
|
96
98
|
end
|
97
99
|
|
98
100
|
def open_empty
|
@@ -109,35 +111,43 @@ module VER
|
|
109
111
|
|
110
112
|
def on_modified(event)
|
111
113
|
@text.see :insert
|
112
|
-
@text.refresh_highlight
|
114
|
+
# @text.refresh_highlight
|
113
115
|
@text.status_projection(@status)
|
114
116
|
end
|
115
117
|
|
116
118
|
def on_focus(event)
|
117
119
|
@text.set_window_title
|
120
|
+
@text.see(:insert)
|
118
121
|
end
|
119
122
|
|
120
|
-
# @text.bind '<Modified>', proc{|e| refresh; p :modified }
|
121
|
-
# @text.bind '<Undo>', proc{|e| refresh; p :undo }
|
122
|
-
# @text.bind '<Redo>', proc{|e| refresh; p :redo }
|
123
|
-
# @text.bind '<Copy>', proc{|e| p :copy }
|
124
|
-
# @text.bind '<Cut>', proc{|e| refresh; p :cut }
|
125
|
-
# @text.bind '<Paste>', proc{|e| refresh; p :paste }
|
126
|
-
# @text.bind '<PasteSelection>', proc{|e| refresh; p :paste_selection }
|
127
|
-
# @text.bind '<Movement>', proc{|e| p :movement }
|
128
|
-
|
129
123
|
def focus
|
130
124
|
text.focus
|
131
125
|
end
|
132
126
|
|
133
|
-
def create
|
127
|
+
def create(path = nil, line = nil)
|
134
128
|
layout.create_view do |view|
|
135
|
-
view.open_empty
|
129
|
+
path ? view.open_path(path, line) : view.open_empty
|
130
|
+
yield(view) if block_given?
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
def find_or_create(path, line = nil, &block)
|
135
|
+
needle = Pathname(path.to_s).expand_path
|
136
|
+
|
137
|
+
if found = layout.views.find{|view| view.filename == needle }
|
138
|
+
found.push_top
|
139
|
+
found.focus
|
140
|
+
found.text.go_line(line) if line
|
141
|
+
yield(found) if block_given?
|
142
|
+
else
|
143
|
+
create(needle, line, &block)
|
136
144
|
end
|
137
145
|
end
|
138
146
|
|
139
147
|
def close
|
140
|
-
|
148
|
+
text.may_close do
|
149
|
+
layout.close_view(self)
|
150
|
+
end
|
141
151
|
end
|
142
152
|
|
143
153
|
def focus_next
|
@@ -148,10 +158,24 @@ module VER
|
|
148
158
|
layout.focus_prev(self)
|
149
159
|
end
|
150
160
|
|
161
|
+
def push_up
|
162
|
+
layout.push_up(self)
|
163
|
+
end
|
164
|
+
|
165
|
+
def push_down
|
166
|
+
layout.push_down(self)
|
167
|
+
end
|
168
|
+
|
169
|
+
def push_top
|
170
|
+
layout.push_top(self)
|
171
|
+
end
|
172
|
+
|
173
|
+
def push_bottom
|
174
|
+
layout.push_bottom(self)
|
175
|
+
end
|
176
|
+
|
151
177
|
def destroy
|
152
|
-
[@text, @ybar, @xbar, @status].each
|
153
|
-
widget.destroy if widget
|
154
|
-
end
|
178
|
+
[@text, @ybar, @xbar, @status].compact.each(&:destroy)
|
155
179
|
|
156
180
|
super
|
157
181
|
end
|
@@ -160,4 +184,4 @@ module VER
|
|
160
184
|
text.filename
|
161
185
|
end
|
162
186
|
end
|
163
|
-
end
|
187
|
+
end
|
@@ -0,0 +1,171 @@
|
|
1
|
+
require 'eventmachine'
|
2
|
+
|
3
|
+
module VER
|
4
|
+
class View
|
5
|
+
class Console
|
6
|
+
class Process < EventMachine::Connection
|
7
|
+
attr_accessor :callback
|
8
|
+
|
9
|
+
def receive_data(data)
|
10
|
+
callback.on_stdout(data)
|
11
|
+
end
|
12
|
+
|
13
|
+
def unbind
|
14
|
+
callback.closed
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class Stderr < EventMachine::Connection
|
19
|
+
attr_accessor :callback
|
20
|
+
|
21
|
+
def initialize(stderr)
|
22
|
+
@stderr = stderr
|
23
|
+
end
|
24
|
+
|
25
|
+
def receive_data(data)
|
26
|
+
callback.on_stderr(data)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def initialize(parent, *cmd)
|
31
|
+
@parent = parent
|
32
|
+
setup_widgets
|
33
|
+
setup_events
|
34
|
+
setup_terminal(*cmd)
|
35
|
+
end
|
36
|
+
|
37
|
+
def setup_widgets
|
38
|
+
font = VER.options[:font]
|
39
|
+
tab_width = font.measure('0') * 2
|
40
|
+
|
41
|
+
@text = Tk::Text.new(
|
42
|
+
@parent,
|
43
|
+
borderwidth: 0,
|
44
|
+
exportselection: true,
|
45
|
+
font: font,
|
46
|
+
insertofftime: 0,
|
47
|
+
setgrid: true,
|
48
|
+
tabs: tab_width,
|
49
|
+
tabstyle: :wordprocessor,
|
50
|
+
background: 'black',
|
51
|
+
foreground: 'white',
|
52
|
+
wrap: :word
|
53
|
+
)
|
54
|
+
@text.tag_configure :stdin, foreground: 'green', background: 'black'
|
55
|
+
@text.tag_configure :stdout, foreground: 'white', background: 'black'
|
56
|
+
@text.tag_configure :stderr, foreground: 'red', background: 'black'
|
57
|
+
|
58
|
+
@entry = Tk::Tile::Entry.new(@parent)
|
59
|
+
@entry.pack fill: :x, side: :bottom
|
60
|
+
@text.pack fill: :both, side: :bottom, after: @entry, expand: true
|
61
|
+
end
|
62
|
+
|
63
|
+
def setup_events
|
64
|
+
@entry.bind('<Control-q>'){ Tk.exit }
|
65
|
+
# @entry.bind('Escape'){ closed }
|
66
|
+
@entry.bind('<Return>'){
|
67
|
+
send_data @entry.value
|
68
|
+
@entry.clear
|
69
|
+
}
|
70
|
+
end
|
71
|
+
|
72
|
+
def closed
|
73
|
+
@entry.bind('<Return>'){}
|
74
|
+
@entry.bind('<Key>'){ Tk.callback_break }
|
75
|
+
@entry.bind('<Escape>'){ destroy }
|
76
|
+
@entry.value = 'Session ended. Press Escape to close console'
|
77
|
+
rescue => ex
|
78
|
+
VER.error(ex)
|
79
|
+
end
|
80
|
+
|
81
|
+
def destroy
|
82
|
+
@text.destroy
|
83
|
+
@entry.destroy
|
84
|
+
@parent.focus
|
85
|
+
end
|
86
|
+
|
87
|
+
def shell_config
|
88
|
+
buffer = []
|
89
|
+
|
90
|
+
shell = ENV['SHELL'] || 'sh'
|
91
|
+
opts = [shell]
|
92
|
+
|
93
|
+
case shell
|
94
|
+
when /zsh/
|
95
|
+
opts << '-s'
|
96
|
+
buffer << 'echo $ZSH $ZSH_VERSION'
|
97
|
+
when /bash/
|
98
|
+
opts << '-s'
|
99
|
+
buffer << 'echo $BASH $BASH_VERSION'
|
100
|
+
end
|
101
|
+
|
102
|
+
return buffer, opts
|
103
|
+
end
|
104
|
+
|
105
|
+
def setup_terminal(*cmd)
|
106
|
+
if cmd.empty?
|
107
|
+
@buffer, opts = shell_config
|
108
|
+
else
|
109
|
+
@buffer = []
|
110
|
+
opts = cmd
|
111
|
+
end
|
112
|
+
|
113
|
+
# FIXME: this should have proper shell escapes
|
114
|
+
popen3(opts.join(' '), self) do |stdin|
|
115
|
+
begin
|
116
|
+
@entry.focus
|
117
|
+
@stdin = stdin
|
118
|
+
|
119
|
+
while line = @buffer.shift
|
120
|
+
send_data(line)
|
121
|
+
end
|
122
|
+
rescue => ex
|
123
|
+
VER.error(ex)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
# the callback should have #on_stdout and #on_stderr
|
129
|
+
# The method yields the stdin and you can use #send_data on it.
|
130
|
+
# This seems to have the side-effect of messing with the original $stderr,
|
131
|
+
# maybe there are other solutions.
|
132
|
+
def popen3(cmd, callback)
|
133
|
+
old_stderr = $stderr.dup
|
134
|
+
rd, wr = IO::pipe
|
135
|
+
$stderr.reopen(wr)
|
136
|
+
|
137
|
+
popen_stdin = EM.popen(cmd, Process)
|
138
|
+
popen_stdin.callback = callback
|
139
|
+
|
140
|
+
popen_stderr = EM.attach(rd, Stderr, rd)
|
141
|
+
popen_stderr.callback = callback
|
142
|
+
|
143
|
+
yield(popen_stdin) if block_given?
|
144
|
+
|
145
|
+
$stderr.reopen old_stderr
|
146
|
+
end
|
147
|
+
|
148
|
+
def send_data(string)
|
149
|
+
@stdin.send_data("#{string}\n")
|
150
|
+
on_stdin(string)
|
151
|
+
end
|
152
|
+
|
153
|
+
def on_stdin(string)
|
154
|
+
output "i> #{string}\n", :stdin
|
155
|
+
end
|
156
|
+
|
157
|
+
def on_stdout(string)
|
158
|
+
output "#{string}", :stdout
|
159
|
+
end
|
160
|
+
|
161
|
+
def on_stderr(string)
|
162
|
+
output "e> #{string}", :stderr
|
163
|
+
end
|
164
|
+
|
165
|
+
def output(string, tag)
|
166
|
+
@text.insert(:end, string, tag)
|
167
|
+
@text.see(:end)
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
data/lib/ver/view/entry.rb
CHANGED
@@ -16,13 +16,17 @@ module VER
|
|
16
16
|
list_view.cancel
|
17
17
|
end
|
18
18
|
|
19
|
-
def
|
20
|
-
list_view.
|
19
|
+
def line_up
|
20
|
+
list_view.line_up
|
21
21
|
end
|
22
22
|
|
23
|
-
def
|
24
|
-
list_view.
|
23
|
+
def line_down
|
24
|
+
list_view.line_down
|
25
|
+
end
|
26
|
+
|
27
|
+
def completion
|
28
|
+
list_view.completion
|
25
29
|
end
|
26
30
|
end
|
27
31
|
end
|
28
|
-
end
|
32
|
+
end
|
data/lib/ver/view/list.rb
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
module VER
|
2
2
|
class View::List < Struct.new(:parent, :frame, :list, :entry, :tag, :callback)
|
3
3
|
autoload :Buffer, 'ver/view/list/buffer'
|
4
|
+
autoload :Grep, 'ver/view/list/grep'
|
5
|
+
autoload :Methods, 'ver/view/list/methods'
|
4
6
|
autoload :Window, 'ver/view/list/buffer'
|
5
7
|
autoload :FuzzyFileFinder, 'ver/view/list/fuzzy_file_finder'
|
6
8
|
autoload :Syntax, 'ver/view/list/syntax'
|
7
9
|
autoload :Theme, 'ver/view/list/theme'
|
10
|
+
autoload :Ex, 'ver/view/list/ex'
|
8
11
|
|
9
12
|
def initialize(parent, &block)
|
10
13
|
self.parent, self.callback = parent, block
|
@@ -16,31 +19,30 @@ module VER
|
|
16
19
|
end
|
17
20
|
|
18
21
|
def setup_widgets
|
19
|
-
self.frame =
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
font VER.options[:font]
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
self.entry = View::Entry.new(frame)
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
}
|
22
|
+
self.frame = Tk::Frame.new.pack fill: :both, expand: true
|
23
|
+
|
24
|
+
self.list = list = Tk::Listbox.new(frame)
|
25
|
+
list.configure(
|
26
|
+
setgrid: true,
|
27
|
+
width: 0,
|
28
|
+
background: '#000',
|
29
|
+
foreground: '#fff',
|
30
|
+
selectforeground: '#000',
|
31
|
+
selectbackground: '#fff',
|
32
|
+
exportselection: false,
|
33
|
+
font: VER.options[:font]
|
34
|
+
)
|
35
|
+
list.pack fill: :both, expand: true
|
36
|
+
|
37
|
+
self.entry = entry = View::Entry.new(frame)
|
38
|
+
entry.configure font: VER.options[:font]
|
39
|
+
entry.pack fill: :x, expand: false
|
40
|
+
entry.focus
|
39
41
|
entry.list_view = self
|
40
42
|
end
|
41
43
|
|
42
44
|
def setup_keymap
|
43
|
-
keymap_name = VER.options.
|
45
|
+
keymap_name = VER.options.keymap
|
44
46
|
|
45
47
|
@list_keymap = Keymap.get(
|
46
48
|
name: keymap_name, receiver: self, widget: list, mode: :list_view_list)
|
@@ -52,7 +54,7 @@ module VER
|
|
52
54
|
# Setup this event, because Keymap gets very confused when you bind 'Key' and
|
53
55
|
# we don't want to break the event-chain anyway
|
54
56
|
def setup_events
|
55
|
-
entry.bind('
|
57
|
+
entry.bind('<<Inserted>>'){ on_update }
|
56
58
|
end
|
57
59
|
|
58
60
|
def on_update
|
@@ -62,10 +64,10 @@ module VER
|
|
62
64
|
end
|
63
65
|
|
64
66
|
def quit
|
65
|
-
|
67
|
+
VER.exit
|
66
68
|
end
|
67
69
|
|
68
|
-
def
|
70
|
+
def line_up
|
69
71
|
index = list.curselection.first - 1
|
70
72
|
|
71
73
|
if index >= 0
|
@@ -74,7 +76,7 @@ module VER
|
|
74
76
|
end
|
75
77
|
end
|
76
78
|
|
77
|
-
def
|
79
|
+
def line_down
|
78
80
|
index = list.curselection.first + 1
|
79
81
|
max = list.size
|
80
82
|
|
@@ -123,15 +125,28 @@ module VER
|
|
123
125
|
end
|
124
126
|
|
125
127
|
def pick_selection
|
126
|
-
pick
|
128
|
+
pick list.get(list.curselection.first)
|
127
129
|
end
|
128
130
|
|
129
|
-
def pick_action(
|
130
|
-
callback.call(
|
131
|
+
def pick_action(*args)
|
132
|
+
callback.call(*args) if callback
|
133
|
+
end
|
134
|
+
|
135
|
+
def completion
|
136
|
+
values = list.get(0, :end)
|
137
|
+
|
138
|
+
if values.size == 1
|
139
|
+
entry.value = values.first
|
140
|
+
elsif values.size > 1
|
141
|
+
require 'abbrev'
|
142
|
+
if found = values.abbrev[entry.value]
|
143
|
+
entry.value = found
|
144
|
+
end
|
145
|
+
end
|
131
146
|
end
|
132
147
|
|
133
148
|
def message(string)
|
134
149
|
parent.status.message(string)
|
135
150
|
end
|
136
151
|
end
|
137
|
-
end
|
152
|
+
end
|