vimamsa 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/vimamsa +4 -2
- data/lib/vimamsa/ack.rb +0 -4
- data/lib/vimamsa/actions.rb +20 -32
- data/lib/vimamsa/buffer.rb +23 -16
- data/lib/vimamsa/buffer_list.rb +3 -3
- data/lib/vimamsa/debug.rb +6 -6
- data/lib/vimamsa/easy_jump.rb +129 -125
- data/lib/vimamsa/editor.rb +29 -28
- data/lib/vimamsa/file_finder.rb +2 -2
- data/lib/vimamsa/file_history.rb +12 -5
- data/lib/vimamsa/gui.rb +561 -0
- data/lib/vimamsa/gui_gtk_sourceview.rb +294 -0
- data/lib/vimamsa/gui_menu.rb +100 -0
- data/lib/vimamsa/gui_select_window.rb +177 -0
- data/lib/vimamsa/gui_sourceview.rb +294 -0
- data/lib/vimamsa/{default_key_bindings.rb → key_actions.rb} +64 -189
- data/lib/vimamsa/key_binding_tree.rb +21 -9
- data/lib/vimamsa/key_bindings_vimlike.rb +259 -0
- data/lib/vimamsa/macro.rb +1 -1
- data/lib/vimamsa/main.rb +1 -2
- data/lib/vimamsa/rbvma.rb +16 -1023
- data/lib/vimamsa/search.rb +0 -4
- data/lib/vimamsa/search_replace.rb +1 -2
- data/lib/vimamsa/version.rb +1 -1
- metadata +9 -3
@@ -53,7 +53,7 @@ end
|
|
53
53
|
|
54
54
|
class KeyBindingTree
|
55
55
|
attr_accessor :C, :I, :cur_state, :root, :match_state, :last_action, :cur_action
|
56
|
-
attr_reader :mode_root_state, :state_trail
|
56
|
+
attr_reader :mode_root_state, :state_trail, :act_bindings
|
57
57
|
|
58
58
|
def initialize()
|
59
59
|
@modes = {}
|
@@ -67,6 +67,10 @@ class KeyBindingTree
|
|
67
67
|
|
68
68
|
@modifiers = [] # TODO: create a queue
|
69
69
|
@last_event = [nil, nil, nil, nil, nil]
|
70
|
+
|
71
|
+
@override_keyhandling_callback = nil
|
72
|
+
# Allows h["foo"]["faa"]=1
|
73
|
+
@act_bindings = Hash.new { |h, k| h[k] = Hash.new(&h.default_proc) }
|
70
74
|
end
|
71
75
|
|
72
76
|
def set_default_mode(label)
|
@@ -110,6 +114,14 @@ class KeyBindingTree
|
|
110
114
|
return nil
|
111
115
|
end
|
112
116
|
|
117
|
+
def set_keyhandling_override(_callback)
|
118
|
+
@override_keyhandling_callback = _callback
|
119
|
+
end
|
120
|
+
|
121
|
+
def remove_keyhandling_override()
|
122
|
+
@override_keyhandling_callback = nil
|
123
|
+
end
|
124
|
+
|
113
125
|
def match(key_name)
|
114
126
|
new_state = []
|
115
127
|
@match_state.each { |parent|
|
@@ -129,9 +141,7 @@ class KeyBindingTree
|
|
129
141
|
end
|
130
142
|
}
|
131
143
|
}
|
132
|
-
|
133
|
-
# Ripl.start :binding => binding
|
134
|
-
end
|
144
|
+
|
135
145
|
|
136
146
|
if new_state.any? # Match found
|
137
147
|
@match_state = new_state
|
@@ -242,8 +252,10 @@ class KeyBindingTree
|
|
242
252
|
# $cur_key_dict = $key_bind_dict[$context[:mode]]
|
243
253
|
print "MATCH KEY CONF: #{[c, translated_c]}" if $debug
|
244
254
|
|
245
|
-
|
246
|
-
|
255
|
+
if !@override_keyhandling_callback.nil?
|
256
|
+
ret = @override_keyhandling_callback.call(c, event_type)
|
257
|
+
return if ret
|
258
|
+
end
|
247
259
|
|
248
260
|
eval_s = nil
|
249
261
|
|
@@ -306,7 +318,6 @@ class KeyBindingTree
|
|
306
318
|
# act_s = cstate.action.to_s if cstate.action != nil
|
307
319
|
# puts " #{cstate.to_s} #{act_s}"
|
308
320
|
# end
|
309
|
-
# Ripl.start :binding => binding
|
310
321
|
# new_state[0].children.collect{|x|x.to_s}
|
311
322
|
end
|
312
323
|
|
@@ -328,7 +339,7 @@ class KeyBindingTree
|
|
328
339
|
|
329
340
|
printf("\n") if $debug
|
330
341
|
else
|
331
|
-
|
342
|
+
|
332
343
|
# Don't execute action if one of the states has children
|
333
344
|
state_with_children = new_state.select { |s| s.children.any? }
|
334
345
|
s_act = new_state.select { |s| s.action != nil }
|
@@ -432,7 +443,7 @@ class KeyBindingTree
|
|
432
443
|
@last_event = event #TODO: outside if?
|
433
444
|
end
|
434
445
|
|
435
|
-
#
|
446
|
+
# gui_refresh_cursor
|
436
447
|
|
437
448
|
event_handle_time = Time.now - t1
|
438
449
|
debug "RB key event handle time: #{event_handle_time}" if event_handle_time > 1 / 40.0
|
@@ -484,6 +495,7 @@ class KeyBindingTree
|
|
484
495
|
|
485
496
|
modes.each { |mode_id|
|
486
497
|
mode_bind_key(mode_id, keydef, action)
|
498
|
+
@act_bindings[mode_id][action] = keydef
|
487
499
|
}
|
488
500
|
end
|
489
501
|
|
@@ -0,0 +1,259 @@
|
|
1
|
+
|
2
|
+
bindkey ["VCB M","B m"], :run_last_macro
|
3
|
+
|
4
|
+
bindkey "VC s", :easy_jump
|
5
|
+
bindkey "VC , m f", [:find_macro_gui, proc{$macro.find_macro_gui}, "Find named macro"]
|
6
|
+
bindkey "C , m n", [:gui_name_macro, proc{$macro.gui_name_macro}, "Name last macro"]
|
7
|
+
bindkey "C , j r", :jump_to_random
|
8
|
+
bindkey "I enter", :insert_new_line
|
9
|
+
bindkey "C , ; s k", :show_key_bindings #TODO: better binding
|
10
|
+
bindkey "C , , c b", :put_file_path_to_clipboard #TODO: better binding or remove?
|
11
|
+
bindkey "C , , e", :encrypt_file #TODO: better binding
|
12
|
+
bindkey "C , ; u", :set_unencrypted #TODO: better binding
|
13
|
+
bindkey "C , c b", :close_current_buffer
|
14
|
+
bindkey "V ctrl-c", :comment_selection
|
15
|
+
bindkey "C x", :delete_char_forward
|
16
|
+
bindkey "C , , l t", :load_theme
|
17
|
+
bindkey "C , f", :gui_file_finder
|
18
|
+
bindkey "C , h", :gui_file_history_finder
|
19
|
+
bindkey "C , r r", :gui_search_replace
|
20
|
+
bindkey "V , r r", :gui_search_replace
|
21
|
+
bindkey "V , t b", :set_style_bold
|
22
|
+
bindkey "V , t l", :set_style_link
|
23
|
+
bindkey "V J", :V_join_lines
|
24
|
+
bindkey "V , t c", :clear_formats
|
25
|
+
bindkey "C , t h", :set_line_style_heading
|
26
|
+
bindkey "C , t 1", :set_line_style_h1
|
27
|
+
bindkey "C , t 2", :set_line_style_h2
|
28
|
+
bindkey "C , t 3", :set_line_style_h3
|
29
|
+
bindkey "C , t 4", :set_line_style_h4
|
30
|
+
bindkey "C , t b", :set_line_style_bold
|
31
|
+
bindkey "C , t t", :set_line_style_title
|
32
|
+
bindkey "C , t c", :clear_line_styles
|
33
|
+
bindkey "C , b", :gui_select_buffer
|
34
|
+
# bindkey "C , f o", :open_file_dialog
|
35
|
+
bindkey "CI ctrl-o", :open_file_dialog
|
36
|
+
# bindkey "M enter", :minibuffer_end
|
37
|
+
bindkey "C , a", :ack_search
|
38
|
+
bindkey "C d w", :delete_to_word_end
|
39
|
+
bindkey "C d 0", :delete_to_line_start
|
40
|
+
bindkey "C , , f", :file_finder
|
41
|
+
bindkey "VC h", :e_move_backward_char
|
42
|
+
bindkey "C , , .", :backup_all_buffers
|
43
|
+
bindkey "C z ", :start_browse_mode
|
44
|
+
bindkey "B h", :history_switch_backwards
|
45
|
+
bindkey "B l", :history_switch_forwards
|
46
|
+
#bindkey 'B z', :center_on_current_line
|
47
|
+
bindkey "B z", "center_on_current_line();call(:exit_browse_mode)"
|
48
|
+
bindkey "B enter || B return || B esc || B j || B ctrl!", :exit_browse_mode
|
49
|
+
bindkey "B s", :page_up
|
50
|
+
bindkey "B d", :page_down
|
51
|
+
bindkey "B s", :page_up
|
52
|
+
bindkey "B d", :page_down
|
53
|
+
bindkey "B i", :jump_to_start_of_buffer
|
54
|
+
bindkey "B o", :jump_to_end_of_buffer
|
55
|
+
bindkey "B c", :close_current_buffer
|
56
|
+
bindkey "B ;", "buf.jump_to_last_edit"
|
57
|
+
bindkey "B q", :jump_to_last_edit
|
58
|
+
bindkey "B w", :jump_to_next_edit
|
59
|
+
bindkey "C , d", :diff_buffer
|
60
|
+
bindkey "C , g", :invoke_grep_search
|
61
|
+
#bindkey 'C , g', proc{invoke_grep_search}
|
62
|
+
bindkey "C , v", :auto_indent_buffer
|
63
|
+
bindkey "C , , d", :savedebug
|
64
|
+
bindkey "C , , u", :update_file_index
|
65
|
+
bindkey "C , s a", :buf_save_as
|
66
|
+
bindkey "C d d", [:delete_line, proc{buf.delete_line}, "Delete current line"]
|
67
|
+
bindkey "C enter || C return", [:line_action,proc{buf.handle_line_action()}, "Line action"]
|
68
|
+
bindkey "C p" , [:paste_after,proc{buf.paste(AFTER)},""] # TODO: implement as replace for visual mode
|
69
|
+
bindkey "V d" , [:delete_selection,proc{buf.delete(SELECTION)},""]
|
70
|
+
|
71
|
+
default_keys = {
|
72
|
+
|
73
|
+
# File handling
|
74
|
+
"C ctrl-s" => :buf_save,
|
75
|
+
|
76
|
+
# Buffer handling
|
77
|
+
"C B" => "bufs.switch",
|
78
|
+
"C tab" => "bufs.switch_to_last_buf",
|
79
|
+
# 'C , s'=> 'gui_select_buffer',
|
80
|
+
"C , r v b" => :buf_revert,
|
81
|
+
"C , c b" => "bufs.close_current_buffer",
|
82
|
+
#"C , b" => '$kbd.set_mode("S");gui_select_buffer',
|
83
|
+
"C , n b" => :buf_new,
|
84
|
+
# "C , , ." => "backup_all_buffers()",
|
85
|
+
"VC , , s" => :search_actions,
|
86
|
+
|
87
|
+
|
88
|
+
# MOVING
|
89
|
+
# 'VC h' => 'buf.move(BACKWARD_CHAR)',
|
90
|
+
"VC l" => "buf.move(FORWARD_CHAR)",
|
91
|
+
"VC j" => "buf.move(FORWARD_LINE)",
|
92
|
+
"VC k" => "buf.move(BACKWARD_LINE)",
|
93
|
+
|
94
|
+
"VC pagedown" => "page_down",
|
95
|
+
"VC pageup" => "page_up",
|
96
|
+
|
97
|
+
"VCI left" => "buf.move(BACKWARD_CHAR)",
|
98
|
+
"VCI right" => "buf.move(FORWARD_CHAR)",
|
99
|
+
"VCI down" => "buf.move(FORWARD_LINE)",
|
100
|
+
"VCI up" => "buf.move(BACKWARD_LINE)",
|
101
|
+
|
102
|
+
"VC w" => "buf.jump_word(FORWARD,WORD_START)",
|
103
|
+
"VC b" => "buf.jump_word(BACKWARD,WORD_START)",
|
104
|
+
"VC e" => "buf.jump_word(FORWARD,WORD_END)",
|
105
|
+
# 'C '=> 'buf.jump_word(BACKWARD,END)',#TODO
|
106
|
+
"VC f <char>" => "buf.jump_to_next_instance_of_char(<char>)",
|
107
|
+
"VC F <char>" => "buf.jump_to_next_instance_of_char(<char>,BACKWARD)",
|
108
|
+
"VC f space" => "buf.jump_to_next_instance_of_char(' ')",
|
109
|
+
"VC F space" => "buf.jump_to_next_instance_of_char(' ',BACKWARD)",
|
110
|
+
|
111
|
+
"VC /[1-9]/" => "set_next_command_count(<char>)",
|
112
|
+
# 'VC number=/[0-9]/+ g'=> 'jump_to_line(<number>)',
|
113
|
+
# 'VC X=/[0-9]/+ * Y=/[0-9]/+ '=> 'x_times_y(<X>,<Y>)',
|
114
|
+
"VC ^" => "buf.jump(BEGINNING_OF_LINE)",
|
115
|
+
"VC G($next_command_count!=nil)" => "buf.jump_to_line()",
|
116
|
+
"VC 0($next_command_count!=nil)" => "set_next_command_count(<char>)",
|
117
|
+
"VC 0($next_command_count==nil)" => "buf.jump(BEGINNING_OF_LINE)",
|
118
|
+
# 'C 0'=> 'buf.jump(BEGINNING_OF_LINE)',
|
119
|
+
"VC g g" => "buf.jump(START_OF_BUFFER)",
|
120
|
+
"VC g ;" => "buf.jump_to_last_edit",
|
121
|
+
"VC G" => "buf.jump(END_OF_BUFFER)",
|
122
|
+
# 'VC z z' => 'center_on_current_line',
|
123
|
+
"VC *" => "buf.jump_to_next_instance_of_word",
|
124
|
+
|
125
|
+
"C , e" => "invoke_command", # Currently eval
|
126
|
+
|
127
|
+
"VC /" => :find_in_buffer,
|
128
|
+
|
129
|
+
# READCHAR bindings
|
130
|
+
|
131
|
+
"R <char>" => "readchar_new_char(<char>)",
|
132
|
+
|
133
|
+
"C n" => "$search.jump_to_next()",
|
134
|
+
"C N" => "$search.jump_to_previous()",
|
135
|
+
|
136
|
+
# Debug
|
137
|
+
"C , d r p" => "start_ripl",
|
138
|
+
"C , D" => "debug_print_buffer",
|
139
|
+
"C , c s" => "bufs.close_scrap_buffers",
|
140
|
+
"C , d b" => "debug_print_buffer",
|
141
|
+
"C , d c" => "debug_dump_clipboard",
|
142
|
+
"C , d d" => "debug_dump_deltas",
|
143
|
+
"VC O" => "buf.jump(END_OF_LINE)",
|
144
|
+
"VC $" => "buf.jump(END_OF_LINE)",
|
145
|
+
|
146
|
+
"C o" => 'buf.jump(END_OF_LINE);buf.insert_txt("\n");$kbd.set_mode(:insert)',
|
147
|
+
"C X" => 'buf.jump(END_OF_LINE);buf.insert_txt("\n");',
|
148
|
+
"C A" => "buf.jump(END_OF_LINE);$kbd.set_mode(:insert)",
|
149
|
+
"C I" => "buf.jump(FIRST_NON_WHITESPACE);$kbd.set_mode(:insert)",
|
150
|
+
"C a" => "buf.move(FORWARD_CHAR);$kbd.set_mode(:insert)",
|
151
|
+
"C J" => "buf.join_lines()",
|
152
|
+
"C u" => "buf.undo()",
|
153
|
+
|
154
|
+
"C ^" => "buf.jump(BEGINNING_OF_LINE)",
|
155
|
+
"C /[1-9]/" => "set_next_command_count(<char>)",
|
156
|
+
|
157
|
+
# Command mode only:
|
158
|
+
"C ctrl-r" => "buf.redo()", # TODO:???
|
159
|
+
"C R" => "buf.redo()",
|
160
|
+
"C v" => "buf.start_visual_mode",
|
161
|
+
"C P" => "buf.paste(BEFORE)", # TODO: implement as replace for visual mode
|
162
|
+
"C space <char>" => "buf.insert_txt(<char>)",
|
163
|
+
"C space space" => "buf.insert_txt(' ')",
|
164
|
+
"C y y" => "buf.copy_line",
|
165
|
+
"C y O" => "buf.copy(:to_line_end)",
|
166
|
+
"C y 0" => "buf.copy(:to_line_start)",
|
167
|
+
"C y e" => "buf.copy(:to_word_end)", # TODO
|
168
|
+
#### Deleting
|
169
|
+
"C x" => "buf.delete(CURRENT_CHAR_FORWARD)",
|
170
|
+
# 'C d k'=> 'delete_line(BACKWARD)', #TODO
|
171
|
+
# 'C d j'=> 'delete_line(FORWARD)', #TODO
|
172
|
+
# 'C d d'=> 'buf.delete_cur_line',
|
173
|
+
"C d e" => "buf.delete2(:to_word_end)",
|
174
|
+
"C d O" => "buf.delete2(:to_line_end)",
|
175
|
+
"C d $" => "buf.delete2(:to_line_end)",
|
176
|
+
# 'C d e'=> 'buf.delete_to_next_word_end',
|
177
|
+
"C d <num> e" => "delete_next_word",
|
178
|
+
"C r <char>" => "buf.replace_with_char(<char>)", # TODO
|
179
|
+
"C , l b" => "load_buffer_list",
|
180
|
+
"C , l l" => "save_buffer_list",
|
181
|
+
"C , r <char>" => "set_register(<char>)", # TODO
|
182
|
+
"C , p <char>" => "buf.paste(BEFORE,<char>)", # TODO
|
183
|
+
|
184
|
+
"C ctrl-c" => "buf.comment_line()",
|
185
|
+
"C ctrl-x" => "buf.comment_line(:uncomment)",
|
186
|
+
|
187
|
+
# 'C 0($next_command_count==nil)'=> 'jump_to_beginning_of_line',
|
188
|
+
|
189
|
+
# Visual mode only:
|
190
|
+
"V esc" => "buf.end_visual_mode",
|
191
|
+
"V ctrl!" => "buf.end_visual_mode",
|
192
|
+
"V y" => "buf.copy_active_selection",
|
193
|
+
"V g U" => "buf.transform_selection(:upcase)",
|
194
|
+
"V g u" => "buf.transform_selection(:downcase)",
|
195
|
+
"V g c" => "buf.transform_selection(:capitalize)",
|
196
|
+
"V g s" => "buf.transform_selection(:swapcase)",
|
197
|
+
"V g r" => "buf.transform_selection(:reverse)",
|
198
|
+
|
199
|
+
"V x" => "buf.delete(SELECTION)",
|
200
|
+
# "V ctrl-c" => "buf.comment_selection",
|
201
|
+
"V ctrl-x" => "buf.comment_selection(:uncomment)",
|
202
|
+
|
203
|
+
"CI ctrl-v" => "buf.paste(BEFORE)",
|
204
|
+
"CI backspace" => "buf.delete(BACKWARD_CHAR)",
|
205
|
+
|
206
|
+
# Marks
|
207
|
+
"CV m <char>" => "buf.mark_current_position(<char>)",
|
208
|
+
'CV \' <char>' => "buf.jump_to_mark(<char>)",
|
209
|
+
# "CV ''" =>'jump_to_mark(NEXT_MARK)', #TODO
|
210
|
+
|
211
|
+
"C i" => "$kbd.set_mode(:insert)",
|
212
|
+
"C ctrl!" => "$kbd.set_mode(:insert)",
|
213
|
+
|
214
|
+
# Macros
|
215
|
+
# (experimental, may not work correctly)
|
216
|
+
# "C q a" => '$macro.start_recording("a")',
|
217
|
+
"VC q <char>" => '$macro.start_recording(<char>)',
|
218
|
+
"VC q($macro.is_recording==true) " => "$macro.end_recording", # TODO
|
219
|
+
# 'C q'=> '$macro.end_recording', #TODO
|
220
|
+
"C q v" => "$macro.end_recording",
|
221
|
+
# 'C v'=> '$macro.end_recording',
|
222
|
+
# "C M" => '$macro.run_last_macro',
|
223
|
+
"C @ <char>" => '$macro.run_macro(<char>)',
|
224
|
+
"C , m S" => '$macro.save_macro("a")',
|
225
|
+
"C , m s" => '$macro.save',
|
226
|
+
"C , t r" => "run_tests()",
|
227
|
+
|
228
|
+
# "C ." => "repeat_last_action", # TODO
|
229
|
+
"VC ;" => "repeat_last_find",
|
230
|
+
# "CV Q" => :quit,
|
231
|
+
"CV ctrl-q" => :quit,
|
232
|
+
"CV , R" => "restart_application",
|
233
|
+
"I ctrl!" => "$kbd.set_mode(:command)",
|
234
|
+
"C shift!" => "buf.save",
|
235
|
+
"I <char>" => "buf.insert_txt(<char>)",
|
236
|
+
"I esc" => "$kbd.set_mode(:command)",
|
237
|
+
|
238
|
+
"I ctrl-d" => "buf.delete2(:to_word_end)",
|
239
|
+
|
240
|
+
# INSERT MODE: Moving
|
241
|
+
"I ctrl-a" => "buf.jump(BEGINNING_OF_LINE)",
|
242
|
+
"I ctrl-b" => "buf.move(BACKWARD_CHAR)",
|
243
|
+
"I ctrl-f" => "buf.move(FORWARD_CHAR)",
|
244
|
+
"I ctrl-n" => "buf.move(FORWARD_LINE)",
|
245
|
+
"I ctrl-p" => "buf.move(BACKWARD_LINE)",
|
246
|
+
"I ctrl-e" => "buf.jump(END_OF_LINE)", # context: mode:I, buttons down: {C}
|
247
|
+
"I alt-f" => "buf.jump_word(FORWARD,WORD_START)",
|
248
|
+
"I alt-b" => "buf.jump_word(BACKWARD,WORD_START)",
|
249
|
+
|
250
|
+
"I tab" => 'buf.insert_txt(" ")',
|
251
|
+
"I space" => 'buf.insert_txt(" ")',
|
252
|
+
# "I return" => 'buf.insert_new_line()',
|
253
|
+
}
|
254
|
+
|
255
|
+
default_keys.each { |key, value|
|
256
|
+
bindkey(key, value)
|
257
|
+
}
|
258
|
+
|
259
|
+
|
data/lib/vimamsa/macro.rb
CHANGED
@@ -58,7 +58,7 @@ class Macro
|
|
58
58
|
$macro_search_list = l
|
59
59
|
$select_keys = ["h", "l", "f", "d", "s", "a", "g", "z"]
|
60
60
|
|
61
|
-
|
61
|
+
gui_select_update_window(l, $select_keys.collect { |x| x.upcase },
|
62
62
|
"gui_find_macro_select_callback",
|
63
63
|
"gui_find_macro_update_callback")
|
64
64
|
end
|
data/lib/vimamsa/main.rb
CHANGED
@@ -28,7 +28,6 @@ $search_dirs = []
|
|
28
28
|
$errors = []
|
29
29
|
|
30
30
|
$cur_register = "a"
|
31
|
-
$input_char_call_func = nil
|
32
31
|
$debuginfo = {}
|
33
32
|
|
34
33
|
$jump_sequence = []
|
@@ -51,7 +50,7 @@ end
|
|
51
50
|
|
52
51
|
require "vimamsa/editor.rb"
|
53
52
|
|
54
|
-
# load "
|
53
|
+
# load "gui_funcs.rb"
|
55
54
|
|
56
55
|
$vma = Editor.new
|
57
56
|
def vma()
|
data/lib/vimamsa/rbvma.rb
CHANGED
@@ -9,16 +9,22 @@ require "ripl/multi_line"
|
|
9
9
|
require "json"
|
10
10
|
require "listen"
|
11
11
|
|
12
|
-
puts "INIT rbvma"
|
13
|
-
|
14
12
|
require "vimamsa/util"
|
15
|
-
|
16
|
-
|
17
|
-
require "vimamsa/
|
18
|
-
require "vimamsa/
|
19
|
-
require "vimamsa/
|
20
|
-
|
21
|
-
|
13
|
+
require "vimamsa/main"
|
14
|
+
|
15
|
+
require "vimamsa/actions"
|
16
|
+
require "vimamsa/key_binding_tree"
|
17
|
+
require "vimamsa/key_actions"
|
18
|
+
|
19
|
+
|
20
|
+
require "vimamsa/gui"
|
21
|
+
require "vimamsa/gui_menu"
|
22
|
+
require "vimamsa/gui_select_window"
|
23
|
+
require "vimamsa/gui_sourceview"
|
24
|
+
|
25
|
+
require "vimamsa/macro"
|
26
|
+
require "vimamsa/buffer"
|
27
|
+
require "vimamsa/debug"
|
22
28
|
require "vimamsa/constants"
|
23
29
|
require "vimamsa/easy_jump"
|
24
30
|
require "vimamsa/hook"
|
@@ -41,422 +47,12 @@ def vma()
|
|
41
47
|
return $vma
|
42
48
|
end
|
43
49
|
|
44
|
-
$idle_scroll_to_mark = false
|
45
|
-
|
46
|
-
def idle_func
|
47
|
-
# puts "IDLEFUNC"
|
48
|
-
if $idle_scroll_to_mark
|
49
|
-
# Ripl.start :binding => binding
|
50
|
-
# $view.get_visible_rect
|
51
|
-
vr = $view.visible_rect
|
52
|
-
|
53
|
-
# iter = b.get_iter_at(:offset => i)
|
54
|
-
|
55
|
-
b = $view.buffer
|
56
|
-
iter = b.get_iter_at(:offset => b.cursor_position)
|
57
|
-
iterxy = $view.get_iter_location(iter)
|
58
|
-
# puts "ITERXY" + iterxy.inspect
|
59
|
-
# Ripl.start :binding => binding
|
60
|
-
|
61
|
-
intr = iterxy.intersect(vr)
|
62
|
-
if intr.nil?
|
63
|
-
$view.set_cursor_pos($view.buffer.cursor_position)
|
64
|
-
else
|
65
|
-
$idle_scroll_to_mark = false
|
66
|
-
end
|
67
|
-
|
68
|
-
sleep(0.1)
|
69
|
-
end
|
70
|
-
sleep(0.01)
|
71
|
-
return true
|
72
|
-
end
|
73
|
-
|
74
|
-
# qt_select_update_window(l, $select_keys.collect { |x| x.upcase },
|
75
|
-
# "gui_find_macro_select_callback",
|
76
|
-
# "gui_find_macro_update_callback")
|
77
|
-
class SelectUpdateWindow
|
78
|
-
COLUMN_JUMP_KEY = 0
|
79
|
-
COLUMN_DESCRIPTION = 1
|
80
|
-
|
81
|
-
def update_item_list(item_list)
|
82
|
-
# puts item_list.inspect
|
83
|
-
# Ripl.start :binding => binding
|
84
|
-
@model.clear
|
85
|
-
for item in item_list
|
86
|
-
iter = @model.append
|
87
|
-
v = ["", item[0]]
|
88
|
-
puts v.inspect
|
89
|
-
iter.set_values(v)
|
90
|
-
end
|
91
|
-
|
92
|
-
set_selected_row(0)
|
93
|
-
end
|
94
|
-
|
95
|
-
def set_selected_row(rownum)
|
96
|
-
rownum = 0 if rownum < 0
|
97
|
-
@selected_row = rownum
|
98
|
-
|
99
|
-
if @model.count > 0
|
100
|
-
path = Gtk::TreePath.new(@selected_row.to_s)
|
101
|
-
iter = @model.get_iter(path)
|
102
|
-
@tv.selection.select_iter(iter)
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
def initialize(main_window, item_list, jump_keys, select_callback, update_callback)
|
107
|
-
@window = Gtk::Window.new(:toplevel)
|
108
|
-
# @window.screen = main_window.screen
|
109
|
-
@window.title = "List Store"
|
110
|
-
|
111
|
-
@selected_row = 0
|
112
|
-
|
113
|
-
puts item_list.inspect
|
114
|
-
@update_callback = method(update_callback)
|
115
|
-
@select_callback = method(select_callback)
|
116
|
-
# puts @update_callback_m.call("").inspect
|
117
|
-
|
118
|
-
vbox = Gtk::Box.new(:vertical, 8)
|
119
|
-
vbox.margin = 8
|
120
|
-
@window.add(vbox)
|
121
|
-
|
122
|
-
@entry = Gtk::SearchEntry.new
|
123
|
-
@entry.width_chars = 45
|
124
|
-
container = Gtk::Box.new(:horizontal, 10)
|
125
|
-
# container.halign = :start
|
126
|
-
container.halign = :center
|
127
|
-
container.pack_start(@entry,
|
128
|
-
:expand => false, :fill => false, :padding => 0)
|
129
|
-
|
130
|
-
# create tree view
|
131
|
-
@model = Gtk::ListStore.new(String, String)
|
132
|
-
treeview = Gtk::TreeView.new(@model)
|
133
|
-
treeview.search_column = COLUMN_DESCRIPTION
|
134
|
-
@tv = treeview
|
135
|
-
# item_list = @update_callback.call("")
|
136
|
-
update_item_list(item_list)
|
137
|
-
|
138
|
-
# Ripl.start :binding => binding
|
139
|
-
@window.signal_connect("key-press-event") do |_widget, event|
|
140
|
-
# puts "KEYPRESS 1"
|
141
|
-
@entry.handle_event(event)
|
142
|
-
end
|
143
|
-
|
144
|
-
@entry.signal_connect("key_press_event") do |widget, event|
|
145
|
-
# puts "KEYPRESS 2"
|
146
|
-
if event.keyval == Gdk::Keyval::KEY_Down
|
147
|
-
puts "DOWN"
|
148
|
-
set_selected_row(@selected_row + 1)
|
149
|
-
# fixed = iter[COLUMN_FIXED]
|
150
|
-
|
151
|
-
true
|
152
|
-
elsif event.keyval == Gdk::Keyval::KEY_Up
|
153
|
-
set_selected_row(@selected_row - 1)
|
154
|
-
puts "UP"
|
155
|
-
true
|
156
|
-
elsif event.keyval == Gdk::Keyval::KEY_Return
|
157
|
-
path = Gtk::TreePath.new(@selected_row.to_s)
|
158
|
-
iter = @model.get_iter(path)
|
159
|
-
ret = iter[1]
|
160
|
-
@select_callback.call(ret, @selected_row)
|
161
|
-
@window.destroy
|
162
|
-
# puts iter[1].inspect
|
163
|
-
true
|
164
|
-
elsif event.keyval == Gdk::Keyval::KEY_Escape
|
165
|
-
@window.destroy
|
166
|
-
true
|
167
|
-
else
|
168
|
-
false
|
169
|
-
end
|
170
|
-
end
|
171
|
-
|
172
|
-
@entry.signal_connect("search-changed") do |widget|
|
173
|
-
puts "search changed: #{widget.text || ""}"
|
174
|
-
item_list = @update_callback.call(widget.text)
|
175
|
-
update_item_list(item_list)
|
176
|
-
# label.text = widget.text || ""
|
177
|
-
end
|
178
|
-
@entry.signal_connect("changed") { puts "[changed] " }
|
179
|
-
@entry.signal_connect("next-match") { puts "[next-match] " }
|
180
|
-
|
181
|
-
label = Gtk::Label.new(<<-EOF)
|
182
|
-
|
183
|
-
Search:
|
184
|
-
EOF
|
185
|
-
vbox.pack_start(label, :expand => false, :fill => false, :padding => 0)
|
186
|
-
|
187
|
-
vbox.pack_start(container, :expand => false, :fill => false, :padding => 0)
|
188
|
-
sw = Gtk::ScrolledWindow.new(nil, nil)
|
189
|
-
sw.shadow_type = :etched_in
|
190
|
-
sw.set_policy(:never, :automatic)
|
191
|
-
vbox.pack_start(sw, :expand => true, :fill => true, :padding => 0)
|
192
|
-
|
193
|
-
sw.add(treeview)
|
194
|
-
|
195
|
-
renderer = Gtk::CellRendererText.new
|
196
|
-
column = Gtk::TreeViewColumn.new("JMP",
|
197
|
-
renderer,
|
198
|
-
"text" => COLUMN_JUMP_KEY)
|
199
|
-
column.sort_column_id = COLUMN_JUMP_KEY
|
200
|
-
treeview.append_column(column)
|
201
|
-
|
202
|
-
renderer = Gtk::CellRendererText.new
|
203
|
-
column = Gtk::TreeViewColumn.new("Description",
|
204
|
-
renderer,
|
205
|
-
"text" => COLUMN_DESCRIPTION)
|
206
|
-
column.sort_column_id = COLUMN_DESCRIPTION
|
207
|
-
treeview.append_column(column)
|
208
|
-
|
209
|
-
@window.set_default_size(280, 500)
|
210
|
-
puts "SelectUpdateWindow"
|
211
|
-
end
|
212
|
-
|
213
|
-
def run
|
214
|
-
if !@window.visible?
|
215
|
-
@window.show_all
|
216
|
-
# add_spinner
|
217
|
-
else
|
218
|
-
@window.destroy
|
219
|
-
# GLib::Source.remove(@tiemout) unless @timeout.zero?
|
220
|
-
@timeout = 0
|
221
|
-
end
|
222
|
-
@window
|
223
|
-
end
|
224
|
-
end
|
225
|
-
|
226
|
-
def center_on_current_line()
|
227
|
-
b = $view.buffer
|
228
|
-
iter = b.get_iter_at(:offset => b.cursor_position)
|
229
|
-
within_margin = 0.0 #margin as a [0.0,0.5) fraction of screen size
|
230
|
-
use_align = true
|
231
|
-
xalign = 0.0 #0.0=top 1.0=bottom, 0.5=center
|
232
|
-
yalign = 0.5
|
233
|
-
$view.scroll_to_iter(iter, within_margin, use_align, xalign, yalign)
|
234
|
-
end
|
235
|
-
|
236
|
-
def qt_select_update_window(item_list, jump_keys, select_callback, update_callback)
|
237
|
-
$selup = SelectUpdateWindow.new(nil, item_list, jump_keys, select_callback, update_callback)
|
238
|
-
$selup.run
|
239
|
-
end
|
240
|
-
|
241
|
-
# ~/Drive/code/ruby-gnome/gtk3/sample/gtk-demo/search_entry2.rb
|
242
|
-
# ~/Drive/code/ruby-gnome/gtk3/sample/gtk-demo/list_store.rb
|
243
|
-
|
244
|
-
def qt_open_file_dialog(dirpath)
|
245
|
-
dialog = Gtk::FileChooserDialog.new(:title => "Open file",
|
246
|
-
:action => :open,
|
247
|
-
:buttons => [[Gtk::Stock::OPEN, :accept],
|
248
|
-
[Gtk::Stock::CANCEL, :cancel]])
|
249
|
-
dialog.set_current_folder(dirpath)
|
250
|
-
|
251
|
-
dialog.signal_connect("response") do |dialog, response_id|
|
252
|
-
if response_id == Gtk::ResponseType::ACCEPT
|
253
|
-
open_new_file(dialog.filename)
|
254
|
-
# puts "uri = #{dialog.uri}"
|
255
|
-
end
|
256
|
-
dialog.destroy
|
257
|
-
end
|
258
|
-
dialog.run
|
259
|
-
end
|
260
|
-
|
261
|
-
def qt_file_saveas(dirpath)
|
262
|
-
dialog = Gtk::FileChooserDialog.new(:title => "Save as",
|
263
|
-
:action => :save,
|
264
|
-
:buttons => [[Gtk::Stock::SAVE, :accept],
|
265
|
-
[Gtk::Stock::CANCEL, :cancel]])
|
266
|
-
dialog.set_current_folder(dirpath)
|
267
|
-
dialog.signal_connect("response") do |dialog, response_id|
|
268
|
-
if response_id == Gtk::ResponseType::ACCEPT
|
269
|
-
file_saveas(dialog.filename)
|
270
|
-
end
|
271
|
-
dialog.destroy
|
272
|
-
end
|
273
|
-
|
274
|
-
dialog.run
|
275
|
-
end
|
276
|
-
|
277
|
-
def qt_create_buffer(id)
|
278
|
-
puts "qt_create_buffer(#{id})"
|
279
|
-
buf1 = GtkSource::Buffer.new()
|
280
|
-
view = VSourceView.new()
|
281
|
-
|
282
|
-
view.set_highlight_current_line(true)
|
283
|
-
view.set_show_line_numbers(true)
|
284
|
-
view.set_buffer(buf1)
|
285
|
-
|
286
|
-
ssm = GtkSource::StyleSchemeManager.new
|
287
|
-
ssm.set_search_path(ssm.search_path << ppath("styles/"))
|
288
|
-
# sty = ssm.get_scheme("dark")
|
289
|
-
sty = ssm.get_scheme("molokai_edit")
|
290
|
-
# puts ssm.scheme_ids
|
291
|
-
|
292
|
-
view.buffer.highlight_matching_brackets = true
|
293
|
-
view.buffer.style_scheme = sty
|
294
|
-
|
295
|
-
provider = Gtk::CssProvider.new
|
296
|
-
provider.load(data: "textview { font-family: Monospace; font-size: 11pt; }")
|
297
|
-
# provider.load(data: "textview { font-family: Arial; font-size: 12pt; }")
|
298
|
-
view.style_context.add_provider(provider)
|
299
|
-
view.wrap_mode = :char
|
300
|
-
|
301
|
-
$vmag.buffers[id] = view
|
302
|
-
end
|
303
|
-
|
304
|
-
def gui_set_file_lang(id, lname)
|
305
|
-
view = $vmag.buffers[id]
|
306
|
-
lm = GtkSource::LanguageManager.new
|
307
|
-
lang = nil
|
308
|
-
lm.set_search_path(lm.search_path << ppath("lang/"))
|
309
|
-
lang = lm.get_language(lname)
|
310
|
-
|
311
|
-
view.buffer.language = lang
|
312
|
-
view.buffer.highlight_syntax = true
|
313
|
-
end
|
314
|
-
|
315
|
-
def qt_process_deltas
|
316
|
-
end
|
317
|
-
|
318
|
-
def qt_add_image(imgpath, pos)
|
319
|
-
end
|
320
|
-
|
321
|
-
def qt_process_deltas
|
322
|
-
end
|
323
|
-
|
324
|
-
def qt_process_events
|
325
|
-
end
|
326
|
-
|
327
|
-
def qt_select_window_close(arg = nil)
|
328
|
-
end
|
329
|
-
|
330
|
-
# def set_window_title(str)
|
331
|
-
# unimplemented
|
332
|
-
# end
|
333
|
-
|
334
|
-
def render_text(tmpbuf, pos, selection_start, reset)
|
335
|
-
unimplemented
|
336
|
-
end
|
337
|
-
|
338
|
-
def qt_set_buffer_contents(id, txt)
|
339
|
-
# $vbuf.set_text(txt)
|
340
|
-
puts "qt_set_buffer_contents(#{id}, txt)"
|
341
|
-
|
342
|
-
$vmag.buffers[id].buffer.set_text(txt)
|
343
|
-
end
|
344
|
-
|
345
|
-
def qt_set_cursor_pos(id, pos)
|
346
|
-
$view.set_cursor_pos(pos)
|
347
|
-
# Ripl.start :binding => binding
|
348
|
-
end
|
349
|
-
|
350
|
-
def qt_set_selection_start(id, selection_start)
|
351
|
-
end
|
352
|
-
|
353
|
-
def qt_set_current_buffer(id)
|
354
|
-
view = $vmag.buffers[id]
|
355
|
-
puts "qt_set_current_buffer(#{id}), view=#{view}"
|
356
|
-
buf1 = view.buffer
|
357
|
-
$vmag.view = view
|
358
|
-
$vmag.buf1 = buf1
|
359
|
-
$view = view
|
360
|
-
$vbuf = buf1
|
361
|
-
|
362
|
-
$vmag.sw.remove($vmag.sw.child) if !$vmag.sw.child.nil?
|
363
|
-
$vmag.sw.add(view)
|
364
|
-
|
365
|
-
view.grab_focus
|
366
|
-
#view.set_focus(10)
|
367
|
-
view.set_cursor_visible(true)
|
368
|
-
#view.move_cursor(1, 1, false)
|
369
|
-
view.place_cursor_onscreen
|
370
|
-
|
371
|
-
#TODO:
|
372
|
-
# itr = view.buffer.get_iter_at(:offset => 0)
|
373
|
-
# view.buffer.place_cursor(itr)
|
374
|
-
|
375
|
-
# wtitle = ""
|
376
|
-
# wtitle = buf.fname if !buf.fname.nil?
|
377
|
-
$vmag.sw.show_all
|
378
|
-
end
|
379
|
-
|
380
|
-
def gui_set_window_title(wtitle,subtitle="")
|
381
|
-
$vmag.window.title = wtitle
|
382
|
-
$vmag.window.titlebar.subtitle = subtitle
|
383
|
-
end
|
384
|
-
|
385
50
|
def unimplemented
|
386
51
|
puts "unimplemented"
|
387
52
|
end
|
388
53
|
|
389
|
-
def center_where_cursor
|
390
|
-
unimplemented
|
391
|
-
end
|
392
|
-
|
393
|
-
def paste_system_clipboard()
|
394
|
-
# clipboard = $vmag.window.get_clipboard(Gdk::Selection::CLIPBOARD)
|
395
|
-
utf8_string = Gdk::Atom.intern("UTF8_STRING")
|
396
|
-
# x = clipboard.request_contents(utf8_string)
|
397
|
-
|
398
|
-
widget = Gtk::Invisible.new
|
399
|
-
clipboard = Gtk::Clipboard.get_default($vmag.window.display)
|
400
|
-
received_text = ""
|
401
|
-
|
402
|
-
target_string = Gdk::Selection::TARGET_STRING
|
403
|
-
ti = clipboard.request_contents(target_string)
|
404
|
-
|
405
|
-
# clipboard.request_contents(target_string) do |_clipboard, selection_data|
|
406
|
-
# received_text = selection_data.text
|
407
|
-
# puts "received_text=#{received_text}"
|
408
|
-
# end
|
409
|
-
if clipboard.wait_is_text_available?
|
410
|
-
received_text = clipboard.wait_for_text
|
411
|
-
end
|
412
|
-
|
413
|
-
if received_text != "" and !received_text.nil?
|
414
|
-
max_clipboard_items = 100
|
415
|
-
if received_text != $clipboard[-1]
|
416
|
-
#TODO: HACK
|
417
|
-
$paste_lines = false
|
418
|
-
end
|
419
|
-
$clipboard << received_text
|
420
|
-
# puts $clipboard[-1]
|
421
|
-
$clipboard = $clipboard[-([$clipboard.size, max_clipboard_items].min)..-1]
|
422
|
-
end
|
423
|
-
return received_text
|
424
|
-
end
|
425
|
-
|
426
|
-
def set_system_clipboard(arg)
|
427
|
-
# return if arg.class != String
|
428
|
-
# return if s.size < 1
|
429
|
-
# utf8_string = Gdk::Atom.intern("UTF8_STRING")
|
430
|
-
widget = Gtk::Invisible.new
|
431
|
-
clipboard = Gtk::Clipboard.get_default($vmag.window.display)
|
432
|
-
clipboard.text = arg
|
433
|
-
end
|
434
|
-
|
435
|
-
def get_visible_area()
|
436
|
-
view = $view
|
437
|
-
vr = view.visible_rect
|
438
|
-
startpos = view.get_iter_at_position_raw(vr.x, vr.y)[1].offset
|
439
|
-
endpos = view.get_iter_at_position_raw(vr.x + vr.width, vr.y + vr.height)[1].offset
|
440
|
-
return [startpos, endpos]
|
441
|
-
end
|
442
|
-
|
443
|
-
def page_up
|
444
|
-
$view.signal_emit("move-cursor", Gtk::MovementStep.new(:PAGES), -1, false)
|
445
|
-
return true
|
446
|
-
end
|
447
|
-
|
448
|
-
def page_down
|
449
|
-
$view.signal_emit("move-cursor", Gtk::MovementStep.new(:PAGES), 1, false)
|
450
|
-
return true
|
451
|
-
end
|
452
54
|
|
453
|
-
|
454
|
-
# # Your code goes here...
|
455
|
-
# def foo
|
456
|
-
# puts "BAR"
|
457
|
-
# end
|
458
|
-
# end
|
459
|
-
$debug = true
|
55
|
+
$debug = false
|
460
56
|
|
461
57
|
def scan_indexes(txt, regex)
|
462
58
|
# indexes = txt.enum_for(:scan, regex).map { Regexp.last_match.begin(0) + 1 }
|
@@ -466,607 +62,4 @@ end
|
|
466
62
|
|
467
63
|
$update_cursor = false
|
468
64
|
|
469
|
-
class VSourceView < GtkSource::View
|
470
|
-
def initialize(title = nil)
|
471
|
-
# super(:toplevel)
|
472
|
-
super()
|
473
|
-
puts "vsource init"
|
474
|
-
@last_keyval = nil
|
475
|
-
@last_event = [nil, nil]
|
476
|
-
|
477
|
-
signal_connect "button-press-event" do |_widget, event|
|
478
|
-
if event.button == Gdk::BUTTON_PRIMARY
|
479
|
-
# puts "Gdk::BUTTON_PRIMARY"
|
480
|
-
false
|
481
|
-
elsif event.button == Gdk::BUTTON_SECONDARY
|
482
|
-
# puts "Gdk::BUTTON_SECONDARY"
|
483
|
-
true
|
484
|
-
else
|
485
|
-
true
|
486
|
-
end
|
487
|
-
end
|
488
|
-
|
489
|
-
signal_connect("key_press_event") do |widget, event|
|
490
|
-
handle_key_event(event, :key_press_event)
|
491
|
-
true
|
492
|
-
end
|
493
|
-
|
494
|
-
signal_connect("key_release_event") do |widget, event|
|
495
|
-
handle_key_event(event, :key_release_event)
|
496
|
-
true
|
497
|
-
end
|
498
|
-
|
499
|
-
signal_connect("move-cursor") do |widget, event|
|
500
|
-
$update_cursor = true
|
501
|
-
false
|
502
|
-
end
|
503
|
-
|
504
|
-
signal_connect "button-release-event" do |widget, event|
|
505
|
-
$buffer.set_pos(buffer.cursor_position)
|
506
|
-
false
|
507
|
-
end
|
508
|
-
@curpos_mark = nil
|
509
|
-
end
|
510
|
-
|
511
|
-
def handle_key_event(event, sig)
|
512
|
-
if $update_cursor
|
513
|
-
curpos = buffer.cursor_position
|
514
|
-
puts "MOVE CURSOR: #{curpos}"
|
515
|
-
buf.set_pos(curpos)
|
516
|
-
$update_cursor = false
|
517
|
-
end
|
518
|
-
puts $view.visible_rect.inspect
|
519
|
-
|
520
|
-
puts "key event"
|
521
|
-
puts event
|
522
|
-
|
523
|
-
key_name = event.string
|
524
|
-
if event.state.control_mask?
|
525
|
-
key_name = Gdk::Keyval.to_name(event.keyval)
|
526
|
-
# Gdk::Keyval.to_name()
|
527
|
-
end
|
528
|
-
|
529
|
-
keyval_trans = {}
|
530
|
-
keyval_trans[Gdk::Keyval::KEY_Control_L] = "ctrl"
|
531
|
-
keyval_trans[Gdk::Keyval::KEY_Control_R] = "ctrl"
|
532
|
-
|
533
|
-
keyval_trans[Gdk::Keyval::KEY_Escape] = "esc"
|
534
|
-
|
535
|
-
keyval_trans[Gdk::Keyval::KEY_Return] = "enter"
|
536
|
-
keyval_trans[Gdk::Keyval::KEY_ISO_Enter] = "enter"
|
537
|
-
keyval_trans[Gdk::Keyval::KEY_KP_Enter] = "enter"
|
538
|
-
keyval_trans[Gdk::Keyval::KEY_Alt_L] = "alt"
|
539
|
-
keyval_trans[Gdk::Keyval::KEY_Alt_R] = "alt"
|
540
|
-
|
541
|
-
keyval_trans[Gdk::Keyval::KEY_BackSpace] = "backspace"
|
542
|
-
keyval_trans[Gdk::Keyval::KEY_KP_Page_Down] = "pagedown"
|
543
|
-
keyval_trans[Gdk::Keyval::KEY_KP_Page_Up] = "pageup"
|
544
|
-
keyval_trans[Gdk::Keyval::KEY_Page_Down] = "pagedown"
|
545
|
-
keyval_trans[Gdk::Keyval::KEY_Page_Up] = "pageup"
|
546
|
-
keyval_trans[Gdk::Keyval::KEY_Left] = "left"
|
547
|
-
keyval_trans[Gdk::Keyval::KEY_Right] = "right"
|
548
|
-
keyval_trans[Gdk::Keyval::KEY_Down] = "down"
|
549
|
-
keyval_trans[Gdk::Keyval::KEY_Up] = "up"
|
550
|
-
keyval_trans[Gdk::Keyval::KEY_space] = "space"
|
551
|
-
|
552
|
-
keyval_trans[Gdk::Keyval::KEY_Shift_L] = "shift"
|
553
|
-
keyval_trans[Gdk::Keyval::KEY_Shift_R] = "shift"
|
554
|
-
keyval_trans[Gdk::Keyval::KEY_Tab] = "tab"
|
555
|
-
|
556
|
-
key_trans = {}
|
557
|
-
key_trans["\e"] = "esc"
|
558
|
-
tk = keyval_trans[event.keyval]
|
559
|
-
key_name = tk if !tk.nil?
|
560
|
-
|
561
|
-
key_str_parts = []
|
562
|
-
key_str_parts << "ctrl" if event.state.control_mask? and key_name != "ctrl"
|
563
|
-
key_str_parts << "alt" if event.state.mod1_mask? and key_name != "alt"
|
564
|
-
|
565
|
-
key_str_parts << key_name
|
566
|
-
key_str = key_str_parts.join("-")
|
567
|
-
keynfo = { :key_str => key_str, :key_name => key_name, :keyval => event.keyval }
|
568
|
-
puts keynfo.inspect
|
569
|
-
# $kbd.match_key_conf(key_str, nil, :key_press)
|
570
|
-
# puts "key_str=#{key_str} key_"
|
571
|
-
|
572
|
-
if key_str != "" # or prefixed_key_str != ""
|
573
|
-
if sig == :key_release_event and event.keyval == @last_keyval
|
574
|
-
$kbd.match_key_conf(key_str + "!", nil, :key_release)
|
575
|
-
@last_event = [event, :key_release]
|
576
|
-
elsif sig == :key_press_event
|
577
|
-
$kbd.match_key_conf(key_str, nil, :key_press)
|
578
|
-
@last_event = [event, key_str, :key_press]
|
579
|
-
end
|
580
|
-
@last_keyval = event.keyval #TODO: outside if?
|
581
|
-
end
|
582
|
-
|
583
|
-
handle_deltas
|
584
|
-
|
585
|
-
# set_focus(5)
|
586
|
-
# false
|
587
|
-
|
588
|
-
end
|
589
|
-
|
590
|
-
def pos_to_coord(i)
|
591
|
-
b = buffer
|
592
|
-
iter = b.get_iter_at(:offset => i)
|
593
|
-
iterxy = get_iter_location(iter)
|
594
|
-
winw = parent_window.width
|
595
|
-
view_width = visible_rect.width
|
596
|
-
gutter_width = winw - view_width
|
597
|
-
|
598
|
-
x = iterxy.x + gutter_width
|
599
|
-
y = iterxy.y
|
600
|
-
|
601
|
-
# buffer_to_window_coords(Gtk::TextWindowType::TEXT, iterxy.x, iterxy.y).inspect
|
602
|
-
# puts buffer_to_window_coords(Gtk::TextWindowType::TEXT, x, y).inspect
|
603
|
-
(x, y) = buffer_to_window_coords(Gtk::TextWindowType::TEXT, x, y)
|
604
|
-
# Ripl.start :binding => binding
|
605
65
|
|
606
|
-
return [x, y]
|
607
|
-
end
|
608
|
-
|
609
|
-
def handle_deltas()
|
610
|
-
any_change = false
|
611
|
-
while d = buf.deltas.shift
|
612
|
-
any_change = true
|
613
|
-
pos = d[0]
|
614
|
-
op = d[1]
|
615
|
-
num = d[2]
|
616
|
-
txt = d[3]
|
617
|
-
if op == DELETE
|
618
|
-
startiter = buffer.get_iter_at(:offset => pos)
|
619
|
-
enditer = buffer.get_iter_at(:offset => pos + num)
|
620
|
-
buffer.delete(startiter, enditer)
|
621
|
-
elsif op == INSERT
|
622
|
-
startiter = buffer.get_iter_at(:offset => pos)
|
623
|
-
buffer.insert(startiter, txt)
|
624
|
-
end
|
625
|
-
end
|
626
|
-
if any_change
|
627
|
-
qt_set_cursor_pos($buffer.id, $buffer.pos) #TODO: only when necessary
|
628
|
-
end
|
629
|
-
|
630
|
-
# sanity_check #TODO
|
631
|
-
end
|
632
|
-
|
633
|
-
def sanity_check()
|
634
|
-
a = buffer.text
|
635
|
-
b = buf.to_s
|
636
|
-
# puts "===================="
|
637
|
-
# puts a.lines[0..10].join()
|
638
|
-
# puts "===================="
|
639
|
-
# puts b.lines[0..10].join()
|
640
|
-
# puts "===================="
|
641
|
-
if a == b
|
642
|
-
puts "Buffers match"
|
643
|
-
else
|
644
|
-
puts "ERROR: Buffer's don't match."
|
645
|
-
end
|
646
|
-
end
|
647
|
-
|
648
|
-
def set_cursor_pos(pos)
|
649
|
-
# return
|
650
|
-
itr = buffer.get_iter_at(:offset => pos)
|
651
|
-
itr2 = buffer.get_iter_at(:offset => pos + 1)
|
652
|
-
buffer.place_cursor(itr)
|
653
|
-
|
654
|
-
# $view.signal_emit("extend-selection", Gtk::MovementStep.new(:PAGES), -1, false)
|
655
|
-
|
656
|
-
within_margin = 0.075 #margin as a [0.0,0.5) fraction of screen size
|
657
|
-
use_align = false
|
658
|
-
xalign = 0.5 #0.0=top 1.0=bottom, 0.5=center
|
659
|
-
yalign = 0.5
|
660
|
-
|
661
|
-
if @curpos_mark.nil?
|
662
|
-
@curpos_mark = buffer.create_mark("cursor", itr, false)
|
663
|
-
else
|
664
|
-
buffer.move_mark(@curpos_mark, itr)
|
665
|
-
end
|
666
|
-
scroll_to_mark(@curpos_mark, within_margin, use_align, xalign, yalign)
|
667
|
-
$idle_scroll_to_mark = true
|
668
|
-
ensure_cursor_visible
|
669
|
-
|
670
|
-
# scroll_to_iter(itr, within_margin, use_align, xalign, yalign)
|
671
|
-
|
672
|
-
# $view.signal_emit("extend-selection", Gtk::TextExtendSelection.new, itr,itr,itr2)
|
673
|
-
# Ripl.start :binding => binding
|
674
|
-
draw_cursor
|
675
|
-
|
676
|
-
return true
|
677
|
-
end
|
678
|
-
|
679
|
-
def cursor_visible_idle_func
|
680
|
-
puts "cursor_visible_idle_func"
|
681
|
-
# From https://picheta.me/articles/2013/08/gtk-plus--a-method-to-guarantee-scrolling.html
|
682
|
-
# vr = visible_rect
|
683
|
-
|
684
|
-
# b = $view.buffer
|
685
|
-
# iter = buffer.get_iter_at(:offset => buffer.cursor_position)
|
686
|
-
# iterxy = get_iter_location(iter)
|
687
|
-
|
688
|
-
sleep(0.01)
|
689
|
-
# intr = iterxy.intersect(vr)
|
690
|
-
if is_cursor_visible == false
|
691
|
-
# set_cursor_pos(buffer.cursor_position)
|
692
|
-
|
693
|
-
itr = buffer.get_iter_at(:offset => buffer.cursor_position)
|
694
|
-
|
695
|
-
within_margin = 0.075 #margin as a [0.0,0.5) fraction of screen size
|
696
|
-
use_align = false
|
697
|
-
xalign = 0.5 #0.0=top 1.0=bottom, 0.5=center
|
698
|
-
yalign = 0.5
|
699
|
-
|
700
|
-
scroll_to_iter(itr, within_margin, use_align, xalign, yalign)
|
701
|
-
|
702
|
-
# return true # Call this func again
|
703
|
-
else
|
704
|
-
return false # Don't call this idle func again
|
705
|
-
end
|
706
|
-
end
|
707
|
-
|
708
|
-
def is_cursor_visible
|
709
|
-
vr = visible_rect
|
710
|
-
iter = buffer.get_iter_at(:offset => buffer.cursor_position)
|
711
|
-
iterxy = get_iter_location(iter)
|
712
|
-
iterxy.width = 1 if iterxy.width == 0
|
713
|
-
iterxy.height = 1 if iterxy.height == 0
|
714
|
-
|
715
|
-
intr = iterxy.intersect(vr)
|
716
|
-
if intr.nil?
|
717
|
-
puts iterxy.inspect
|
718
|
-
puts vr.inspect
|
719
|
-
# Ripl.start :binding => binding
|
720
|
-
|
721
|
-
# exit!
|
722
|
-
return false
|
723
|
-
else
|
724
|
-
return true
|
725
|
-
end
|
726
|
-
end
|
727
|
-
|
728
|
-
def ensure_cursor_visible
|
729
|
-
if is_cursor_visible == false
|
730
|
-
Thread.new {
|
731
|
-
sleep 0.01
|
732
|
-
GLib::Idle.add(proc { cursor_visible_idle_func })
|
733
|
-
}
|
734
|
-
end
|
735
|
-
end
|
736
|
-
|
737
|
-
def draw_cursor
|
738
|
-
if is_command_mode
|
739
|
-
itr = buffer.get_iter_at(:offset => buf.pos)
|
740
|
-
itr2 = buffer.get_iter_at(:offset => buf.pos + 1)
|
741
|
-
$view.buffer.select_range(itr, itr2)
|
742
|
-
elsif buf.visual_mode?
|
743
|
-
puts "VISUAL MODE"
|
744
|
-
(_start, _end) = buf.get_visual_mode_range2
|
745
|
-
puts "#{_start}, #{_end}"
|
746
|
-
itr = buffer.get_iter_at(:offset => _start)
|
747
|
-
itr2 = buffer.get_iter_at(:offset => _end + 1)
|
748
|
-
$view.buffer.select_range(itr, itr2)
|
749
|
-
else # Insert mode
|
750
|
-
itr = buffer.get_iter_at(:offset => buf.pos)
|
751
|
-
$view.buffer.select_range(itr, itr)
|
752
|
-
puts "INSERT MODE"
|
753
|
-
end
|
754
|
-
end
|
755
|
-
|
756
|
-
# def quit
|
757
|
-
# destroy
|
758
|
-
# true
|
759
|
-
# end
|
760
|
-
end
|
761
|
-
|
762
|
-
class VMAg
|
763
|
-
attr_accessor :buffers, :sw, :view, :buf1, :window
|
764
|
-
|
765
|
-
VERSION = "1.0"
|
766
|
-
|
767
|
-
HEART = "♥"
|
768
|
-
RADIUS = 150
|
769
|
-
N_WORDS = 5
|
770
|
-
FONT = "Serif 18"
|
771
|
-
TEXT = "I ♥ GTK+"
|
772
|
-
|
773
|
-
def initialize()
|
774
|
-
@show_overlay = true
|
775
|
-
@da = nil
|
776
|
-
@buffers = {}
|
777
|
-
@view = nil
|
778
|
-
@buf1 = nil
|
779
|
-
end
|
780
|
-
|
781
|
-
def run
|
782
|
-
init_window
|
783
|
-
# init_rtext
|
784
|
-
Gtk.main
|
785
|
-
end
|
786
|
-
|
787
|
-
def start_overlay_draw()
|
788
|
-
@da = Gtk::Fixed.new
|
789
|
-
@overlay.add_overlay(@da)
|
790
|
-
@overlay.set_overlay_pass_through(@da, true)
|
791
|
-
end
|
792
|
-
|
793
|
-
def clear_overlay()
|
794
|
-
if @da != nil
|
795
|
-
@overlay.remove(@da)
|
796
|
-
end
|
797
|
-
end
|
798
|
-
|
799
|
-
def overlay_draw_text(text, textpos)
|
800
|
-
# puts "overlay_draw_text #{[x,y]}"
|
801
|
-
(x, y) = @view.pos_to_coord(textpos)
|
802
|
-
# puts "overlay_draw_text #{[x,y]}"
|
803
|
-
label = Gtk::Label.new("<span background='#00000088' foreground='#ff0000' weight='ultrabold'>#{text}</span>")
|
804
|
-
label.use_markup = true
|
805
|
-
@da.put(label, x, y)
|
806
|
-
end
|
807
|
-
|
808
|
-
def end_overlay_draw()
|
809
|
-
@da.show_all
|
810
|
-
end
|
811
|
-
|
812
|
-
def toggle_overlay
|
813
|
-
@show_overlay = @show_overlay ^ 1
|
814
|
-
if !@show_overlay
|
815
|
-
if @da != nil
|
816
|
-
@overlay.remove(@da)
|
817
|
-
end
|
818
|
-
return
|
819
|
-
else
|
820
|
-
@da = Gtk::Fixed.new
|
821
|
-
@overlay.add_overlay(@da)
|
822
|
-
@overlay.set_overlay_pass_through(@da, true)
|
823
|
-
end
|
824
|
-
|
825
|
-
(startpos, endpos) = get_visible_area
|
826
|
-
s = @view.buffer.text
|
827
|
-
wpos = s.enum_for(:scan, /\W(\w)/).map { Regexp.last_match.begin(0) + 1 }
|
828
|
-
wpos = wpos[0..130]
|
829
|
-
|
830
|
-
# vr = @view.visible_rect
|
831
|
-
# # gtk_text_view_get_line_at_y
|
832
|
-
# # gtk_text_view_get_iter_at_position
|
833
|
-
# gtk_text_view_get_iter_at_position(vr.
|
834
|
-
# istart = @view.get_iter_at_position(vr.x,vr.y)
|
835
|
-
# istart = @view.get_iter_at_y(vr.y)
|
836
|
-
# startpos = @view.get_iter_at_position_raw(vr.x,vr.y)[1].offset
|
837
|
-
# endpos = @view.get_iter_at_position_raw(vr.x+vr.width,vr.y+vr.height)[1].offset
|
838
|
-
# puts "startpos,endpos:#{[startpos, endpos]}"
|
839
|
-
|
840
|
-
da = @da
|
841
|
-
if false
|
842
|
-
da.signal_connect "draw" do |widget, cr|
|
843
|
-
cr.save
|
844
|
-
for pos in wpos
|
845
|
-
(x, y) = @view.pos_to_coord(pos)
|
846
|
-
|
847
|
-
layout = da.create_pango_layout("XY")
|
848
|
-
desc = Pango::FontDescription.new("sans bold 11")
|
849
|
-
layout.font_description = desc
|
850
|
-
|
851
|
-
cr.move_to(x, y)
|
852
|
-
# cr.move_to(gutter_width, 300)
|
853
|
-
cr.pango_layout_path(layout)
|
854
|
-
|
855
|
-
cr.set_source_rgb(1.0, 0.0, 0.0)
|
856
|
-
cr.fill_preserve
|
857
|
-
end
|
858
|
-
cr.restore
|
859
|
-
false # = draw other
|
860
|
-
# true # = Don't draw others
|
861
|
-
end
|
862
|
-
end
|
863
|
-
|
864
|
-
for pos in wpos
|
865
|
-
(x, y) = @view.pos_to_coord(pos)
|
866
|
-
# da.put(Gtk::Label.new("AB"), x, y)
|
867
|
-
label = Gtk::Label.new("<span background='#00000088' foreground='#ff0000' weight='ultrabold'>AB</span>")
|
868
|
-
label.use_markup = true
|
869
|
-
da.put(label, x, y)
|
870
|
-
end
|
871
|
-
|
872
|
-
# puts @view.pos_to_coord(300).inspect
|
873
|
-
|
874
|
-
@da.show_all
|
875
|
-
end
|
876
|
-
|
877
|
-
def init_keybindings
|
878
|
-
$kbd = KeyBindingTree.new()
|
879
|
-
$kbd.add_mode("C", :command)
|
880
|
-
$kbd.add_mode("I", :insert)
|
881
|
-
$kbd.add_mode("V", :visual)
|
882
|
-
$kbd.add_mode("M", :minibuffer)
|
883
|
-
$kbd.add_mode("R", :readchar)
|
884
|
-
$kbd.add_mode("B", :browse)
|
885
|
-
$kbd.set_default_mode(:command)
|
886
|
-
require "default_key_bindings"
|
887
|
-
|
888
|
-
$macro = Macro.new
|
889
|
-
|
890
|
-
# bindkey "VC j", "buf.move(FORWARD_LINE)"
|
891
|
-
bindkey "VC j", "puts('j_key_action')"
|
892
|
-
bindkey "VC ctrl-j", "puts('ctrl_j_key_action')"
|
893
|
-
|
894
|
-
bindkey "VC l", "buf.move(FORWARD_CHAR)"
|
895
|
-
bindkey "C x", "buf.delete(CURRENT_CHAR_FORWARD)"
|
896
|
-
# bindkey "C r <char>", "buf.replace_with_char(<char>)"
|
897
|
-
bindkey "I space", 'buf.insert_txt(" ")'
|
898
|
-
|
899
|
-
bindkey "VC l", "buf.move(FORWARD_CHAR)"
|
900
|
-
bindkey "VC j", "buf.move(FORWARD_LINE)"
|
901
|
-
bindkey "VC k", "buf.move(BACKWARD_LINE)"
|
902
|
-
bindkey "VC h", "buf.move(BACKWARD_CHAR)"
|
903
|
-
end
|
904
|
-
|
905
|
-
def handle_deltas()
|
906
|
-
while d = buf.deltas.shift
|
907
|
-
pos = d[0]
|
908
|
-
op = d[1]
|
909
|
-
num = d[2]
|
910
|
-
txt = d[3]
|
911
|
-
if op == DELETE
|
912
|
-
startiter = @buf1.get_iter_at(:offset => pos)
|
913
|
-
enditer = @buf1.get_iter_at(:offset => pos + num)
|
914
|
-
@buf1.delete(startiter, enditer)
|
915
|
-
elsif op == INSERT
|
916
|
-
startiter = @buf1.get_iter_at(:offset => pos)
|
917
|
-
@buf1.insert(startiter, txt)
|
918
|
-
end
|
919
|
-
end
|
920
|
-
end
|
921
|
-
|
922
|
-
def add_to_minibuf(msg)
|
923
|
-
startiter = @minibuf.buffer.get_iter_at(:offset => 0)
|
924
|
-
@minibuf.buffer.insert(startiter, "#{msg}\n")
|
925
|
-
@minibuf.signal_emit("move-cursor", Gtk::MovementStep.new(:PAGES), -1, false)
|
926
|
-
end
|
927
|
-
|
928
|
-
def init_minibuffer()
|
929
|
-
# Init minibuffer
|
930
|
-
sw = Gtk::ScrolledWindow.new
|
931
|
-
sw.set_policy(:automatic, :automatic)
|
932
|
-
overlay = Gtk::Overlay.new
|
933
|
-
overlay.add(sw)
|
934
|
-
@vpaned.pack2(overlay, :resize => false)
|
935
|
-
# overlay.set_size_request(-1, 50)
|
936
|
-
# $ovrl = overlay
|
937
|
-
# $ovrl.set_size_request(-1, 30)
|
938
|
-
$sw2 = sw
|
939
|
-
sw.set_size_request(-1, 12)
|
940
|
-
|
941
|
-
view = VSourceView.new()
|
942
|
-
view.set_highlight_current_line(false)
|
943
|
-
view.set_show_line_numbers(false)
|
944
|
-
# view.set_buffer(buf1)
|
945
|
-
ssm = GtkSource::StyleSchemeManager.new
|
946
|
-
ssm.set_search_path(ssm.search_path << ppath("styles/"))
|
947
|
-
sty = ssm.get_scheme("molokai_edit")
|
948
|
-
view.buffer.highlight_matching_brackets = false
|
949
|
-
view.buffer.style_scheme = sty
|
950
|
-
provider = Gtk::CssProvider.new
|
951
|
-
# provider.load(data: "textview { font-family: Monospace; font-size: 11pt; }")
|
952
|
-
provider.load(data: "textview { font-family: Arial; font-size: 10pt; color:#ff0000}")
|
953
|
-
view.style_context.add_provider(provider)
|
954
|
-
view.wrap_mode = :char
|
955
|
-
@minibuf = view
|
956
|
-
# Ripl.start :binding => binding
|
957
|
-
# startiter = view.buffer.get_iter_at(:offset => 0)
|
958
|
-
message("STARTUP")
|
959
|
-
sw.add(view)
|
960
|
-
end
|
961
|
-
|
962
|
-
def init_header_bar()
|
963
|
-
|
964
|
-
header = Gtk::HeaderBar.new
|
965
|
-
@header = header
|
966
|
-
header.show_close_button = true
|
967
|
-
header.title = ""
|
968
|
-
header.has_subtitle = true
|
969
|
-
header.subtitle = ""
|
970
|
-
# Ripl.start :binding => binding
|
971
|
-
|
972
|
-
|
973
|
-
# icon = Gio::ThemedIcon.new("mail-send-receive-symbolic")
|
974
|
-
# icon = Gio::ThemedIcon.new("document-open-symbolic")
|
975
|
-
# icon = Gio::ThemedIcon.new("dialog-password")
|
976
|
-
|
977
|
-
#edit-redo edit-paste edit-find-replace edit-undo edit-find edit-cut edit-copy
|
978
|
-
#document-open document-save document-save-as document-properties document-new
|
979
|
-
# document-revert-symbolic
|
980
|
-
#
|
981
|
-
|
982
|
-
#TODO:
|
983
|
-
# button = Gtk::Button.new
|
984
|
-
# icon = Gio::ThemedIcon.new("open-menu-symbolic")
|
985
|
-
# image = Gtk::Image.new(:icon => icon, :size => :button)
|
986
|
-
# button.add(image)
|
987
|
-
# header.pack_end(button)
|
988
|
-
|
989
|
-
button = Gtk::Button.new
|
990
|
-
icon = Gio::ThemedIcon.new("document-open-symbolic")
|
991
|
-
image = Gtk::Image.new(:icon => icon, :size => :button)
|
992
|
-
button.add(image)
|
993
|
-
header.pack_end(button)
|
994
|
-
|
995
|
-
button.signal_connect "clicked" do |_widget|
|
996
|
-
open_file_dialog
|
997
|
-
end
|
998
|
-
|
999
|
-
button = Gtk::Button.new
|
1000
|
-
icon = Gio::ThemedIcon.new("document-save-symbolic")
|
1001
|
-
image = Gtk::Image.new(:icon => icon, :size => :button)
|
1002
|
-
button.add(image)
|
1003
|
-
header.pack_end(button)
|
1004
|
-
button.signal_connect "clicked" do |_widget|
|
1005
|
-
buf.save
|
1006
|
-
end
|
1007
|
-
|
1008
|
-
button = Gtk::Button.new
|
1009
|
-
icon = Gio::ThemedIcon.new("document-new-symbolic")
|
1010
|
-
image = Gtk::Image.new(:icon => icon, :size => :button)
|
1011
|
-
button.add(image)
|
1012
|
-
header.pack_end(button)
|
1013
|
-
button.signal_connect "clicked" do |_widget|
|
1014
|
-
create_new_file
|
1015
|
-
end
|
1016
|
-
|
1017
|
-
box = Gtk::Box.new(:horizontal, 0)
|
1018
|
-
box.style_context.add_class("linked")
|
1019
|
-
|
1020
|
-
button = Gtk::Button.new
|
1021
|
-
image = Gtk::Image.new(:icon_name => "pan-start-symbolic", :size => :button)
|
1022
|
-
button.add(image)
|
1023
|
-
box.add(button)
|
1024
|
-
button.signal_connect "clicked" do |_widget|
|
1025
|
-
history_switch_backwards
|
1026
|
-
end
|
1027
|
-
|
1028
|
-
button = Gtk::Button.new
|
1029
|
-
image = Gtk::Image.new(:icon_name => "pan-end-symbolic", :size => :button)
|
1030
|
-
button.add(image)
|
1031
|
-
box.add(button)
|
1032
|
-
button.signal_connect "clicked" do |_widget|
|
1033
|
-
history_switch_forwards
|
1034
|
-
end
|
1035
|
-
|
1036
|
-
button = Gtk::Button.new
|
1037
|
-
icon = Gio::ThemedIcon.new("window-close-symbolic")
|
1038
|
-
image = Gtk::Image.new(:icon => icon, :size => :button)
|
1039
|
-
button.add(image)
|
1040
|
-
box.add(button)
|
1041
|
-
button.signal_connect "clicked" do |_widget|
|
1042
|
-
bufs.close_current_buffer
|
1043
|
-
end
|
1044
|
-
|
1045
|
-
header.pack_start(box)
|
1046
|
-
@window.titlebar = header
|
1047
|
-
@window.add(Gtk::TextView.new)
|
1048
|
-
end
|
1049
|
-
|
1050
|
-
def init_window
|
1051
|
-
@window = Gtk::Window.new(:toplevel)
|
1052
|
-
@window.set_default_size(650, 850)
|
1053
|
-
@window.title = "Multiple Views"
|
1054
|
-
@window.show_all
|
1055
|
-
# vpaned = Gtk::Paned.new(:horizontal)
|
1056
|
-
@vpaned = Gtk::Paned.new(:vertical)
|
1057
|
-
@window.add(@vpaned)
|
1058
|
-
|
1059
|
-
@sw = Gtk::ScrolledWindow.new
|
1060
|
-
@sw.set_policy(:automatic, :automatic)
|
1061
|
-
@overlay = Gtk::Overlay.new
|
1062
|
-
@overlay.add(@sw)
|
1063
|
-
@vpaned.pack1(@overlay, :resize => true)
|
1064
|
-
|
1065
|
-
init_minibuffer
|
1066
|
-
init_header_bar
|
1067
|
-
|
1068
|
-
@window.show_all
|
1069
|
-
|
1070
|
-
vma.start
|
1071
|
-
end
|
1072
|
-
end
|