vimamsa 0.1.20 → 0.1.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6b635655f9d50eb870f5593b8d2e63cfacff5ed0aece9b197ca8805622799ab0
4
- data.tar.gz: 8c579b33d9d5e5d48c25fef3da47ca77eb9ba9bf713cf7c2895c1af5e2cf2d30
3
+ metadata.gz: 3eba5b3c9a7821e14802295825b32369ff9440046b91b065ca2b1e82e44cc444
4
+ data.tar.gz: 16bd4a94226c3b07cb5d40cb6e395a09f8fbbb4e96e164af19b05415048a9812
5
5
  SHA512:
6
- metadata.gz: 1027546a7e21d7832e546f4ccd7eb9064aece5b7c13bef4d83477082351b2cc74e136c952999c69de70581aa651af2a5e8fd14960a1b52c91a0d0a7d08bd530c
7
- data.tar.gz: 3784552302bd4f7541320785f250fe9c4aa36e6bcd7d1317f9f85b776900211a1f7d5644891de6ae224703dca6ce9c0eda12fc894d1d4f73523e6bd149b6aebf
6
+ metadata.gz: f74f902af54d82002d4b0d814e80cafc5326bfb712c0cd124c39be0bb2bf3f70d1eaabe6c2f05de619ee9e9ac4cf12a10a4350c568ca1b815129904b40797c48
7
+ data.tar.gz: a01c59f8358904e1ad511c4608de70bc31ac8bc8ccbbfa240eb897240a68f7673b7ae1bc124dcf312b94a6c7f12834d33dba692e6795713f083a5b2736ac6291
data/README.md CHANGED
@@ -1,21 +1,38 @@
1
1
  # Vimamsa
2
2
 
3
- Vi/Vim -inspired experimental GUI-oriented text editor written with Ruby and GTK.
3
+ Vi/Vim -inspired experimental GUI-oriented text editor written with Ruby and GTK.
4
4
 
5
+ <!-- toc -->
6
+
7
+ - [Requirements](#requirements)
8
+ - [Installation](#installation)
9
+ * [Other install options](#other-install-options)
10
+ - [Run](#run)
11
+ - [Screenshots](#screenshots)
12
+ - [Key bindings](#key-bindings)
13
+ - [Current limitations](#current-limitations)
14
+
15
+ <!-- tocstop -->
5
16
 
6
17
  ## Requirements
7
18
  - Ruby 3.0+
8
19
  - GTK 4
9
20
 
21
+
10
22
  ## Installation
11
23
 
12
24
 
13
- On Ubuntu:
25
+ On Ubuntu (22.04):
14
26
  ```
15
- sudo apt install ruby-dev
27
+ sudo apt install ruby-dev build-essential
16
28
  sudo gem install vimamsa
17
29
  ```
18
30
 
31
+ Run:
32
+ ```
33
+ vimamsa
34
+ ```
35
+
19
36
  ### Other install options
20
37
 
21
38
  Install from sources:
@@ -40,7 +57,6 @@ vimamsa
40
57
  Install packages for optional features:
41
58
  ```
42
59
  sudo apt install ack-grep clang-format
43
- gem install ripl ripl-multi_line differ parallel listen rufo language_server-protocol
44
60
  ```
45
61
 
46
62
  For customization, edit ~/.vimamsa/custom.rb
@@ -52,7 +68,7 @@ For customization, edit ~/.vimamsa/custom.rb
52
68
 
53
69
  ## Key bindings
54
70
 
55
- Key bindings are very much like in VIm. For details, see file lib/vimamsa/key_bindings.rb and lib/vimamsa/key_bindings_vimlike.rb
71
+ Key bindings are very much like in VIm. For details, see menu item "Help -> Show key bindings" and file lib/vimamsa/key_bindings_vimlike.rb
56
72
 
57
73
  Keys that work somewhat similarly as in Vim:
58
74
 
@@ -70,8 +86,9 @@ d y gU gu
70
86
  Keys that work differently to Vim are documented in the tables below
71
87
 
72
88
  Syntax:
73
- ctrl! means press and immediate release of ctrl key. Triggered by key up event.
74
- ctrl-x means press and hold ctrl key, press x
89
+
90
+ - ctrl! means press and immediate release of ctrl key. Triggered by key up event when no other keys were pressed between key down and key up events.
91
+ - ctrl-x means press and hold ctrl key, press x
75
92
 
76
93
  <table>
77
94
  <colgroup>
@@ -144,6 +161,10 @@ For example, to bind ctrl-n to action "create new file":
144
161
  bindkey 'C ctrl-n', 'create_new_file()'
145
162
  ```
146
163
 
164
+
165
+ ## Known issues
166
+ - Cursor sometimes vanishes when dragging or resizing the window. At least some cases are fixed in new GTK4 versions ( >= 4.18, in Ubuntu Ubuntu 25.04). Workaround is to press ctrl key twice.
167
+
147
168
  ## Current limitations
148
169
  - UTF8 only
149
170
  - Line endings with "\n"
data/install.sh ADDED
@@ -0,0 +1,4 @@
1
+ #!/bin/bash
2
+ gem build vimamsa.gemspec
3
+ sudo gem uninstall vimamsa
4
+ sudo gem install --local $(ls -1tr *gem |head -n 1)
@@ -41,6 +41,7 @@ class Buffer < String
41
41
  @module = nil
42
42
 
43
43
  @last_save = @last_asked_from_user = @file_last_cheked = Time.now
44
+ @t_modified = @last_save
44
45
 
45
46
  @crypt = nil
46
47
  @update_highlight = true
@@ -1295,6 +1296,16 @@ class Buffer < String
1295
1296
  end_visual_mode
1296
1297
  end
1297
1298
 
1299
+ def eval_whole_buf(x = 888)
1300
+ s = self.to_s
1301
+ begin
1302
+ eval(s)
1303
+ rescue Exception
1304
+ message("Error running eval")
1305
+ else
1306
+ end
1307
+ end
1308
+
1298
1309
  def convert_selected_text(converter_id)
1299
1310
  return if !@visual_mode
1300
1311
  r = get_visual_mode_range
@@ -1503,6 +1514,7 @@ class Buffer < String
1503
1514
  #TODO: show message box
1504
1515
  end
1505
1516
  @last_save = Time.now
1517
+ refresh_title
1506
1518
  debug "file saved on #{@last_save}"
1507
1519
  sleep 3
1508
1520
  }
@@ -1515,6 +1527,20 @@ class Buffer < String
1515
1527
  end
1516
1528
  end
1517
1529
 
1530
+ def unsaved_changes?
1531
+ pp [@t_modified, @last_save]
1532
+ return true if @t_modified > @last_save
1533
+ return false
1534
+ end
1535
+
1536
+ def refresh_title
1537
+ if vma.buf == self
1538
+ pfx = ""
1539
+ pfx = "+ " if vma.buf.unsaved_changes?
1540
+ gui_set_window_title(pfx + vma.buf.title, vma.buf.subtitle)
1541
+ end
1542
+ end
1543
+
1518
1544
  def check_if_modified_outside
1519
1545
  # Don't check if less than 8 seconds since last checked
1520
1546
  return false if @fname.nil?
@@ -1597,4 +1623,3 @@ def backup_all_buffers()
1597
1623
  end
1598
1624
  message("Backup all buffers")
1599
1625
  end
1600
-
@@ -5,6 +5,7 @@ class Buffer < String
5
5
 
6
6
  #TODO: change to apply=true as default
7
7
  def add_delta(delta, apply = false, auto_update_cpos = false)
8
+ @t_modified = Time.now
8
9
  return if !is_delta_ok(delta)
9
10
  if delta[1] == DELETE
10
11
  return if delta[0] >= self.size
@@ -26,6 +27,7 @@ class Buffer < String
26
27
  add_delta([self.size, INSERT, 1, "\n"], true)
27
28
  end
28
29
  reset_larger_cpos #TODO: correct here?
30
+ refresh_title
29
31
  end
30
32
 
31
33
  # TODO: rename ot auto-format. separate module?
@@ -141,7 +141,7 @@ class Buffer < String
141
141
  end
142
142
 
143
143
  def jump_to_next_instance_of_word()
144
- if $kbd.last_action == $kbd.cur_action and @current_word != nil
144
+ if vma.kbd.last_action == vma.kbd.cur_action and @current_word != nil
145
145
  # debug "REPEATING *"
146
146
  else
147
147
  start_search = [@pos - 150, 0].max
@@ -154,7 +154,7 @@ class BufferList
154
154
  # end
155
155
  # vma.kbd.set_mode_to_default if vma.kbd.get_scope != :editor
156
156
 
157
- gui_set_window_title(vma.buf.title, vma.buf.subtitle)
157
+ vma.buf.refresh_title
158
158
 
159
159
  if vma.buf.fname
160
160
  @last_dir = File.dirname(vma.buf.fname)
@@ -180,7 +180,7 @@ class BufferList
180
180
  end
181
181
 
182
182
  def get_last_dir
183
- return @last_dir
183
+ return File.expand_path(@last_dir)
184
184
  end
185
185
 
186
186
  def reset_navigation
@@ -74,7 +74,7 @@ class Editor
74
74
 
75
75
  # build_key_bindings_tree
76
76
  @kbd = KeyBindingTree.new()
77
- $kbd = @kbd
77
+ $kbd = @kbd #TODO: remove global
78
78
  require "vimamsa/key_bindings_vimlike"
79
79
 
80
80
  $buffers = BufferList.new
@@ -139,7 +139,7 @@ class Editor
139
139
  fname = fname_
140
140
  end
141
141
  else
142
- fname = ppath("demo.txt")
142
+ # fname = ppath("demo.txt")
143
143
  end
144
144
  fname = ARGV[0] if ARGV.size >= 1 and File.file?(File.expand_path(ARGV[0]))
145
145
  # vma.add_content_search_path(Dir.pwd)
@@ -261,6 +261,9 @@ class Editor
261
261
  if p and !@file_content_search_paths.include?(p)
262
262
  r.insert(0, p)
263
263
  end
264
+
265
+ # Ensure that paths are in correct format
266
+ r = r.map{|x|File.expand_path(x)}
264
267
 
265
268
  return r
266
269
  end
@@ -365,21 +368,6 @@ def start_minibuffer_cmd(bufname, bufstr, cmd)
365
368
  $minibuffer.call_func = method(cmd)
366
369
  end
367
370
 
368
- def show_key_bindings()
369
- kbd_s = "❙Key bindings❙\n"
370
- kbd_s << "\n⦁[Mode] keys : action⦁\n"
371
-
372
- kbd_s << "[B]=Browse, [C]=Command, [I]=Insert, [V]=Visual\n"
373
- kbd_s << "key!: Press key once, release before pressing any other keys\n"
374
-
375
- kbd_s << "===============================================\n"
376
- kbd_s << vma.kbd.to_s
377
- kbd_s << "\n"
378
- kbd_s << "===============================================\n"
379
- b = create_new_buffer(kbd_s, "key-bindings")
380
- gui_set_file_lang(b.id, "hyperplaintext")
381
- #
382
- end
383
371
 
384
372
  def diff_buffer()
385
373
  bufstr = ""
@@ -412,14 +400,14 @@ end
412
400
 
413
401
  def minibuffer_end()
414
402
  debug "minibuffer_end"
415
- $kbd.set_mode(:command)
403
+ vma.kbd.set_mode(:command)
416
404
  minibuffer_input = $minibuffer.to_s[0..-2]
417
405
  return $minibuffer.call_func.call(minibuffer_input)
418
406
  end
419
407
 
420
408
  def minibuffer_cancel()
421
409
  debug "minibuffer_cancel"
422
- $kbd.set_mode(:command)
410
+ vma.kbd.set_mode(:command)
423
411
  minibuffer_input = $minibuffer.to_s[0..-2]
424
412
  # $minibuffer.call_func.call('')
425
413
  end
@@ -645,7 +633,7 @@ def find_project_dir_of_fn(fn)
645
633
  break
646
634
  end
647
635
  end
648
- return if !projdir.nil?
636
+ return projdir if !projdir.nil?
649
637
  end
650
638
  return projdir
651
639
  end
@@ -8,6 +8,7 @@ cnf.search_dirs = []
8
8
  class StringIndex
9
9
  def initialize()
10
10
  @idx = StrIdx::StringIndex.new
11
+ @idx.setDirSeparator("/")
11
12
  end
12
13
 
13
14
  def find(str, minChars: 2)
@@ -94,10 +95,15 @@ class FileFinder
94
95
  select_callback = self.method("gui_file_finder_select_callback")
95
96
  update_callback = self.method("gui_file_finder_update_callback")
96
97
 
98
+
99
+ opt = { :title => "Fuzzy filename search",
100
+ :desc => "Search for files in folders defined in cnf.search_dirs" ,
101
+ :columns => [{:title=>'Filename',:id=>0}]
102
+ }
103
+
97
104
  gui_select_update_window(l, $select_keys.collect { |x| x.upcase },
98
- # "gui_file_finder_select_callback",
99
105
  select_callback,
100
- update_callback)
106
+ update_callback, opt)
101
107
  end
102
108
 
103
109
  def gui_file_finder_update_callback(search_str = "")
@@ -105,8 +111,11 @@ class FileFinder
105
111
  if (search_str.size >= 3)
106
112
  files = filter_files(search_str)
107
113
  @file_search_list = files
114
+ if files.size > 1
115
+ files = files.collect{|x|[tilde_path(x[0])]}
116
+ end
117
+
108
118
  return files
109
- #debug files.inspect
110
119
  #return files.values
111
120
  end
112
121
  return []
@@ -18,7 +18,7 @@ class FileManager
18
18
  end
19
19
 
20
20
  def self.init()
21
- reg_act(:start_file_selector, proc { FileManager.new.run; vma.kbd.set_mode(:file_exp); }, "File selector")
21
+ reg_act(:start_file_selector, proc { FileManager.new.run; vma.kbd.set_mode(:file_exp) }, "File selector")
22
22
 
23
23
  reg_act(:fexp_chdir_parent, proc { FileManager.chdir_parent }, "File selector")
24
24
  reg_act(:fexp_select, proc { buf.module.select_line }, "")
@@ -162,13 +162,14 @@ class FileManager
162
162
  #TODO:
163
163
  end
164
164
 
165
+ # Main inteface, show contents of current dir
165
166
  def dir_to_buf(dirpath, b = nil)
166
167
  # File.stat("testfile").mtime
167
168
 
168
169
  debug "last file: #{vma.buffers.last_file}", 2
169
170
  lastf = vma.buffers.last_file
170
171
  jumpto = nil
171
- if File.dirname(lastf) == dirpath
172
+ if !lastf.nil? and File.dirname(lastf) == dirpath
172
173
  jumpto = File.basename(lastf)
173
174
  end
174
175
  vma.buffers.last_dir = dirpath
@@ -231,6 +232,13 @@ class FileManager
231
232
  else
232
233
  @buf.set_line_and_column_pos(@header.size, 0)
233
234
  end
235
+
236
+ if @cdirs.size > 0
237
+ r = vma.buf.line_range(2, @cdirs.size+1)
238
+
239
+ # Hilight works only if done after buffer is drawn
240
+ run_as_idle proc { Gui.hilight_range(vma.buf, r, color: "#4488ffff") }
241
+ end
234
242
  end
235
243
 
236
244
  def fullp(fn)
@@ -267,7 +275,6 @@ class FileManager
267
275
  jump_to_file(fn)
268
276
  # vma.buffers.set_current_buffer(idx)
269
277
  vma.buffers.close_other_buffer(@buf.id)
270
-
271
278
  else
272
279
  open_with_default_program(fn)
273
280
  end
data/lib/vimamsa/gui.rb CHANGED
@@ -348,7 +348,7 @@ class VMAgui
348
348
  sw.set_child(view)
349
349
  end
350
350
 
351
- #TODO: implement in gtk4
351
+ #TODO: implement in gtk4
352
352
  def init_header_bar()
353
353
  header = Gtk::HeaderBar.new
354
354
  @header = header
@@ -577,17 +577,36 @@ class VMAgui
577
577
 
578
578
  reset_controllers
579
579
 
580
+ focus_controller = Gtk::EventControllerFocus.new
581
+
582
+ focus_controller.signal_connect("enter") do
583
+ debug "Gained focus"
584
+ draw_cursor_bug_workaround
585
+ end
586
+ @window.add_controller(focus_controller)
587
+
588
+ motion_controller = Gtk::EventControllerMotion.new
589
+ motion_controller.signal_connect("motion") do |controller, x, y|
590
+ # label.set_text("Mouse at: (%.1f, %.1f)" % [x, y])
591
+ # puts "MOVE #{x} #{y}"
592
+
593
+ # Cursor vanishes when hovering over menubar
594
+ draw_cursor_bug_workaround if y < 30
595
+ @last_cursor = [x, y]
596
+ @cursor_move_time = Time.now
597
+ end
598
+ @window.add_controller(motion_controller)
599
+
580
600
  @windows[1] = new_window(1)
581
601
 
582
602
  @last_adj_time = Time.now
583
603
 
584
-
585
604
  # To show keyboard key binding state
586
605
  @statnfo = Gtk::Label.new
587
-
606
+
588
607
  # To show e.g. current folder
589
608
  @subtitle = Gtk::Label.new("")
590
-
609
+
591
610
  @statbox = Gtk::Box.new(:horizontal, 2)
592
611
  @statnfo.set_size_request(150, 10)
593
612
  @statbox.append(@subtitle)
@@ -618,6 +637,12 @@ class VMAgui
618
637
 
619
638
  @window.show
620
639
 
640
+ surface = @window.native.surface
641
+ tt = Time.now
642
+ surface.signal_connect("layout") do
643
+ # puts "Window resized or moved, other redraw."
644
+ end
645
+
621
646
  run_as_idle proc { idle_set_size }
622
647
 
623
648
  prov = Gtk::CssProvider.new
@@ -666,9 +691,9 @@ class VMAgui
666
691
  return true if Time.now - @monitor_time < 0.2
667
692
  # Detect element resize
668
693
  if swa.width != @sw_width
669
- # puts "@sw.width=#{@sw.width}"
694
+ debug "Width change sw_width #{@sw_width}"
670
695
  @sw_width = swa.width
671
- DelayExecutioner.exec(id: :scale_images, wait: 0.7, callable: proc { vma.gui.scale_all_images })
696
+ DelayExecutioner.exec(id: :scale_images, wait: 0.7, callable: proc { debug ":scale_images"; vma.gui.scale_all_images })
672
697
  end
673
698
  @monitor_time = Time.now
674
699
  return true
@@ -1,16 +1,7 @@
1
1
  # class VSourceView < Gtk::TextView
2
2
  class VSourceView < GtkSource::View
3
3
  attr_accessor :bufo, :autocp_active, :cpl_list
4
- # :highlight_matching_brackets
5
4
 
6
- # def set_highlight_current_line(vbool)
7
- # end
8
-
9
- # def set_show_line_numbers(vbool)
10
- # end
11
-
12
- # def highlight_matching_brackets=(vbool)
13
- # end
14
5
 
15
6
  # def initialize(title = nil,bufo=nil)
16
7
  def initialize(title, bufo)
@@ -27,29 +18,6 @@ class VSourceView < GtkSource::View
27
18
 
28
19
  @tt = nil
29
20
 
30
- # self.drag_dest_add_image_targets #TODO:gtk4
31
- # self.drag_dest_add_uri_targets #TODO:gtk4
32
-
33
- # signal_connect("drag-data-received") do |widget, event, x, y, data, info, time| #TODO:gtk4
34
- # puts "drag-data-received"
35
- # puts
36
- # if data.uris.size >= 1
37
-
38
- # imgpath = CGI.unescape(data.uris[0])
39
- # m = imgpath.match(/^file:\/\/(.*)/)
40
- # if m
41
- # fp = m[1]
42
- # handle_drag_and_drop(fp)
43
- # end
44
- # end
45
- # true
46
- # end
47
-
48
- # signal_connect("show-completion") do |x, y, z|
49
- # debug "SHOW-COMPLETION", 2
50
- # false
51
- # end
52
-
53
21
  # Mainly after page-up or page-down
54
22
  signal_connect("move-cursor") do |widget, event|
55
23
  # if event.name == "GTK_MOVEMENT_PAGES" and (vma.actions.last_action == "page_up" or vma.actions.last_action == "page_down")
@@ -70,7 +38,6 @@ class VSourceView < GtkSource::View
70
38
 
71
39
  return
72
40
 
73
- #TODO:gtk4
74
41
  signal_connect "button-release-event" do |widget, event|
75
42
  vma.buf.set_pos(buffer.cursor_position)
76
43
  false
@@ -104,9 +71,18 @@ class VSourceView < GtkSource::View
104
71
  # Sometimes a GestureClick EventController appears from somewhere
105
72
  # not initiated from this file.
106
73
 
107
- # if ctr.class == Gtk::EventControllerKey or ctr.class == Gtk::GestureClick
108
- if ctr != @click
109
- # to_remove << ctr if ctr.class != Gtk::GestureDrag
74
+ # TODO: Check which of these are needed:
75
+ # puts ctr.class
76
+ # Gtk::DropTarget
77
+ # Gtk::EventControllerFocus
78
+ # Gtk::EventControllerKey
79
+ # Gtk::EventControllerMotion
80
+ # Gtk::EventControllerScroll
81
+ # Gtk::GestureClick
82
+ # Gtk::GestureDrag
83
+ # Gtk::ShortcutController
84
+
85
+ if ![@click, @dt].include?(ctr) and [Gtk::DropControllerMotion, Gtk::DropTarget, Gtk::GestureDrag, Gtk::GestureClick, Gtk::EventControllerKey].include?(ctr.class)
110
86
  to_remove << ctr
111
87
  end
112
88
  }
@@ -120,20 +96,19 @@ class VSourceView < GtkSource::View
120
96
  end
121
97
 
122
98
  def focus_out()
123
- set_cursor_color(:inactive)
124
-
125
- # This does not seem to work: (TODO:why?)
126
- # self.cursor_visible = false
99
+ set_cursor_color(:inactive)
100
+
101
+ # This does not seem to work: (TODO:why?)
102
+ # self.cursor_visible = false
127
103
  end
128
-
104
+
129
105
  def focus_in()
130
- set_cursor_color(@ctype)
131
- self.cursor_visible = false
132
- self.cursor_visible = true
133
- self.grab_focus
106
+ set_cursor_color(@ctype)
107
+ self.cursor_visible = false
108
+ self.cursor_visible = true
109
+ self.grab_focus
134
110
  end
135
-
136
-
111
+
137
112
  def register_signals()
138
113
  check_controllers
139
114
 
@@ -149,11 +124,8 @@ class VSourceView < GtkSource::View
149
124
  uri = v.value.gsub(/\r\n$/, "")
150
125
  end
151
126
  debug "dt,drop #{v.value},#{x},#{y}", 2
152
- begin
153
- fp = URI(uri).path
154
- buf.handle_drag_and_drop(fp)
155
- rescue URI::InvalidURIError
156
- end
127
+ fp = uri_to_path(uri)
128
+ buf.handle_drag_and_drop(fp) if !fp.nil?
157
129
  true
158
130
  end
159
131
 
@@ -332,7 +304,7 @@ class VSourceView < GtkSource::View
332
304
  end
333
305
  debug $view.visible_rect.inspect
334
306
 
335
- debug "key event"
307
+ debug "key event" + [keyval, @last_keyval, keyname, sig].to_s
336
308
  # debug event
337
309
 
338
310
  # key_name = event.string
@@ -353,6 +325,7 @@ class VSourceView < GtkSource::View
353
325
  keyval_trans[Gdk::Keyval::KEY_KP_Enter] = "enter"
354
326
  keyval_trans[Gdk::Keyval::KEY_Alt_L] = "alt"
355
327
  keyval_trans[Gdk::Keyval::KEY_Alt_R] = "alt"
328
+ keyval_trans[Gdk::Keyval::KEY_Caps_Lock] = "caps"
356
329
 
357
330
  keyval_trans[Gdk::Keyval::KEY_BackSpace] = "backspace"
358
331
  keyval_trans[Gdk::Keyval::KEY_KP_Page_Down] = "pagedown"
@@ -383,6 +356,15 @@ class VSourceView < GtkSource::View
383
356
  key_str_parts << "super" if vma.kbd.modifiers[:super]
384
357
  key_str_parts << keyname
385
358
 
359
+ # After remapping capslock to control in gnome-tweak tool,
360
+ # if pressing and immediately releasing the capslock (control) key,
361
+ # we get first "caps" on keydown and ctrl-"caps" on keyup (keyval 65509, Gdk::Keyval::KEY_Caps_Lock)
362
+ # If mapping capslock to ctrl in hardware, we get keyval 65507 (Gdk::Keyval::KEY_Control_L) instead
363
+ if key_str_parts[0] == "ctrl" and key_str_parts[1] == "caps"
364
+ # Replace ctrl-caps with ctrl
365
+ key_str_parts.delete_at(1)
366
+ end
367
+
386
368
  if key_str_parts[0] == key_str_parts[1]
387
369
  # We don't want "ctrl-ctrl" or "alt-alt"
388
370
  # TODO:There should be a better way to do this
@@ -404,19 +386,19 @@ class VSourceView < GtkSource::View
404
386
 
405
387
  keynfo = { :key_str => key_str, :key_name => keyname, :keyval => keyval }
406
388
  debug keynfo.inspect
407
- # $kbd.match_key_conf(key_str, nil, :key_press)
389
+ # vma.kbd.match_key_conf(key_str, nil, :key_press)
408
390
  # debug "key_str=#{key_str} key_"
409
391
 
410
392
  if key_str != "" # or prefixed_key_str != ""
411
393
  if sig == :key_release and keyval == @last_keyval
412
- $kbd.match_key_conf(key_str + "!", nil, :key_release)
394
+ vma.kbd.match_key_conf(key_str + "!", nil, :key_release)
413
395
  @last_event = [keynfo, :key_release]
414
396
  elsif sig == :key_press
415
- $kbd.match_key_conf(key_str, nil, :key_press)
397
+ vma.kbd.match_key_conf(key_str, nil, :key_press)
416
398
  @last_event = [keynfo, key_str, :key_press]
417
399
  end
418
- @last_keyval = keyval #TODO: outside if?
419
400
  end
401
+ @last_keyval = keyval
420
402
 
421
403
  handle_deltas
422
404
 
@@ -596,7 +578,6 @@ class VSourceView < GtkSource::View
596
578
  end
597
579
 
598
580
  def draw_cursor
599
-
600
581
  sv = vma.gui.active_window[:sw].child
601
582
  return if sv.nil?
602
583
  if sv != self # if we are not the current buffer
@@ -652,3 +633,4 @@ class VSourceView < GtkSource::View
652
633
  end
653
634
  end #end draw_cursor
654
635
  end
636
+