Module: Gui
- Defined in:
- lib/vimamsa/gui_text.rb,
lib/vimamsa/gui_dialog.rb
Class Method Summary collapse
- .confirm(title, callback, param: nil) ⇒ Object
- .highlight_match(bf, str, color: "#aa0000ff", weight: 650) ⇒ Object
- .hilight_range(bf, r, color: "#aa0000ff", weight: nil, tag: nil) ⇒ Object
Class Method Details
.confirm(title, callback, param: nil) ⇒ Object
2 3 4 5 6 7 8 9 |
# File 'lib/vimamsa/gui_dialog.rb', line 2 def self.confirm(title, callback, param: nil) params = {} params["title"] = title params["inputs"] = {} params["inputs"]["yes_btn"] = { :label => "Yes", :type => :button, :default_focus => true } params[:callback] = callback PopupFormGenerator.new(params).run end |
.highlight_match(bf, str, color: "#aa0000ff", weight: 650) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/vimamsa/gui_text.rb', line 16 def self.highlight_match(bf, str, color: "#aa0000ff", weight: 650) r = Regexp.new(Regexp.escape(str), Regexp::IGNORECASE) tag = vma.gui.view.buffer.create_tag tag.weight = weight tag.foreground = color ind = scan_indexes(bf, r) ind.each { |x| r = x..(x + str.size) self.hilight_range(bf, r, tag: tag) } end |
.hilight_range(bf, r, color: "#aa0000ff", weight: nil, tag: nil) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/vimamsa/gui_text.rb', line 2 def self.hilight_range(bf, r, color: "#aa0000ff", weight: nil, tag: nil) vbuf = bf.view.buffer if tag.nil? tag = vma.gui.view.buffer.create_tag tag.weight = weight if !weight.nil? tag.foreground = color end itr = vbuf.get_iter_at(:offset => r.begin) itr2 = vbuf.get_iter_at(:offset => r.last) vbuf.apply_tag(tag, itr, itr2) end |