ver 2009.10.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (188) hide show
  1. data/CHANGELOG +1404 -0
  2. data/MANIFEST +187 -0
  3. data/Rakefile +30 -0
  4. data/TODO +169 -0
  5. data/bin/ver +19 -0
  6. data/config/detect.rb +109 -0
  7. data/config/keymap/vim.rb +239 -0
  8. data/config/rc.rb +0 -0
  9. data/config/scratch +3 -0
  10. data/config/syntax/ANTLR.json +275 -0
  11. data/config/syntax/ASP VB.net.json +228 -0
  12. data/config/syntax/ASP.json +135 -0
  13. data/config/syntax/ActionScript.json +168 -0
  14. data/config/syntax/Ada.json +108 -0
  15. data/config/syntax/Apache.json +342 -0
  16. data/config/syntax/AppleScript.json +721 -0
  17. data/config/syntax/Bibtex.json +253 -0
  18. data/config/syntax/Blog (HTML).json +47 -0
  19. data/config/syntax/Blog (Markdown).json +50 -0
  20. data/config/syntax/Blog (Text).json +45 -0
  21. data/config/syntax/Blog (Textile).json +45 -0
  22. data/config/syntax/Bulletin Board.json +428 -0
  23. data/config/syntax/C++.json +323 -0
  24. data/config/syntax/C.json +694 -0
  25. data/config/syntax/CSS.json +346 -0
  26. data/config/syntax/DOT.json +79 -0
  27. data/config/syntax/Diff.json +136 -0
  28. data/config/syntax/Dylan.json +104 -0
  29. data/config/syntax/Eiffel.json +128 -0
  30. data/config/syntax/Erlang.json +1636 -0
  31. data/config/syntax/F-Script.json +137 -0
  32. data/config/syntax/FXScript.json +260 -0
  33. data/config/syntax/Gri.json +141 -0
  34. data/config/syntax/HTML (Mason).json +207 -0
  35. data/config/syntax/HTML (Rails).json +52 -0
  36. data/config/syntax/HTML (Tcl).json +42 -0
  37. data/config/syntax/HTML for ASP.net.json +736 -0
  38. data/config/syntax/HTML-ASP.json +45 -0
  39. data/config/syntax/HTML.json +614 -0
  40. data/config/syntax/Haskell.json +407 -0
  41. data/config/syntax/Inform.json +80 -0
  42. data/config/syntax/Ini.json +91 -0
  43. data/config/syntax/Io.json +142 -0
  44. data/config/syntax/Java.json +745 -0
  45. data/config/syntax/JavaProperties.json +42 -0
  46. data/config/syntax/JavaScript.json +446 -0
  47. data/config/syntax/LaTeX Beamer.json +65 -0
  48. data/config/syntax/LaTeX Log.json +88 -0
  49. data/config/syntax/LaTeX.json +962 -0
  50. data/config/syntax/Lighttpd.json +93 -0
  51. data/config/syntax/Lisp.json +101 -0
  52. data/config/syntax/Literate Haskell.json +55 -0
  53. data/config/syntax/Logtalk.json +289 -0
  54. data/config/syntax/Lua.json +146 -0
  55. data/config/syntax/M.json +744 -0
  56. data/config/syntax/MEL.json +161 -0
  57. data/config/syntax/MIPS.json +114 -0
  58. data/config/syntax/Mail.json +224 -0
  59. data/config/syntax/Makefile.json +66 -0
  60. data/config/syntax/Markdown.json +644 -0
  61. data/config/syntax/Modula-3.json +80 -0
  62. data/config/syntax/Movable Type.json +348 -0
  63. data/config/syntax/OCaml.json +1391 -0
  64. data/config/syntax/Objective-C++.json +21 -0
  65. data/config/syntax/OpenGL.json +24 -0
  66. data/config/syntax/PHP.json +2184 -0
  67. data/config/syntax/Pascal.json +128 -0
  68. data/config/syntax/Perl.json +2091 -0
  69. data/config/syntax/Plain text.json +49 -0
  70. data/config/syntax/Processing.json +188 -0
  71. data/config/syntax/Quake3 Config.json +54 -0
  72. data/config/syntax/R.json +157 -0
  73. data/config/syntax/Rez.json +137 -0
  74. data/config/syntax/Ruby on Rails.json +170 -0
  75. data/config/syntax/Ruby.json +1753 -0
  76. data/config/syntax/SQL (Rails).json +31 -0
  77. data/config/syntax/SQL.json +435 -0
  78. data/config/syntax/SWIG.json +96 -0
  79. data/config/syntax/Scheme.json +359 -0
  80. data/config/syntax/Shell-Unix-Generic.json +1198 -0
  81. data/config/syntax/Slate.json +265 -0
  82. data/config/syntax/Smarty.json +110 -0
  83. data/config/syntax/Standard ML.json +322 -0
  84. data/config/syntax/Subversion commit message.json +62 -0
  85. data/config/syntax/Tcl.json +278 -0
  86. data/config/syntax/TeX Math.json +83 -0
  87. data/config/syntax/TeX.json +157 -0
  88. data/config/syntax/Textile.json +273 -0
  89. data/config/syntax/Twiki.json +436 -0
  90. data/config/syntax/Vectorscript.json +97 -0
  91. data/config/syntax/XML strict.json +148 -0
  92. data/config/syntax/XML.json +301 -0
  93. data/config/syntax/XSL.json +96 -0
  94. data/config/syntax/YAML.json +293 -0
  95. data/config/syntax/iCalendar.json +51 -0
  96. data/config/syntax/reStructuredText.json +403 -0
  97. data/config/theme/Active4D.json +260 -0
  98. data/config/theme/All Hallow's Eve.json +171 -0
  99. data/config/theme/Amy.json +359 -0
  100. data/config/theme/BBEdit.json +269 -0
  101. data/config/theme/Bespin.json +322 -0
  102. data/config/theme/Blackboard.json +215 -0
  103. data/config/theme/BoysAndGirls01.json +156 -0
  104. data/config/theme/Brilliance Black.json +1695 -0
  105. data/config/theme/Brilliance Dull.json +1451 -0
  106. data/config/theme/Classic Modified.json +288 -0
  107. data/config/theme/Cobalt.json +345 -0
  108. data/config/theme/Cool Glow.json +215 -0
  109. data/config/theme/Dawn.json +258 -0
  110. data/config/theme/Eiffel.json +270 -0
  111. data/config/theme/Espresso Libre.json +247 -0
  112. data/config/theme/Fluidvision.json +272 -0
  113. data/config/theme/IDLE.json +159 -0
  114. data/config/theme/LAZY.json +178 -0
  115. data/config/theme/Mac Classic.json +277 -0
  116. data/config/theme/MagicWB (Amiga).json +231 -0
  117. data/config/theme/Merbivore Soft.json +181 -0
  118. data/config/theme/Merbivore.json +181 -0
  119. data/config/theme/Monokai.json +177 -0
  120. data/config/theme/Notepad2.json +166 -0
  121. data/config/theme/Pastels on Dark.json +437 -0
  122. data/config/theme/RubyBlue.json +226 -0
  123. data/config/theme/Sin City 2.json +361 -0
  124. data/config/theme/Slate.json +270 -0
  125. data/config/theme/Slush & Poppies.json +232 -0
  126. data/config/theme/SpaceCadet.json +143 -0
  127. data/config/theme/Sunburst.json +415 -0
  128. data/config/theme/Twilight BG FG.json +633 -0
  129. data/config/theme/Twilight.json +321 -0
  130. data/config/theme/Whys Poignant.json +119 -0
  131. data/config/theme/Zenburnesque.json +237 -0
  132. data/config/theme/barf.json +155 -0
  133. data/config/theme/fake.json +418 -0
  134. data/config/theme/happydeluxe.json +114 -0
  135. data/config/theme/iLife 05.json +393 -0
  136. data/config/theme/iPlastic.json +177 -0
  137. data/config/theme/mintBlue Dark.json +414 -0
  138. data/config/theme/mintBlue.json +415 -0
  139. data/config/theme/monoindustrial.json +276 -0
  140. data/config/theme/starlight.json +67 -0
  141. data/config/tutorial +74 -0
  142. data/config/welcome +115 -0
  143. data/help/index.verh +14 -0
  144. data/lib/ver.rb +156 -0
  145. data/lib/ver/entry.rb +97 -0
  146. data/lib/ver/keymap.rb +96 -0
  147. data/lib/ver/layout.rb +107 -0
  148. data/lib/ver/methods.rb +19 -0
  149. data/lib/ver/methods/completion.rb +116 -0
  150. data/lib/ver/methods/control.rb +340 -0
  151. data/lib/ver/methods/insert.rb +6 -0
  152. data/lib/ver/methods/move.rb +65 -0
  153. data/lib/ver/methods/search.rb +33 -0
  154. data/lib/ver/methods/select.rb +145 -0
  155. data/lib/ver/methods/views.rb +21 -0
  156. data/lib/ver/mode.rb +160 -0
  157. data/lib/ver/options.rb +207 -0
  158. data/lib/ver/plist.rb +106 -0
  159. data/lib/ver/status.rb +67 -0
  160. data/lib/ver/syntax.rb +68 -0
  161. data/lib/ver/syntax/detector.rb +53 -0
  162. data/lib/ver/syntax/processor.rb +48 -0
  163. data/lib/ver/text.rb +374 -0
  164. data/lib/ver/textpow.rb +357 -0
  165. data/lib/ver/theme.rb +162 -0
  166. data/lib/ver/vendor/fuzzy_file_finder.rb +340 -0
  167. data/lib/ver/view.rb +163 -0
  168. data/lib/ver/view/entry.rb +28 -0
  169. data/lib/ver/view/list.rb +137 -0
  170. data/lib/ver/view/list/buffer.rb +27 -0
  171. data/lib/ver/view/list/fuzzy_file_finder.rb +44 -0
  172. data/lib/ver/view/list/syntax.rb +13 -0
  173. data/lib/ver/view/list/theme.rb +13 -0
  174. data/spec/keymap.rb +224 -0
  175. data/tasks/bacon.rake +49 -0
  176. data/tasks/changelog.rake +18 -0
  177. data/tasks/gem.rake +22 -0
  178. data/tasks/gem_installer.rake +76 -0
  179. data/tasks/grancher.rake +12 -0
  180. data/tasks/install_dependencies.rake +6 -0
  181. data/tasks/manifest.rake +4 -0
  182. data/tasks/plist2json.rake +35 -0
  183. data/tasks/rcov.rake +18 -0
  184. data/tasks/release.rake +12 -0
  185. data/tasks/reversion.rake +8 -0
  186. data/tasks/syntax_list.rake +31 -0
  187. data/ver.gemspec +29 -0
  188. metadata +241 -0
@@ -0,0 +1,67 @@
1
+ {
2
+ "name": "Starlight",
3
+ "settings": [
4
+ {
5
+ "settings": {
6
+ "background": "#223859F2",
7
+ "caret": "#D0C179",
8
+ "foreground": "#C0B6A8",
9
+ "invisibles": "#BFBFBF",
10
+ "lineHighlight": "#0000001F",
11
+ "selection": "#50729C"
12
+ }
13
+ },
14
+ {
15
+ "name": "Comment",
16
+ "scope": "comment",
17
+ "settings": {
18
+ "fontStyle": "",
19
+ "foreground": "#AEAEAE"
20
+ }
21
+ },
22
+ {
23
+ "name": "String",
24
+ "scope": "string",
25
+ "settings": {
26
+ "fontStyle": "",
27
+ "foreground": "#B9A185"
28
+ }
29
+ },
30
+ {
31
+ "name": "Number",
32
+ "scope": "constant.numeric",
33
+ "settings": {
34
+ "foreground": "#B9A185"
35
+ }
36
+ },
37
+ {
38
+ "name": "Keyword",
39
+ "scope": "keyword",
40
+ "settings": {
41
+ "fontStyle": "",
42
+ "foreground": "#A38474"
43
+ }
44
+ },
45
+ {
46
+ "name": "Entity",
47
+ "settings": {
48
+ "foreground": "#B8ADA0"
49
+ }
50
+ },
51
+ {
52
+ "name": "Variable",
53
+ "scope": "variable",
54
+ "settings": {
55
+ "foreground": "#A19A83"
56
+ }
57
+ },
58
+ {
59
+ "name": "Invalid",
60
+ "scope": "invalid",
61
+ "settings": {
62
+ "foreground": "#F3D651"
63
+ }
64
+ }
65
+ ],
66
+ "uuid": "750AEFCD-88F3-4E2C-9560-1CF215A393C9"
67
+ }
data/config/tutorial ADDED
@@ -0,0 +1,74 @@
1
+ =====================================================================
2
+ = Welcome to the VER Tutor - Version 2009.09 =
3
+ ================================================
4
+
5
+ VER is a very powerful editor that has many commands, too many to
6
+ explain in a tutor such as this. This tutor is designed to describe
7
+ enough of the commands that you will be able to easily use VER as
8
+ an all-purpose editor.
9
+
10
+ The approximate time required to complete the tutor is 25-30 minutes,
11
+ depending upon how much time is spent with experimentation.
12
+
13
+ ATTENTION:
14
+ The commands in the lessons will modify the text. Make a copy of this
15
+ file to practise on (if you started "vertutor" this is already a copy).
16
+
17
+ It is important to remember that this tutor is set up to teach by
18
+ use. That means that you need to execute the commands to learn them
19
+ properly. If you only read the text, you will forget the commands!
20
+
21
+ Now, make sure that your Shift-Lock key is NOT depressed and press
22
+ the j key enough times to move the cursor so that Lesson 1.1
23
+ completely fills the screen.
24
+
25
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
26
+ Lesson 1.1: MOVING THE CURSOR
27
+
28
+
29
+ To move the cursor, press the h,j,k,l keys as indicated.
30
+
31
+ ^
32
+ k Hint: The h key is at the left and moves left.
33
+ < h l > The l key is at the right and moves right.
34
+ j The j key looks like a down arrow.
35
+ v
36
+
37
+ 1. Move the cursor around the screen until you are comfortable.
38
+
39
+ 2. Hold down the down key (j) until it repeats.
40
+ Now you know how to move to the next lesson.
41
+
42
+ 3. Using the down key, move to Lesson 1.2.
43
+
44
+ NOTE: If you are ever unsure about something you typed, press <ESC> to place
45
+ you in Normal mode. Then retype the command you wanted.
46
+
47
+ NOTE: The cursor keys should also work. But using hjkl you will be able to
48
+ move around much faster, once you get used to it. Really!
49
+
50
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
51
+ Lesson 1.2: EXITING VIM
52
+
53
+
54
+ !! NOTE: Before executing any of the steps below, read this entire lesson!!
55
+
56
+ 1. Press the <ESC> key (to make sure you are in Normal mode).
57
+
58
+ 2. Type: :q! <ENTER>.
59
+ This exits the editor, DISCARDING any changes you have made.
60
+
61
+ 3. When you see the shell prompt, type the command that got you into this
62
+ tutor. That would be: vimtutor <ENTER>
63
+
64
+ 4. If you have these steps memorized and are confident, execute steps
65
+ 1 through 3 to exit and re-enter the editor.
66
+
67
+ NOTE: :q! <ENTER> discards any changes you made. In a few lessons you
68
+ will learn how to save the changes to a file.
69
+
70
+ 5. Move the cursor down to Lesson 1.3.
71
+
72
+
73
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
74
+ Lesson 1.3: TEXT EDITING - DELETION
data/config/welcome ADDED
@@ -0,0 +1,115 @@
1
+ ====================================================
2
+ = Welcome to VER, the Vim & Emacs in Ruby editor =
3
+ ====================================================
4
+
5
+ This project can be found at: http://github.com/manveru/ver
6
+
7
+ Notes:
8
+ * M usually stands for the alt key on your keyboard.
9
+
10
+ Various help commands (all not implemented yet):
11
+ [M-h h] : Open help browser
12
+ [M-h k] : Query help for key
13
+ [M-h g] : Grep help
14
+ [M-h t] : Open tutorial
15
+
16
+ Quick intro:
17
+
18
+ VER is a modal editor, drawing from both Emacs and Vim for inspiration, as they are both excellent projects but have very different downsides.
19
+ I tried to address these downsides:
20
+
21
+ * Use of a real programming language (Ruby) for implementation, configuration and scripting (no ancient elisp or crazy vimscript)
22
+ * Easy to use keymappings to emulate other editors while maintaining the strength of a live environment.
23
+ * I don't intend this editor to be everything for everybody, it's just useful for myself for now.
24
+ * Make editing powerful without years of learning and remembering arcane shortcuts, and don't require users of the editor to sacrifice their wrists.
25
+ * Allow project-based browsing and grepping right from the start.
26
+ * Easily identify the mode you are in by looking at the color of the status line and cursor.
27
+
28
+ Currently working:
29
+
30
+ * [C-x] : Eval a line of ruby
31
+ * [C-e] : Eval current line and output result below
32
+ * Buffers
33
+ * [C-s] : Save buffer contents to file
34
+ * Opening new buffers
35
+ * [M-o] : Fuzzy file browser (only use for projects)
36
+ * [C-o] : Normal file browser (fast for anything, but less magic)
37
+ * [C-g] : Grep browser, grep all files and jump to matches
38
+ * Switching buffers
39
+ * [M-1] to [M-9] : Quick switching buffers
40
+ * [M-b] : Switching buffers by partial name
41
+ * [C-q] : Exit current mode or close VER
42
+ * [C-w] : Close current buffer (requires confirmation if buffer was modified)
43
+ * Selection, Copy, Paste
44
+ * Starting selection
45
+ * [v] : charwise
46
+ * [V] : linewise
47
+ * [C-v] : blockwise
48
+ * Once selection is active, you can switch between these selection modes
49
+ with the same keys.
50
+ So, if you started charwise selection but would like to select
51
+ blockwise instead, just hit [C-v]
52
+ * Copy to clipboard
53
+ * [y] : copy current selection
54
+ * [Y] : copy the full lines touched by current selection
55
+ * Paste from clipboard
56
+ * [p] : paste after current cursor position
57
+ * [P] : paste before current cursor position
58
+ * Indent
59
+ * [>] : Indent selection
60
+ * [<] : Unindent selection
61
+ * Filter
62
+ * [!] : Filter selection through external program
63
+ * [M-e] : Eval selection and output result below
64
+ * Syntax highlighting
65
+ - No keys associated, the syntax is detected by filename extension for now.
66
+ - Trailing newlines are highlighted by default.
67
+ * Searching
68
+ * [/] : Start searching by regular expression
69
+ * [n] : Jump to next search result
70
+ * [N] : Jump to previous search result
71
+ * Indentation
72
+ * [>] : Indent line
73
+ * [<] : Unindent line
74
+ * Movement
75
+ * Basic
76
+ * [j] : Line down
77
+ * [k] : Line up
78
+ * [h] : Char left
79
+ * [l] : Char right
80
+ * Jumps
81
+ * [w] : Word right
82
+ * [W] : Chunk right
83
+ * [b] : Word left
84
+ * [B] : Chunk left
85
+ * [0] : Beginning of line
86
+ * [$] : End of line
87
+ * [G] : Last line
88
+ * [g g] : First line
89
+ * [C-f] or [npage] : One page down
90
+ * [C-b] or [ppage] : One page up
91
+ * [0 g], [50 g], [100 g], ... : Jump to given line
92
+ * Completion
93
+ * [tab] : Last used completion, if first time it defaults to word completion
94
+ * [C-x C-w] : Word completion
95
+ * [C-x C-l] : Full line completion
96
+ * [C-x C-f] : Filename completion
97
+ * [C-x C-s] : spelling completion (needs aspell)
98
+
99
+
100
+ How to run VER:
101
+
102
+ First, make sure that you have the bin/ directory in your PATH.
103
+ On startup you can choose which keymap to use, VER currently ships with two: vi and diakonos. The vi mapping is the default.
104
+
105
+ ver -k diakonos
106
+ ver -k vi
107
+
108
+
109
+ Todo:
110
+
111
+ - [M-s] : Save file under different name
112
+ - [M-x] : Live ruby console (figure out some nice way)
113
+ - FFI bindings for X11 so we can communicate with it and have a proper clipboard (xclip is weak)
114
+ - Proper handling of [esc], halfdelay works if it's called later, but makes other control characters send signals.
115
+ - Handling tabs
data/help/index.verh ADDED
@@ -0,0 +1,14 @@
1
+ * VER Help system
2
+
3
+ ** Control keymappings
4
+
5
+ To exit: C-q
6
+ To open a file: C-o
7
+ To close a file: C-w
8
+ To save a buffer: C-s
9
+ To select a buffer: C-b
10
+ To go to insert mode: i
11
+
12
+ ** Insert mode keymappings
13
+
14
+ To go to control mode: C-c
data/lib/ver.rb ADDED
@@ -0,0 +1,156 @@
1
+ # Well begun is half done.
2
+ # -- Aristotle
3
+
4
+ # TODO: remove before release
5
+ $LOAD_PATH.unshift File.expand_path('../', __FILE__)
6
+
7
+ # stdlib
8
+ require 'tk'
9
+ require 'benchmark'
10
+ require 'digest/sha1'
11
+ require 'fileutils'
12
+ require 'json'
13
+ require 'pathname'
14
+ require 'pp'
15
+ require 'securerandom'
16
+ require 'set'
17
+ require 'tmpdir'
18
+
19
+ class Pathname
20
+ alias / join
21
+
22
+ def cp(dest)
23
+ FileUtils.copy_file(expand_path.to_s, dest.to_s, preserve = true)
24
+ end
25
+
26
+ def =~(regexp)
27
+ to_s =~ regexp
28
+ end
29
+ end
30
+
31
+ module VER
32
+ autoload :BufferListView, 'ver/view/buffer_list_view'
33
+ autoload :Entry, 'ver/entry'
34
+ autoload :FuzzyFileFinderView, 'ver/view/fuzzy_file_finder_view'
35
+ autoload :Keymap, 'ver/keymap'
36
+ autoload :Layout, 'ver/layout'
37
+ autoload :ListView, 'ver/view/list_view'
38
+ autoload :Methods, 'ver/methods'
39
+ autoload :Mode, 'ver/mode'
40
+ autoload :Status, 'ver/status'
41
+ autoload :SyntaxListView, 'ver/view/syntax_list_view'
42
+ autoload :Syntax, 'ver/syntax'
43
+ autoload :Text, 'ver/text'
44
+ autoload :Textpow, 'ver/textpow'
45
+ autoload :Theme, 'ver/theme'
46
+ autoload :ThemeListView, 'ver/view/theme_list_view'
47
+ autoload :View, 'ver/view'
48
+
49
+ home_conf_dir = Pathname('~/.config/ver').expand_path
50
+ core_conf_dir = Pathname(File.expand_path('../../config/', __FILE__))
51
+
52
+ # poor man's option system
53
+ # p Tk::Tile.themes # a list of available themes
54
+ # Linux themes: "classic", "default", "clam", "alt"
55
+ OPTIONS = {
56
+ font: TkFont.new(family: 'Terminus', size: 9),
57
+ tk_theme: 'clam',
58
+ theme: 'Blackboard',
59
+ keymap: 'vim',
60
+ global_quit: 'Control-q',
61
+ home_conf_dir: home_conf_dir,
62
+ core_conf_dir: core_conf_dir,
63
+ loadpath: [home_conf_dir, core_conf_dir],
64
+ }
65
+
66
+ class << self
67
+ attr_reader :root, :layout, :status, :paths, :options
68
+ end
69
+
70
+ module_function
71
+
72
+ def loadpath
73
+ options[:loadpath]
74
+ end
75
+
76
+ def run(given_options = {})
77
+ @options = OPTIONS.merge(given_options)
78
+
79
+ setup
80
+ first_startup unless options[:home_conf_dir].directory?
81
+ load 'rc'
82
+ open_argv || open_welcome
83
+ emergency_bindings
84
+
85
+ rescue => exception
86
+ puts "#{exception.class}: #{exception}", *exception.backtrace
87
+ Tk.exit
88
+ else
89
+ Tk.mainloop
90
+ end
91
+
92
+ def setup
93
+ Thread.abort_on_exception = true
94
+
95
+ Tk::Tile.set_theme options[:tk_theme]
96
+
97
+ @paths = Set.new
98
+ @root = TkRoot.new
99
+ @layout = Layout.new(@root)
100
+ @layout.strategy = Layout::VerticalTiling
101
+ end
102
+
103
+ def first_startup
104
+ home, core = options.values_at(:home_conf_dir, :core_conf_dir)
105
+ home.mkpath
106
+
107
+ (core/'rc.rb').cp(home/'rc.rb')
108
+ (core/'scratch').cp(home/'scratch')
109
+ (core/'tutorial').cp(home/'tutorial')
110
+ (core/'welcome').cp(home/'welcome')
111
+ end
112
+
113
+ def load(name)
114
+ loadpath.each do |path|
115
+ file = File.join(path, name)
116
+
117
+ begin
118
+ require(file)
119
+ return
120
+ rescue LoadError
121
+ end
122
+ end
123
+ end
124
+
125
+ def find_in_loadpath(basename)
126
+ loadpath.each do |dirname|
127
+ file = dirname/basename
128
+ return file if file.file?
129
+ end
130
+
131
+ nil
132
+ end
133
+
134
+ def open_argv
135
+ ARGV.each{|arg|
136
+ layout.create_view do |view|
137
+ view.open_path(arg)
138
+ end
139
+ }.any?
140
+ end
141
+
142
+ def open_welcome
143
+ layout.create_view do |view|
144
+ welcome = find_in_loadpath('welcome')
145
+ view.open_path(welcome)
146
+ end
147
+ end
148
+
149
+ def emergency_bindings
150
+ Tk.bind :all, options[:global_quit], proc{ exit }
151
+ end
152
+
153
+ def opened_file(text)
154
+ @paths << text.filename
155
+ end
156
+ end
data/lib/ver/entry.rb ADDED
@@ -0,0 +1,97 @@
1
+ module VER
2
+ # A custom widget for easier integration
3
+ #
4
+ # The style related things are needed for Tk versions around 8.5.7, which is what everybody is using currently.
5
+ # It doesn't GC styles of widgets that are no longer used, so if we simply keep using new style names, we would eventually run out of memory.
6
+ # A small leak, but better we cover this now than tracking it down later.
7
+ # Tk should get some user states, called like 'user1', 'user2', 'user3', that would allow some flexibility, but still won't be able to represent every mode.
8
+ class Entry < Tk::Tile::Entry
9
+ STYLE_NAME_REGISTER = []
10
+ STYLE_NAME_POOL = []
11
+
12
+ def self.obtain_style_name
13
+ unless style_name = STYLE_NAME_POOL.shift
14
+ begin
15
+ id = SecureRandom.hex
16
+ style_name = "#{id}.#{self}.TEntry"
17
+ end while STYLE_NAME_REGISTER.include?(style_name)
18
+ STYLE_NAME_REGISTER << style_name
19
+ end
20
+
21
+ style_name
22
+ end
23
+
24
+ def self.return_style_name(style_name)
25
+ STYLE_NAME_POOL << style_name
26
+ end
27
+
28
+ def style
29
+ style = cget(:style)
30
+ style.flatten.first if style
31
+ end
32
+
33
+ def quit
34
+ Tk.exit
35
+ end
36
+
37
+ def value=(string)
38
+ super
39
+ Tk.event_generate(self, '<Modified>')
40
+ end
41
+
42
+ def delete(*args)
43
+ super
44
+ Tk.event_generate(self, '<Modified>')
45
+ end
46
+
47
+ def insert(*args)
48
+ super
49
+ Tk.event_generate(self, '<Modified>')
50
+ end
51
+
52
+ def message(string)
53
+ self.value = string
54
+ end
55
+
56
+ def error(string)
57
+ self.value = string
58
+ end
59
+
60
+ def insert_string(string)
61
+ insert cursor, string
62
+ end
63
+
64
+ def delete_char_left
65
+ delete(cursor - 1)
66
+ end
67
+
68
+ def delete_char_right
69
+ delete(cursor)
70
+ end
71
+
72
+ def go_char_left
73
+ self.cursor = cursor - 1
74
+ end
75
+
76
+ def go_char_right
77
+ self.cursor = cursor + 1
78
+ end
79
+
80
+ def go_word_left
81
+ if index = value.rindex(/.\b\s/, cursor - 1)
82
+ self.cursor = index
83
+ else
84
+ self.cursor = 0
85
+ end
86
+ end
87
+
88
+ def go_word_right
89
+ if match = value.match(/\s\b/, cursor)
90
+ offset_from, offset_to = match.offset(0)
91
+ self.cursor = offset_to
92
+ else
93
+ self.cursor = :end
94
+ end
95
+ end
96
+ end
97
+ end