vimamsa 0.1.7 → 0.1.8
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 +4 -4
 - data/lib/vimamsa/actions.rb +6 -6
 - data/lib/vimamsa/buffer.rb +69 -39
 - data/lib/vimamsa/buffer_list.rb +24 -0
 - data/lib/vimamsa/buffer_manager.rb +83 -0
 - data/lib/vimamsa/conf.rb +21 -0
 - data/lib/vimamsa/debug.rb +3 -2
 - data/lib/vimamsa/easy_jump.rb +7 -7
 - data/lib/vimamsa/editor.rb +24 -17
 - data/lib/vimamsa/file_finder.rb +5 -6
 - data/lib/vimamsa/file_history.rb +3 -3
 - data/lib/vimamsa/file_manager.rb +9 -8
 - data/lib/vimamsa/gui.rb +15 -17
 - data/lib/vimamsa/gui_menu.rb +11 -1
 - data/lib/vimamsa/gui_select_window.rb +13 -13
 - data/lib/vimamsa/gui_sourceview.rb +23 -23
 - data/lib/vimamsa/hyper_plain_text.rb +8 -10
 - data/lib/vimamsa/key_actions.rb +4 -0
 - data/lib/vimamsa/key_binding_tree.rb +27 -27
 - data/lib/vimamsa/key_bindings_vimlike.rb +1 -1
 - data/lib/vimamsa/macro.rb +5 -5
 - data/lib/vimamsa/rbvma.rb +11 -10
 - data/lib/vimamsa/search.rb +1 -1
 - data/lib/vimamsa/search_replace.rb +3 -4
 - data/lib/vimamsa/version.rb +1 -1
 - metadata +4 -3
 - data/lib/vimamsa/gui_gtk_sourceview.rb +0 -294
 
| 
         @@ -1,10 +1,5 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            def hpt_open_link()
         
     | 
| 
       4 
     | 
    
         
            -
            end
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
1 
     | 
    
         
             
            def hpt_check_cur_word(w)
         
     | 
| 
       7 
     | 
    
         
            -
               
     | 
| 
      
 2 
     | 
    
         
            +
              debug "check_cur_word(w)"
         
     | 
| 
       8 
3 
     | 
    
         
             
              m = w.match(/⟦(.*)⟧/)
         
     | 
| 
       9 
4 
     | 
    
         
             
              if m
         
     | 
| 
       10 
5 
     | 
    
         
             
                fpfx = m[1]
         
     | 
| 
         @@ -12,8 +7,10 @@ def hpt_check_cur_word(w) 
     | 
|
| 
       12 
7 
     | 
    
         
             
                  dn = File.dirname($buffer.fname)
         
     | 
| 
       13 
8 
     | 
    
         | 
| 
       14 
9 
     | 
    
         
             
                  fcands = []
         
     | 
| 
       15 
     | 
    
         
            -
                   
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
      
 10 
     | 
    
         
            +
                  if fpfx[0] != "/"
         
     | 
| 
      
 11 
     | 
    
         
            +
                    fcands << "#{dn}/#{fpfx}"
         
     | 
| 
      
 12 
     | 
    
         
            +
                    fcands << "#{dn}/#{fpfx}.txt"
         
     | 
| 
      
 13 
     | 
    
         
            +
                  end
         
     | 
| 
       17 
14 
     | 
    
         
             
                  fcands << File.expand_path("#{fpfx}")
         
     | 
| 
       18 
15 
     | 
    
         
             
                  fcands << File.expand_path("#{fpfx}.txt")
         
     | 
| 
       19 
16 
     | 
    
         | 
| 
         @@ -38,22 +35,23 @@ def hpt_check_cur_word(w) 
     | 
|
| 
       38 
35 
     | 
    
         
             
              return nil
         
     | 
| 
       39 
36 
     | 
    
         
             
            end
         
     | 
| 
       40 
37 
     | 
    
         | 
| 
      
 38 
     | 
    
         
            +
            # Scan images inserted with ⟦img:filepath⟧ syntax
         
     | 
| 
       41 
39 
     | 
    
         
             
            def hpt_scan_images()
         
     | 
| 
       42 
40 
     | 
    
         
             
              return if !buf.fname
         
     | 
| 
       43 
41 
     | 
    
         
             
              return if !buf.fname.match(/.*txt$/)
         
     | 
| 
       44 
42 
     | 
    
         
             
              imgpos = scan_indexes(buf, /⟦img:.+?⟧/)
         
     | 
| 
       45 
43 
     | 
    
         
             
              imgtags = buf.scan(/(⟦img:(.+?)⟧)/)
         
     | 
| 
       46 
     | 
    
         
            -
              # i = 0
         
     | 
| 
       47 
44 
     | 
    
         
             
              c = 0
         
     | 
| 
       48 
45 
     | 
    
         
             
              imgpos.each.with_index { |x, i|
         
     | 
| 
       49 
46 
     | 
    
         
             
                a = imgpos[i]
         
     | 
| 
       50 
47 
     | 
    
         
             
                t = imgtags[i]
         
     | 
| 
       51 
48 
     | 
    
         
             
                insert_pos = a + t[0].size + c
         
     | 
| 
       52 
49 
     | 
    
         
             
                imgfn = File.expand_path(t[1])
         
     | 
| 
       53 
     | 
    
         
            -
                # Ripl.start :binding => binding
         
     | 
| 
       54 
50 
     | 
    
         
             
                next if !File.exist?(imgfn)
         
     | 
| 
      
 51 
     | 
    
         
            +
                # Show as image in gui, handle as empty space in txt file
         
     | 
| 
       55 
52 
     | 
    
         
             
                if buf[insert_pos..(insert_pos + 2)] != "\n \n"
         
     | 
| 
       56 
53 
     | 
    
         
             
                  buf.insert_txt_at("\n \n", insert_pos)
         
     | 
| 
      
 54 
     | 
    
         
            +
                  buf.view.handle_deltas
         
     | 
| 
       57 
55 
     | 
    
         
             
                  c += 3
         
     | 
| 
       58 
56 
     | 
    
         
             
                end
         
     | 
| 
       59 
57 
     | 
    
         
             
                buf.add_image(imgfn, insert_pos + 1)
         
     | 
    
        data/lib/vimamsa/key_actions.rb
    CHANGED
    
    | 
         @@ -28,6 +28,10 @@ def is_visual_mode() 
     | 
|
| 
       28 
28 
     | 
    
         
             
              return 0
         
     | 
| 
       29 
29 
     | 
    
         
             
            end
         
     | 
| 
       30 
30 
     | 
    
         | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
            reg_act(:enable_debug, proc { $debug=true }, "Enable debug")
         
     | 
| 
      
 33 
     | 
    
         
            +
            reg_act(:disable_debug, proc {$debug=false }, "Disable debug")
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
       31 
35 
     | 
    
         
             
            reg_act(:easy_jump, proc { EasyJump.start }, "Easy jump")
         
     | 
| 
       32 
36 
     | 
    
         
             
            reg_act(:savedebug, "savedebug", "Save debug info", { :group => :debug })
         
     | 
| 
       33 
37 
     | 
    
         
             
            reg_act(:open_file_dialog, "open_file_dialog", "Open file", { :group => :file })
         
     | 
| 
         @@ -127,16 +127,16 @@ class KeyBindingTree 
     | 
|
| 
       127 
127 
     | 
    
         
             
                @match_state.each { |parent|
         
     | 
| 
       128 
128 
     | 
    
         
             
                  parent.children.each { |c|
         
     | 
| 
       129 
129 
     | 
    
         
             
                    # printf(" KEY MATCH: ")
         
     | 
| 
       130 
     | 
    
         
            -
                    #  
     | 
| 
      
 130 
     | 
    
         
            +
                    # debug [c.key_name, key_name].inspect
         
     | 
| 
       131 
131 
     | 
    
         
             
                    if c.key_name == key_name and c.eval_rule == ""
         
     | 
| 
       132 
132 
     | 
    
         
             
                      new_state << c
         
     | 
| 
       133 
133 
     | 
    
         
             
                    elsif c.key_name == key_name and c.eval_rule != ""
         
     | 
| 
       134 
     | 
    
         
            -
                       
     | 
| 
      
 134 
     | 
    
         
            +
                      debug "CHECK EVAL: #{c.eval_rule}"
         
     | 
| 
       135 
135 
     | 
    
         
             
                      if eval(c.eval_rule)
         
     | 
| 
       136 
136 
     | 
    
         
             
                        new_state << c
         
     | 
| 
       137 
     | 
    
         
            -
                         
     | 
| 
      
 137 
     | 
    
         
            +
                        debug "EVAL TRUE"
         
     | 
| 
       138 
138 
     | 
    
         
             
                      else
         
     | 
| 
       139 
     | 
    
         
            -
                         
     | 
| 
      
 139 
     | 
    
         
            +
                        debug "EVAL FALSE"
         
     | 
| 
       140 
140 
     | 
    
         
             
                      end
         
     | 
| 
       141 
141 
     | 
    
         
             
                    end
         
     | 
| 
       142 
142 
     | 
    
         
             
                  }
         
     | 
| 
         @@ -195,7 +195,7 @@ class KeyBindingTree 
     | 
|
| 
       195 
195 
     | 
    
         
             
                end
         
     | 
| 
       196 
196 
     | 
    
         | 
| 
       197 
197 
     | 
    
         
             
                @state_trail = [@mode_root_state]
         
     | 
| 
       198 
     | 
    
         
            -
                #  
     | 
| 
      
 198 
     | 
    
         
            +
                # debug get_state_trail_str()
         
     | 
| 
       199 
199 
     | 
    
         
             
                # $next_command_count = nil # TODO: set somewhere else?
         
     | 
| 
       200 
200 
     | 
    
         
             
              end
         
     | 
| 
       201 
201 
     | 
    
         | 
| 
         @@ -305,18 +305,18 @@ class KeyBindingTree 
     | 
|
| 
       305 
305 
     | 
    
         | 
| 
       306 
306 
     | 
    
         
             
                if new_state != nil
         
     | 
| 
       307 
307 
     | 
    
         
             
                  @state_trail << new_state
         
     | 
| 
       308 
     | 
    
         
            -
                   
     | 
| 
       309 
     | 
    
         
            -
                  # #  
     | 
| 
      
 308 
     | 
    
         
            +
                  debug get_state_trail_str()
         
     | 
| 
      
 309 
     | 
    
         
            +
                  # # debug "CUR STATE: #{@state_trail.collect{|x| x.to_s}.join}"
         
     | 
| 
       310 
310 
     | 
    
         
             
                  # s_trail = ""
         
     | 
| 
       311 
311 
     | 
    
         
             
                  # for st in @state_trail
         
     | 
| 
       312 
312 
     | 
    
         
             
                  # st = st[0] if st.class == Array
         
     | 
| 
       313 
313 
     | 
    
         
             
                  # s_trail << " #{st.to_s}"
         
     | 
| 
       314 
314 
     | 
    
         
             
                  # end
         
     | 
| 
       315 
     | 
    
         
            -
                  #  
     | 
| 
      
 315 
     | 
    
         
            +
                  # debug "CUR STATE: #{s_trail}"
         
     | 
| 
       316 
316 
     | 
    
         
             
                  # for cstate in new_state[0].children
         
     | 
| 
       317 
317 
     | 
    
         
             
                  # act_s = "..."
         
     | 
| 
       318 
318 
     | 
    
         
             
                  # act_s = cstate.action.to_s if cstate.action != nil
         
     | 
| 
       319 
     | 
    
         
            -
                  #  
     | 
| 
      
 319 
     | 
    
         
            +
                  # debug "  #{cstate.to_s} #{act_s}"
         
     | 
| 
       320 
320 
     | 
    
         
             
                  # end
         
     | 
| 
       321 
321 
     | 
    
         
             
                  # new_state[0].children.collect{|x|x.to_s}
         
     | 
| 
       322 
322 
     | 
    
         
             
                end
         
     | 
| 
         @@ -330,7 +330,7 @@ class KeyBindingTree 
     | 
|
| 
       330 
330 
     | 
    
         
             
                  end
         
     | 
| 
       331 
331 
     | 
    
         | 
| 
       332 
332 
     | 
    
         
             
                  if event_type == :key_release and c == "shift!"
         
     | 
| 
       333 
     | 
    
         
            -
                    # Pressing a modifier key (shift)  
     | 
| 
      
 333 
     | 
    
         
            +
                    # Pressing a modifier key (shift) sets state back to root
         
     | 
| 
       334 
334 
     | 
    
         
             
                    # only on key release when no other key has been pressed
         
     | 
| 
       335 
335 
     | 
    
         
             
                    # after said modifier key (shift).
         
     | 
| 
       336 
336 
     | 
    
         
             
                    set_state_to_root
         
     | 
| 
         @@ -346,14 +346,14 @@ class KeyBindingTree 
     | 
|
| 
       346 
346 
     | 
    
         | 
| 
       347 
347 
     | 
    
         
             
                  if s_act.any? and !state_with_children.any?
         
     | 
| 
       348 
348 
     | 
    
         
             
                    eval_s = s_act.first.action if eval_s == nil
         
     | 
| 
       349 
     | 
    
         
            -
                     
     | 
| 
       350 
     | 
    
         
            -
                     
     | 
| 
      
 349 
     | 
    
         
            +
                    debug "FOUND MATCH:#{eval_s}"
         
     | 
| 
      
 350 
     | 
    
         
            +
                    debug "CHAR: #{c}"
         
     | 
| 
       351 
351 
     | 
    
         
             
                    c.gsub!("\\", %q{\\\\} * 4) # Escape \ -chars
         
     | 
| 
       352 
352 
     | 
    
         
             
                    c.gsub!("'", "#{'\\' * 4}'") # Escape ' -chars
         
     | 
| 
       353 
353 
     | 
    
         | 
| 
       354 
354 
     | 
    
         
             
                    eval_s.gsub!("<char>", "'#{c}'") if eval_s.class == String
         
     | 
| 
       355 
     | 
    
         
            -
                     
     | 
| 
       356 
     | 
    
         
            -
                     
     | 
| 
      
 355 
     | 
    
         
            +
                    debug eval_s
         
     | 
| 
      
 356 
     | 
    
         
            +
                    debug c
         
     | 
| 
       357 
357 
     | 
    
         
             
                    handle_key_bindigs_action(eval_s, c)
         
     | 
| 
       358 
358 
     | 
    
         
             
                    set_state_to_root
         
     | 
| 
       359 
359 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -365,7 +365,7 @@ class KeyBindingTree 
     | 
|
| 
       365 
365 
     | 
    
         
             
              # Receive keyboard event from Qt
         
     | 
| 
       366 
366 
     | 
    
         
             
              def handle_key_event(event)
         
     | 
| 
       367 
367 
     | 
    
         
             
                start_profiler
         
     | 
| 
       368 
     | 
    
         
            -
                #  
     | 
| 
      
 368 
     | 
    
         
            +
                # debug "GOT KEY EVENT: #{key.inspect}"
         
     | 
| 
       369 
369 
     | 
    
         
             
                debug "GOT KEY EVENT:: #{event} #{event[2]}"
         
     | 
| 
       370 
370 
     | 
    
         
             
                debug "|#{event.inspect}|"
         
     | 
| 
       371 
371 
     | 
    
         
             
                $debuginfo["cur_event"] = event
         
     | 
| 
         @@ -392,11 +392,11 @@ class KeyBindingTree 
     | 
|
| 
       392 
392 
     | 
    
         
             
                  end
         
     | 
| 
       393 
393 
     | 
    
         
             
                end
         
     | 
| 
       394 
394 
     | 
    
         | 
| 
       395 
     | 
    
         
            -
                #  
     | 
| 
       396 
     | 
    
         
            -
                #  
     | 
| 
       397 
     | 
    
         
            -
                #  
     | 
| 
       398 
     | 
    
         
            -
                #  
     | 
| 
       399 
     | 
    
         
            -
                #  
     | 
| 
      
 395 
     | 
    
         
            +
                # debug "----D------------"
         
     | 
| 
      
 396 
     | 
    
         
            +
                # debug @modifiers.inspect
         
     | 
| 
      
 397 
     | 
    
         
            +
                # debug event.inspect
         
     | 
| 
      
 398 
     | 
    
         
            +
                # debug event[4] & ALTMODIFIER
         
     | 
| 
      
 399 
     | 
    
         
            +
                # debug "-----------------"
         
     | 
| 
       400 
400 
     | 
    
         | 
| 
       401 
401 
     | 
    
         
             
                @modifiers.delete(keycode) if event_type == KEY_RELEASE
         
     | 
| 
       402 
402 
     | 
    
         | 
| 
         @@ -422,7 +422,7 @@ class KeyBindingTree 
     | 
|
| 
       422 
422 
     | 
    
         
             
                if $translate_table.include?(keycode)
         
     | 
| 
       423 
423 
     | 
    
         
             
                  key_str2 = $translate_table[keycode].downcase
         
     | 
| 
       424 
424 
     | 
    
         
             
                end
         
     | 
| 
       425 
     | 
    
         
            -
                #  
     | 
| 
      
 425 
     | 
    
         
            +
                # debug "key_str=|#{key_str}| key_str=|#{key_str.inspect}| key_str2=|#{key_str2}|"
         
     | 
| 
       426 
426 
     | 
    
         
             
                prefixed_key_str = key_prefix + key_str2
         
     | 
| 
       427 
427 
     | 
    
         | 
| 
       428 
428 
     | 
    
         
             
                # Space is only key in $event_keysym_translate_table
         
     | 
| 
         @@ -430,7 +430,7 @@ class KeyBindingTree 
     | 
|
| 
       430 
430 
     | 
    
         
             
                key_str = " " if key_str == "space" # HACK
         
     | 
| 
       431 
431 
     | 
    
         | 
| 
       432 
432 
     | 
    
         
             
                # if keycode == @last_event[0] and event_type == KEY_RELEASE
         
     | 
| 
       433 
     | 
    
         
            -
                #  
     | 
| 
      
 433 
     | 
    
         
            +
                # debug "KEY! key_str=|#{key_str}| prefixed_key_str=|#{prefixed_key_str}|"
         
     | 
| 
       434 
434 
     | 
    
         
             
                # end
         
     | 
| 
       435 
435 
     | 
    
         | 
| 
       436 
436 
     | 
    
         
             
                if key_str != "" or prefixed_key_str != ""
         
     | 
| 
         @@ -485,7 +485,7 @@ class KeyBindingTree 
     | 
|
| 
       485 
485 
     | 
    
         
             
                m = key.match(/^(\S+)\s(\S.*)$/)
         
     | 
| 
       486 
486 
     | 
    
         
             
                if m
         
     | 
| 
       487 
487 
     | 
    
         
             
                  modetmp = m[1]
         
     | 
| 
       488 
     | 
    
         
            -
                   
     | 
| 
      
 488 
     | 
    
         
            +
                  debug [key, modetmp, m].inspect
         
     | 
| 
       489 
489 
     | 
    
         
             
                  modes = modetmp.split("") if modetmp.match(/^\p{Lu}+$/) # Uppercase
         
     | 
| 
       490 
490 
     | 
    
         
             
                  modes = [modetmp] if modetmp.match(/^\p{Ll}+$/) # Lowercase
         
     | 
| 
       491 
491 
     | 
    
         
             
                  keydef = m[2]
         
     | 
| 
         @@ -568,10 +568,10 @@ class KeyBindingTree 
     | 
|
| 
       568 
568 
     | 
    
         
             
                  # debug("NameError with eval cmd #{action}: " + $!.to_s)
         
     | 
| 
       569 
569 
     | 
    
         
             
                  # raise
         
     | 
| 
       570 
570 
     | 
    
         
             
                rescue Exception => e
         
     | 
| 
       571 
     | 
    
         
            -
                   
     | 
| 
       572 
     | 
    
         
            -
                   
     | 
| 
       573 
     | 
    
         
            -
                   
     | 
| 
       574 
     | 
    
         
            -
                   
     | 
| 
      
 571 
     | 
    
         
            +
                  debug "BACKTRACE"
         
     | 
| 
      
 572 
     | 
    
         
            +
                  debug e.backtrace
         
     | 
| 
      
 573 
     | 
    
         
            +
                  debug e.inspect
         
     | 
| 
      
 574 
     | 
    
         
            +
                  debug "BACKTRACE END"
         
     | 
| 
       575 
575 
     | 
    
         
             
                  if $!.class == SystemExit
         
     | 
| 
       576 
576 
     | 
    
         
             
                    exit
         
     | 
| 
       577 
577 
     | 
    
         
             
                  else
         
     | 
| 
         @@ -30,7 +30,7 @@ bindkey "C , t 4", :set_line_style_h4 
     | 
|
| 
       30 
30 
     | 
    
         
             
            bindkey "C , t b", :set_line_style_bold
         
     | 
| 
       31 
31 
     | 
    
         
             
            bindkey "C , t t", :set_line_style_title
         
     | 
| 
       32 
32 
     | 
    
         
             
            bindkey "C , t c", :clear_line_styles
         
     | 
| 
       33 
     | 
    
         
            -
            bindkey "C , b", : 
     | 
| 
      
 33 
     | 
    
         
            +
            bindkey "C , b", :start_buf_manager
         
     | 
| 
       34 
34 
     | 
    
         
             
            # bindkey "C , f o", :open_file_dialog
         
     | 
| 
       35 
35 
     | 
    
         
             
            bindkey "CI ctrl-o", :open_file_dialog
         
     | 
| 
       36 
36 
     | 
    
         
             
            # bindkey "M enter", :minibuffer_end
         
     | 
    
        data/lib/vimamsa/macro.rb
    CHANGED
    
    | 
         @@ -1,6 +1,6 @@ 
     | 
|
| 
       1 
1 
     | 
    
         | 
| 
       2 
2 
     | 
    
         
             
            def gui_find_macro_update_callback(search_str = "")
         
     | 
| 
       3 
     | 
    
         
            -
               
     | 
| 
      
 3 
     | 
    
         
            +
              debug "gui_find_macro_update_callback: #{search_str}"
         
     | 
| 
       4 
4 
     | 
    
         
             
              heystack = $macro.named_macros
         
     | 
| 
       5 
5 
     | 
    
         
             
              return [] if heystack.empty?
         
     | 
| 
       6 
6 
     | 
    
         
             
              $macro_search_list = []
         
     | 
| 
         @@ -14,10 +14,10 @@ def gui_find_macro_update_callback(search_str = "") 
     | 
|
| 
       14 
14 
     | 
    
         
             
            end
         
     | 
| 
       15 
15 
     | 
    
         | 
| 
       16 
16 
     | 
    
         
             
            def gui_find_macro_select_callback(search_str, idx)
         
     | 
| 
       17 
     | 
    
         
            -
               
     | 
| 
      
 17 
     | 
    
         
            +
              debug "gui_find_macro_select_callback"
         
     | 
| 
       18 
18 
     | 
    
         
             
              selected = $macro_search_list[idx]
         
     | 
| 
       19 
19 
     | 
    
         
             
              m = $macro.named_macros[selected[0]].clone
         
     | 
| 
       20 
     | 
    
         
            -
               
     | 
| 
      
 20 
     | 
    
         
            +
              debug "SELECTED MACRO:#{selected}, #{m}"
         
     | 
| 
       21 
21 
     | 
    
         
             
              id = $macro.last_macro
         
     | 
| 
       22 
22 
     | 
    
         
             
              $macro.recorded_macros[id] = m
         
     | 
| 
       23 
23 
     | 
    
         
             
              $macro.run_macro(id)
         
     | 
| 
         @@ -64,7 +64,7 @@ class Macro 
     | 
|
| 
       64 
64 
     | 
    
         
             
              end
         
     | 
| 
       65 
65 
     | 
    
         | 
| 
       66 
66 
     | 
    
         
             
              def name_macro(name, id = nil)
         
     | 
| 
       67 
     | 
    
         
            -
                 
     | 
| 
      
 67 
     | 
    
         
            +
                debug "NAME MACRO #{name}"
         
     | 
| 
       68 
68 
     | 
    
         
             
                if id.nil?
         
     | 
| 
       69 
69 
     | 
    
         
             
                  id = @last_macro
         
     | 
| 
       70 
70 
     | 
    
         
             
                end
         
     | 
| 
         @@ -134,7 +134,7 @@ class Macro 
     | 
|
| 
       134 
134 
     | 
    
         
             
                  # Ripl.start :binding => binding
         
     | 
| 
       135 
135 
     | 
    
         
             
                  for a in acts
         
     | 
| 
       136 
136 
     | 
    
         
             
                    ret = exec_action(a)
         
     | 
| 
       137 
     | 
    
         
            -
                     
     | 
| 
      
 137 
     | 
    
         
            +
                    debug ret
         
     | 
| 
       138 
138 
     | 
    
         
             
                    if ret == false
         
     | 
| 
       139 
139 
     | 
    
         
             
                      message("Error while running macro")
         
     | 
| 
       140 
140 
     | 
    
         
             
                      break
         
     | 
    
        data/lib/vimamsa/rbvma.rb
    CHANGED
    
    | 
         @@ -22,21 +22,22 @@ require "vimamsa/gui_menu" 
     | 
|
| 
       22 
22 
     | 
    
         
             
            require "vimamsa/gui_select_window"
         
     | 
| 
       23 
23 
     | 
    
         
             
            require "vimamsa/gui_sourceview"
         
     | 
| 
       24 
24 
     | 
    
         | 
| 
       25 
     | 
    
         
            -
            require "vimamsa/ 
     | 
| 
      
 25 
     | 
    
         
            +
            require "vimamsa/ack"
         
     | 
| 
       26 
26 
     | 
    
         
             
            require "vimamsa/buffer"
         
     | 
| 
       27 
     | 
    
         
            -
            require "vimamsa/ 
     | 
| 
      
 27 
     | 
    
         
            +
            require "vimamsa/buffer_list"
         
     | 
| 
      
 28 
     | 
    
         
            +
            require "vimamsa/buffer_manager"
         
     | 
| 
       28 
29 
     | 
    
         
             
            require "vimamsa/constants"
         
     | 
| 
      
 30 
     | 
    
         
            +
            require "vimamsa/debug"
         
     | 
| 
       29 
31 
     | 
    
         
             
            require "vimamsa/easy_jump"
         
     | 
| 
      
 32 
     | 
    
         
            +
            require "vimamsa/encrypt"
         
     | 
| 
      
 33 
     | 
    
         
            +
            require "vimamsa/file_finder"
         
     | 
| 
      
 34 
     | 
    
         
            +
            require "vimamsa/file_manager"
         
     | 
| 
       30 
35 
     | 
    
         
             
            require "vimamsa/hook"
         
     | 
| 
      
 36 
     | 
    
         
            +
            require "vimamsa/hyper_plain_text"
         
     | 
| 
      
 37 
     | 
    
         
            +
            require "vimamsa/macro"
         
     | 
| 
       31 
38 
     | 
    
         
             
            require "vimamsa/search"
         
     | 
| 
       32 
39 
     | 
    
         
             
            require "vimamsa/search_replace"
         
     | 
| 
       33 
     | 
    
         
            -
            require "vimamsa/ 
     | 
| 
       34 
     | 
    
         
            -
            require "vimamsa/file_finder"
         
     | 
| 
       35 
     | 
    
         
            -
            require "vimamsa/hyper_plain_text"
         
     | 
| 
       36 
     | 
    
         
            -
            require "vimamsa/ack"
         
     | 
| 
       37 
     | 
    
         
            -
            require "vimamsa/encrypt"
         
     | 
| 
       38 
     | 
    
         
            -
            require "vimamsa/file_manager"
         
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
      
 40 
     | 
    
         
            +
            require "vimamsa/conf"
         
     | 
| 
       40 
41 
     | 
    
         
             
            # load "vendor/ver/lib/ver/vendor/textpow.rb"
         
     | 
| 
       41 
42 
     | 
    
         
             
            # load "vendor/ver/lib/ver/syntax/detector.rb"
         
     | 
| 
       42 
43 
     | 
    
         
             
            # load "vendor/ver/config/detect.rb"
         
     | 
| 
         @@ -48,7 +49,7 @@ def vma() 
     | 
|
| 
       48 
49 
     | 
    
         
             
            end
         
     | 
| 
       49 
50 
     | 
    
         | 
| 
       50 
51 
     | 
    
         
             
            def unimplemented
         
     | 
| 
       51 
     | 
    
         
            -
               
     | 
| 
      
 52 
     | 
    
         
            +
              debug "unimplemented"
         
     | 
| 
       52 
53 
     | 
    
         
             
            end
         
     | 
| 
       53 
54 
     | 
    
         | 
| 
       54 
55 
     | 
    
         | 
    
        data/lib/vimamsa/search.rb
    CHANGED
    
    
| 
         @@ -50,7 +50,7 @@ class FileSelector 
     | 
|
| 
       50 
50 
     | 
    
         
             
                # puts "def select_line"
         
     | 
| 
       51 
51 
     | 
    
         
             
                fn = fullp(@buf.get_current_line[0..-2])
         
     | 
| 
       52 
52 
     | 
    
         
             
                if File.directory?(fn)
         
     | 
| 
       53 
     | 
    
         
            -
                   
     | 
| 
      
 53 
     | 
    
         
            +
                  debug "CHDIR: #{fn}"
         
     | 
| 
       54 
54 
     | 
    
         
             
                  dir_to_buf(fn)
         
     | 
| 
       55 
55 
     | 
    
         
             
                # elsif vma.can_open_extension?(fn) #TODO: remove this check?
         
     | 
| 
       56 
56 
     | 
    
         
             
                  # jump_to_file(fn)
         
     | 
| 
         @@ -59,7 +59,6 @@ class FileSelector 
     | 
|
| 
       59 
59 
     | 
    
         
             
                else
         
     | 
| 
       60 
60 
     | 
    
         
             
                  open_with_default_program(fn)
         
     | 
| 
       61 
61 
     | 
    
         
             
                end
         
     | 
| 
       62 
     | 
    
         
            -
                # puts l.inspect
         
     | 
| 
       63 
62 
     | 
    
         
             
              end
         
     | 
| 
       64 
63 
     | 
    
         
             
            end
         
     | 
| 
       65 
64 
     | 
    
         | 
| 
         @@ -91,7 +90,7 @@ def grep_cur_buffer(search_str, b = nil) 
     | 
|
| 
       91 
90 
     | 
    
         
             
              # @current_buf = buffer_i
         
     | 
| 
       92 
91 
     | 
    
         | 
| 
       93 
92 
     | 
    
         
             
              b.line_action_handler = proc { |lineno|
         
     | 
| 
       94 
     | 
    
         
            -
                 
     | 
| 
      
 93 
     | 
    
         
            +
                debug "GREP HANDLER:#{lineno}"
         
     | 
| 
       95 
94 
     | 
    
         
             
                jumpto = $grep_matches[lineno]
         
     | 
| 
       96 
95 
     | 
    
         
             
                if jumpto.class == Integer
         
     | 
| 
       97 
96 
     | 
    
         
             
                  $buffers.set_current_buffer($grep_bufid, update_history = true)
         
     | 
| 
         @@ -114,7 +113,7 @@ end 
     | 
|
| 
       114 
113 
     | 
    
         
             
            def gui_replace_callback(vals)
         
     | 
| 
       115 
114 
     | 
    
         
             
              search_str = vals["search"]
         
     | 
| 
       116 
115 
     | 
    
         
             
              replace_str = vals["replace"]
         
     | 
| 
       117 
     | 
    
         
            -
               
     | 
| 
      
 116 
     | 
    
         
            +
              debug "gui_replace_callback: #{search_str} => #{replace_str}"
         
     | 
| 
       118 
117 
     | 
    
         
             
              gui_select_window_close(0)
         
     | 
| 
       119 
118 
     | 
    
         
             
              buf_replace(search_str, replace_str)
         
     | 
| 
       120 
119 
     | 
    
         
             
            end
         
     | 
    
        data/lib/vimamsa/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: vimamsa
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.1.8
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Sami Sieranoja
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: exe
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2022- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2022-05-03 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: bundler
         
     | 
| 
         @@ -190,6 +190,8 @@ files: 
     | 
|
| 
       190 
190 
     | 
    
         
             
            - lib/vimamsa/actions.rb
         
     | 
| 
       191 
191 
     | 
    
         
             
            - lib/vimamsa/buffer.rb
         
     | 
| 
       192 
192 
     | 
    
         
             
            - lib/vimamsa/buffer_list.rb
         
     | 
| 
      
 193 
     | 
    
         
            +
            - lib/vimamsa/buffer_manager.rb
         
     | 
| 
      
 194 
     | 
    
         
            +
            - lib/vimamsa/conf.rb
         
     | 
| 
       193 
195 
     | 
    
         
             
            - lib/vimamsa/constants.rb
         
     | 
| 
       194 
196 
     | 
    
         
             
            - lib/vimamsa/debug.rb
         
     | 
| 
       195 
197 
     | 
    
         
             
            - lib/vimamsa/easy_jump.rb
         
     | 
| 
         @@ -199,7 +201,6 @@ files: 
     | 
|
| 
       199 
201 
     | 
    
         
             
            - lib/vimamsa/file_history.rb
         
     | 
| 
       200 
202 
     | 
    
         
             
            - lib/vimamsa/file_manager.rb
         
     | 
| 
       201 
203 
     | 
    
         
             
            - lib/vimamsa/gui.rb
         
     | 
| 
       202 
     | 
    
         
            -
            - lib/vimamsa/gui_gtk_sourceview.rb
         
     | 
| 
       203 
204 
     | 
    
         
             
            - lib/vimamsa/gui_menu.rb
         
     | 
| 
       204 
205 
     | 
    
         
             
            - lib/vimamsa/gui_select_window.rb
         
     | 
| 
       205 
206 
     | 
    
         
             
            - lib/vimamsa/gui_sourceview.rb
         
     | 
| 
         @@ -1,294 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
       2 
     | 
    
         
            -
            class VSourceView < GtkSource::View
         
     | 
| 
       3 
     | 
    
         
            -
              def initialize(title = nil)
         
     | 
| 
       4 
     | 
    
         
            -
                # super(:toplevel)
         
     | 
| 
       5 
     | 
    
         
            -
                super()
         
     | 
| 
       6 
     | 
    
         
            -
                puts "vsource init"
         
     | 
| 
       7 
     | 
    
         
            -
                @last_keyval = nil
         
     | 
| 
       8 
     | 
    
         
            -
                @last_event = [nil, nil]
         
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
                signal_connect "button-press-event" do |_widget, event|
         
     | 
| 
       11 
     | 
    
         
            -
                  if event.button == Gdk::BUTTON_PRIMARY
         
     | 
| 
       12 
     | 
    
         
            -
                    # puts "Gdk::BUTTON_PRIMARY"
         
     | 
| 
       13 
     | 
    
         
            -
                    false
         
     | 
| 
       14 
     | 
    
         
            -
                  elsif event.button == Gdk::BUTTON_SECONDARY
         
     | 
| 
       15 
     | 
    
         
            -
                    # puts "Gdk::BUTTON_SECONDARY"
         
     | 
| 
       16 
     | 
    
         
            -
                    true
         
     | 
| 
       17 
     | 
    
         
            -
                  else
         
     | 
| 
       18 
     | 
    
         
            -
                    true
         
     | 
| 
       19 
     | 
    
         
            -
                  end
         
     | 
| 
       20 
     | 
    
         
            -
                end
         
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
                signal_connect("key_press_event") do |widget, event|
         
     | 
| 
       23 
     | 
    
         
            -
                  handle_key_event(event, :key_press_event)
         
     | 
| 
       24 
     | 
    
         
            -
                  true
         
     | 
| 
       25 
     | 
    
         
            -
                end
         
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
                signal_connect("key_release_event") do |widget, event|
         
     | 
| 
       28 
     | 
    
         
            -
                  handle_key_event(event, :key_release_event)
         
     | 
| 
       29 
     | 
    
         
            -
                  true
         
     | 
| 
       30 
     | 
    
         
            -
                end
         
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
                signal_connect("move-cursor") do |widget, event|
         
     | 
| 
       33 
     | 
    
         
            -
                  $update_cursor = true
         
     | 
| 
       34 
     | 
    
         
            -
                  false
         
     | 
| 
       35 
     | 
    
         
            -
                end
         
     | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
     | 
    
         
            -
                signal_connect "button-release-event" do |widget, event|
         
     | 
| 
       38 
     | 
    
         
            -
                  $buffer.set_pos(buffer.cursor_position)
         
     | 
| 
       39 
     | 
    
         
            -
                  false
         
     | 
| 
       40 
     | 
    
         
            -
                end
         
     | 
| 
       41 
     | 
    
         
            -
                @curpos_mark = nil
         
     | 
| 
       42 
     | 
    
         
            -
              end
         
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
       44 
     | 
    
         
            -
              def handle_key_event(event, sig)
         
     | 
| 
       45 
     | 
    
         
            -
                if $update_cursor
         
     | 
| 
       46 
     | 
    
         
            -
                  curpos = buffer.cursor_position
         
     | 
| 
       47 
     | 
    
         
            -
                  puts "MOVE CURSOR: #{curpos}"
         
     | 
| 
       48 
     | 
    
         
            -
                  buf.set_pos(curpos)
         
     | 
| 
       49 
     | 
    
         
            -
                  $update_cursor = false
         
     | 
| 
       50 
     | 
    
         
            -
                end
         
     | 
| 
       51 
     | 
    
         
            -
                puts $view.visible_rect.inspect
         
     | 
| 
       52 
     | 
    
         
            -
             
     | 
| 
       53 
     | 
    
         
            -
                puts "key event"
         
     | 
| 
       54 
     | 
    
         
            -
                puts event
         
     | 
| 
       55 
     | 
    
         
            -
             
     | 
| 
       56 
     | 
    
         
            -
                key_name = event.string
         
     | 
| 
       57 
     | 
    
         
            -
                if event.state.control_mask?
         
     | 
| 
       58 
     | 
    
         
            -
                  key_name = Gdk::Keyval.to_name(event.keyval)
         
     | 
| 
       59 
     | 
    
         
            -
                  # Gdk::Keyval.to_name()
         
     | 
| 
       60 
     | 
    
         
            -
                end
         
     | 
| 
       61 
     | 
    
         
            -
             
     | 
| 
       62 
     | 
    
         
            -
                keyval_trans = {}
         
     | 
| 
       63 
     | 
    
         
            -
                keyval_trans[Gdk::Keyval::KEY_Control_L] = "ctrl"
         
     | 
| 
       64 
     | 
    
         
            -
                keyval_trans[Gdk::Keyval::KEY_Control_R] = "ctrl"
         
     | 
| 
       65 
     | 
    
         
            -
             
     | 
| 
       66 
     | 
    
         
            -
                keyval_trans[Gdk::Keyval::KEY_Escape] = "esc"
         
     | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
       68 
     | 
    
         
            -
                keyval_trans[Gdk::Keyval::KEY_Return] = "enter"
         
     | 
| 
       69 
     | 
    
         
            -
                keyval_trans[Gdk::Keyval::KEY_ISO_Enter] = "enter"
         
     | 
| 
       70 
     | 
    
         
            -
                keyval_trans[Gdk::Keyval::KEY_KP_Enter] = "enter"
         
     | 
| 
       71 
     | 
    
         
            -
                keyval_trans[Gdk::Keyval::KEY_Alt_L] = "alt"
         
     | 
| 
       72 
     | 
    
         
            -
                keyval_trans[Gdk::Keyval::KEY_Alt_R] = "alt"
         
     | 
| 
       73 
     | 
    
         
            -
             
     | 
| 
       74 
     | 
    
         
            -
                keyval_trans[Gdk::Keyval::KEY_BackSpace] = "backspace"
         
     | 
| 
       75 
     | 
    
         
            -
                keyval_trans[Gdk::Keyval::KEY_KP_Page_Down] = "pagedown"
         
     | 
| 
       76 
     | 
    
         
            -
                keyval_trans[Gdk::Keyval::KEY_KP_Page_Up] = "pageup"
         
     | 
| 
       77 
     | 
    
         
            -
                keyval_trans[Gdk::Keyval::KEY_Page_Down] = "pagedown"
         
     | 
| 
       78 
     | 
    
         
            -
                keyval_trans[Gdk::Keyval::KEY_Page_Up] = "pageup"
         
     | 
| 
       79 
     | 
    
         
            -
                keyval_trans[Gdk::Keyval::KEY_Left] = "left"
         
     | 
| 
       80 
     | 
    
         
            -
                keyval_trans[Gdk::Keyval::KEY_Right] = "right"
         
     | 
| 
       81 
     | 
    
         
            -
                keyval_trans[Gdk::Keyval::KEY_Down] = "down"
         
     | 
| 
       82 
     | 
    
         
            -
                keyval_trans[Gdk::Keyval::KEY_Up] = "up"
         
     | 
| 
       83 
     | 
    
         
            -
                keyval_trans[Gdk::Keyval::KEY_space] = "space"
         
     | 
| 
       84 
     | 
    
         
            -
             
     | 
| 
       85 
     | 
    
         
            -
                keyval_trans[Gdk::Keyval::KEY_Shift_L] = "shift"
         
     | 
| 
       86 
     | 
    
         
            -
                keyval_trans[Gdk::Keyval::KEY_Shift_R] = "shift"
         
     | 
| 
       87 
     | 
    
         
            -
                keyval_trans[Gdk::Keyval::KEY_Tab] = "tab"
         
     | 
| 
       88 
     | 
    
         
            -
             
     | 
| 
       89 
     | 
    
         
            -
                key_trans = {}
         
     | 
| 
       90 
     | 
    
         
            -
                key_trans["\e"] = "esc"
         
     | 
| 
       91 
     | 
    
         
            -
                tk = keyval_trans[event.keyval]
         
     | 
| 
       92 
     | 
    
         
            -
                key_name = tk if !tk.nil?
         
     | 
| 
       93 
     | 
    
         
            -
             
     | 
| 
       94 
     | 
    
         
            -
                key_str_parts = []
         
     | 
| 
       95 
     | 
    
         
            -
                key_str_parts << "ctrl" if event.state.control_mask? and key_name != "ctrl"
         
     | 
| 
       96 
     | 
    
         
            -
                key_str_parts << "alt" if event.state.mod1_mask? and key_name != "alt"
         
     | 
| 
       97 
     | 
    
         
            -
             
     | 
| 
       98 
     | 
    
         
            -
                key_str_parts << key_name
         
     | 
| 
       99 
     | 
    
         
            -
                key_str = key_str_parts.join("-")
         
     | 
| 
       100 
     | 
    
         
            -
                keynfo = { :key_str => key_str, :key_name => key_name, :keyval => event.keyval }
         
     | 
| 
       101 
     | 
    
         
            -
                puts keynfo.inspect
         
     | 
| 
       102 
     | 
    
         
            -
                # $kbd.match_key_conf(key_str, nil, :key_press)
         
     | 
| 
       103 
     | 
    
         
            -
                # puts "key_str=#{key_str} key_"
         
     | 
| 
       104 
     | 
    
         
            -
             
     | 
| 
       105 
     | 
    
         
            -
                if key_str != "" # or prefixed_key_str != ""
         
     | 
| 
       106 
     | 
    
         
            -
                  if sig == :key_release_event and event.keyval == @last_keyval
         
     | 
| 
       107 
     | 
    
         
            -
                    $kbd.match_key_conf(key_str + "!", nil, :key_release)
         
     | 
| 
       108 
     | 
    
         
            -
                    @last_event = [event, :key_release]
         
     | 
| 
       109 
     | 
    
         
            -
                  elsif sig == :key_press_event
         
     | 
| 
       110 
     | 
    
         
            -
                    $kbd.match_key_conf(key_str, nil, :key_press)
         
     | 
| 
       111 
     | 
    
         
            -
                    @last_event = [event, key_str, :key_press]
         
     | 
| 
       112 
     | 
    
         
            -
                  end
         
     | 
| 
       113 
     | 
    
         
            -
                  @last_keyval = event.keyval #TODO: outside if?
         
     | 
| 
       114 
     | 
    
         
            -
                end
         
     | 
| 
       115 
     | 
    
         
            -
             
     | 
| 
       116 
     | 
    
         
            -
                handle_deltas
         
     | 
| 
       117 
     | 
    
         
            -
             
     | 
| 
       118 
     | 
    
         
            -
                # set_focus(5)
         
     | 
| 
       119 
     | 
    
         
            -
                # false
         
     | 
| 
       120 
     | 
    
         
            -
             
     | 
| 
       121 
     | 
    
         
            -
              end
         
     | 
| 
       122 
     | 
    
         
            -
             
     | 
| 
       123 
     | 
    
         
            -
              def pos_to_coord(i)
         
     | 
| 
       124 
     | 
    
         
            -
                b = buffer
         
     | 
| 
       125 
     | 
    
         
            -
                iter = b.get_iter_at(:offset => i)
         
     | 
| 
       126 
     | 
    
         
            -
                iterxy = get_iter_location(iter)
         
     | 
| 
       127 
     | 
    
         
            -
                winw = parent_window.width
         
     | 
| 
       128 
     | 
    
         
            -
                view_width = visible_rect.width
         
     | 
| 
       129 
     | 
    
         
            -
                gutter_width = winw - view_width
         
     | 
| 
       130 
     | 
    
         
            -
             
     | 
| 
       131 
     | 
    
         
            -
                x = iterxy.x + gutter_width
         
     | 
| 
       132 
     | 
    
         
            -
                y = iterxy.y
         
     | 
| 
       133 
     | 
    
         
            -
             
     | 
| 
       134 
     | 
    
         
            -
                # buffer_to_window_coords(Gtk::TextWindowType::TEXT, iterxy.x, iterxy.y).inspect
         
     | 
| 
       135 
     | 
    
         
            -
                # puts buffer_to_window_coords(Gtk::TextWindowType::TEXT, x, y).inspect
         
     | 
| 
       136 
     | 
    
         
            -
                (x, y) = buffer_to_window_coords(Gtk::TextWindowType::TEXT, x, y)
         
     | 
| 
       137 
     | 
    
         
            -
                # Ripl.start :binding => binding
         
     | 
| 
       138 
     | 
    
         
            -
             
     | 
| 
       139 
     | 
    
         
            -
                return [x, y]
         
     | 
| 
       140 
     | 
    
         
            -
              end
         
     | 
| 
       141 
     | 
    
         
            -
             
     | 
| 
       142 
     | 
    
         
            -
              def handle_deltas()
         
     | 
| 
       143 
     | 
    
         
            -
                any_change = false
         
     | 
| 
       144 
     | 
    
         
            -
                while d = buf.deltas.shift
         
     | 
| 
       145 
     | 
    
         
            -
                  any_change = true
         
     | 
| 
       146 
     | 
    
         
            -
                  pos = d[0]
         
     | 
| 
       147 
     | 
    
         
            -
                  op = d[1]
         
     | 
| 
       148 
     | 
    
         
            -
                  num = d[2]
         
     | 
| 
       149 
     | 
    
         
            -
                  txt = d[3]
         
     | 
| 
       150 
     | 
    
         
            -
                  if op == DELETE
         
     | 
| 
       151 
     | 
    
         
            -
                    startiter = buffer.get_iter_at(:offset => pos)
         
     | 
| 
       152 
     | 
    
         
            -
                    enditer = buffer.get_iter_at(:offset => pos + num)
         
     | 
| 
       153 
     | 
    
         
            -
                    buffer.delete(startiter, enditer)
         
     | 
| 
       154 
     | 
    
         
            -
                  elsif op == INSERT
         
     | 
| 
       155 
     | 
    
         
            -
                    startiter = buffer.get_iter_at(:offset => pos)
         
     | 
| 
       156 
     | 
    
         
            -
                    buffer.insert(startiter, txt)
         
     | 
| 
       157 
     | 
    
         
            -
                  end
         
     | 
| 
       158 
     | 
    
         
            -
                end
         
     | 
| 
       159 
     | 
    
         
            -
                if any_change
         
     | 
| 
       160 
     | 
    
         
            -
                  gui_set_cursor_pos($buffer.id, $buffer.pos) #TODO: only when necessary
         
     | 
| 
       161 
     | 
    
         
            -
                end
         
     | 
| 
       162 
     | 
    
         
            -
             
     | 
| 
       163 
     | 
    
         
            -
                # sanity_check #TODO
         
     | 
| 
       164 
     | 
    
         
            -
              end
         
     | 
| 
       165 
     | 
    
         
            -
             
     | 
| 
       166 
     | 
    
         
            -
              def sanity_check()
         
     | 
| 
       167 
     | 
    
         
            -
                a = buffer.text
         
     | 
| 
       168 
     | 
    
         
            -
                b = buf.to_s
         
     | 
| 
       169 
     | 
    
         
            -
                # puts "===================="
         
     | 
| 
       170 
     | 
    
         
            -
                # puts a.lines[0..10].join()
         
     | 
| 
       171 
     | 
    
         
            -
                # puts "===================="
         
     | 
| 
       172 
     | 
    
         
            -
                # puts b.lines[0..10].join()
         
     | 
| 
       173 
     | 
    
         
            -
                # puts "===================="
         
     | 
| 
       174 
     | 
    
         
            -
                if a == b
         
     | 
| 
       175 
     | 
    
         
            -
                  puts "Buffers match"
         
     | 
| 
       176 
     | 
    
         
            -
                else
         
     | 
| 
       177 
     | 
    
         
            -
                  puts "ERROR: Buffer's don't match."
         
     | 
| 
       178 
     | 
    
         
            -
                end
         
     | 
| 
       179 
     | 
    
         
            -
              end
         
     | 
| 
       180 
     | 
    
         
            -
             
     | 
| 
       181 
     | 
    
         
            -
              def set_cursor_pos(pos)
         
     | 
| 
       182 
     | 
    
         
            -
                # return
         
     | 
| 
       183 
     | 
    
         
            -
                itr = buffer.get_iter_at(:offset => pos)
         
     | 
| 
       184 
     | 
    
         
            -
                itr2 = buffer.get_iter_at(:offset => pos + 1)
         
     | 
| 
       185 
     | 
    
         
            -
                buffer.place_cursor(itr)
         
     | 
| 
       186 
     | 
    
         
            -
             
     | 
| 
       187 
     | 
    
         
            -
                # $view.signal_emit("extend-selection", Gtk::MovementStep.new(:PAGES), -1, false)
         
     | 
| 
       188 
     | 
    
         
            -
             
     | 
| 
       189 
     | 
    
         
            -
                within_margin = 0.075 #margin as a [0.0,0.5) fraction of screen size
         
     | 
| 
       190 
     | 
    
         
            -
                use_align = false
         
     | 
| 
       191 
     | 
    
         
            -
                xalign = 0.5 #0.0=top 1.0=bottom, 0.5=center
         
     | 
| 
       192 
     | 
    
         
            -
                yalign = 0.5
         
     | 
| 
       193 
     | 
    
         
            -
             
     | 
| 
       194 
     | 
    
         
            -
                if @curpos_mark.nil?
         
     | 
| 
       195 
     | 
    
         
            -
                  @curpos_mark = buffer.create_mark("cursor", itr, false)
         
     | 
| 
       196 
     | 
    
         
            -
                else
         
     | 
| 
       197 
     | 
    
         
            -
                  buffer.move_mark(@curpos_mark, itr)
         
     | 
| 
       198 
     | 
    
         
            -
                end
         
     | 
| 
       199 
     | 
    
         
            -
                scroll_to_mark(@curpos_mark, within_margin, use_align, xalign, yalign)
         
     | 
| 
       200 
     | 
    
         
            -
                $idle_scroll_to_mark = true
         
     | 
| 
       201 
     | 
    
         
            -
                ensure_cursor_visible
         
     | 
| 
       202 
     | 
    
         
            -
             
     | 
| 
       203 
     | 
    
         
            -
                # scroll_to_iter(itr, within_margin, use_align, xalign, yalign)
         
     | 
| 
       204 
     | 
    
         
            -
             
     | 
| 
       205 
     | 
    
         
            -
                # $view.signal_emit("extend-selection", Gtk::TextExtendSelection.new, itr,itr,itr2)
         
     | 
| 
       206 
     | 
    
         
            -
                # Ripl.start :binding => binding
         
     | 
| 
       207 
     | 
    
         
            -
                draw_cursor
         
     | 
| 
       208 
     | 
    
         
            -
             
     | 
| 
       209 
     | 
    
         
            -
                return true
         
     | 
| 
       210 
     | 
    
         
            -
              end
         
     | 
| 
       211 
     | 
    
         
            -
             
     | 
| 
       212 
     | 
    
         
            -
              def cursor_visible_idle_func
         
     | 
| 
       213 
     | 
    
         
            -
                puts "cursor_visible_idle_func"
         
     | 
| 
       214 
     | 
    
         
            -
                # From https://picheta.me/articles/2013/08/gtk-plus--a-method-to-guarantee-scrolling.html
         
     | 
| 
       215 
     | 
    
         
            -
                # vr = visible_rect
         
     | 
| 
       216 
     | 
    
         
            -
             
     | 
| 
       217 
     | 
    
         
            -
                # b = $view.buffer
         
     | 
| 
       218 
     | 
    
         
            -
                # iter = buffer.get_iter_at(:offset => buffer.cursor_position)
         
     | 
| 
       219 
     | 
    
         
            -
                # iterxy = get_iter_location(iter)
         
     | 
| 
       220 
     | 
    
         
            -
             
     | 
| 
       221 
     | 
    
         
            -
                sleep(0.01)
         
     | 
| 
       222 
     | 
    
         
            -
                # intr = iterxy.intersect(vr)
         
     | 
| 
       223 
     | 
    
         
            -
                if is_cursor_visible == false
         
     | 
| 
       224 
     | 
    
         
            -
                  # set_cursor_pos(buffer.cursor_position)
         
     | 
| 
       225 
     | 
    
         
            -
             
     | 
| 
       226 
     | 
    
         
            -
                  itr = buffer.get_iter_at(:offset => buffer.cursor_position)
         
     | 
| 
       227 
     | 
    
         
            -
             
     | 
| 
       228 
     | 
    
         
            -
                  within_margin = 0.075 #margin as a [0.0,0.5) fraction of screen size
         
     | 
| 
       229 
     | 
    
         
            -
                  use_align = false
         
     | 
| 
       230 
     | 
    
         
            -
                  xalign = 0.5 #0.0=top 1.0=bottom, 0.5=center
         
     | 
| 
       231 
     | 
    
         
            -
                  yalign = 0.5
         
     | 
| 
       232 
     | 
    
         
            -
             
     | 
| 
       233 
     | 
    
         
            -
                  scroll_to_iter(itr, within_margin, use_align, xalign, yalign)
         
     | 
| 
       234 
     | 
    
         
            -
             
     | 
| 
       235 
     | 
    
         
            -
                  # return true # Call this func again
         
     | 
| 
       236 
     | 
    
         
            -
                else
         
     | 
| 
       237 
     | 
    
         
            -
                  return false # Don't call this idle func again
         
     | 
| 
       238 
     | 
    
         
            -
                end
         
     | 
| 
       239 
     | 
    
         
            -
              end
         
     | 
| 
       240 
     | 
    
         
            -
             
     | 
| 
       241 
     | 
    
         
            -
              def is_cursor_visible
         
     | 
| 
       242 
     | 
    
         
            -
                vr = visible_rect
         
     | 
| 
       243 
     | 
    
         
            -
                iter = buffer.get_iter_at(:offset => buffer.cursor_position)
         
     | 
| 
       244 
     | 
    
         
            -
                iterxy = get_iter_location(iter)
         
     | 
| 
       245 
     | 
    
         
            -
                iterxy.width = 1 if iterxy.width == 0
         
     | 
| 
       246 
     | 
    
         
            -
                iterxy.height = 1 if iterxy.height == 0
         
     | 
| 
       247 
     | 
    
         
            -
             
     | 
| 
       248 
     | 
    
         
            -
                intr = iterxy.intersect(vr)
         
     | 
| 
       249 
     | 
    
         
            -
                if intr.nil?
         
     | 
| 
       250 
     | 
    
         
            -
                  puts iterxy.inspect
         
     | 
| 
       251 
     | 
    
         
            -
                  puts vr.inspect
         
     | 
| 
       252 
     | 
    
         
            -
                  # Ripl.start :binding => binding
         
     | 
| 
       253 
     | 
    
         
            -
             
     | 
| 
       254 
     | 
    
         
            -
                  # exit!
         
     | 
| 
       255 
     | 
    
         
            -
                  return false
         
     | 
| 
       256 
     | 
    
         
            -
                else
         
     | 
| 
       257 
     | 
    
         
            -
                  return true
         
     | 
| 
       258 
     | 
    
         
            -
                end
         
     | 
| 
       259 
     | 
    
         
            -
              end
         
     | 
| 
       260 
     | 
    
         
            -
             
     | 
| 
       261 
     | 
    
         
            -
              def ensure_cursor_visible
         
     | 
| 
       262 
     | 
    
         
            -
                if is_cursor_visible == false
         
     | 
| 
       263 
     | 
    
         
            -
                  Thread.new {
         
     | 
| 
       264 
     | 
    
         
            -
                    sleep 0.01
         
     | 
| 
       265 
     | 
    
         
            -
                    GLib::Idle.add(proc { cursor_visible_idle_func })
         
     | 
| 
       266 
     | 
    
         
            -
                  }
         
     | 
| 
       267 
     | 
    
         
            -
                end
         
     | 
| 
       268 
     | 
    
         
            -
              end
         
     | 
| 
       269 
     | 
    
         
            -
             
     | 
| 
       270 
     | 
    
         
            -
              def draw_cursor
         
     | 
| 
       271 
     | 
    
         
            -
                if is_command_mode
         
     | 
| 
       272 
     | 
    
         
            -
                  itr = buffer.get_iter_at(:offset => buf.pos)
         
     | 
| 
       273 
     | 
    
         
            -
                  itr2 = buffer.get_iter_at(:offset => buf.pos + 1)
         
     | 
| 
       274 
     | 
    
         
            -
                  $view.buffer.select_range(itr, itr2)
         
     | 
| 
       275 
     | 
    
         
            -
                elsif buf.visual_mode?
         
     | 
| 
       276 
     | 
    
         
            -
                  puts "VISUAL MODE"
         
     | 
| 
       277 
     | 
    
         
            -
                  (_start, _end) = buf.get_visual_mode_range2
         
     | 
| 
       278 
     | 
    
         
            -
                  puts "#{_start}, #{_end}"
         
     | 
| 
       279 
     | 
    
         
            -
                  itr = buffer.get_iter_at(:offset => _start)
         
     | 
| 
       280 
     | 
    
         
            -
                  itr2 = buffer.get_iter_at(:offset => _end + 1)
         
     | 
| 
       281 
     | 
    
         
            -
                  $view.buffer.select_range(itr, itr2)
         
     | 
| 
       282 
     | 
    
         
            -
                else # Insert mode
         
     | 
| 
       283 
     | 
    
         
            -
                  itr = buffer.get_iter_at(:offset => buf.pos)
         
     | 
| 
       284 
     | 
    
         
            -
                  $view.buffer.select_range(itr, itr)
         
     | 
| 
       285 
     | 
    
         
            -
                  puts "INSERT MODE"
         
     | 
| 
       286 
     | 
    
         
            -
                end
         
     | 
| 
       287 
     | 
    
         
            -
              end
         
     | 
| 
       288 
     | 
    
         
            -
             
     | 
| 
       289 
     | 
    
         
            -
              # def quit
         
     | 
| 
       290 
     | 
    
         
            -
              # destroy
         
     | 
| 
       291 
     | 
    
         
            -
              # true
         
     | 
| 
       292 
     | 
    
         
            -
              # end
         
     | 
| 
       293 
     | 
    
         
            -
            end
         
     | 
| 
       294 
     | 
    
         
            -
             
     |