Class: Vimamsa::Menu
- Inherits:
-
Object
- Object
- Vimamsa::Menu
- Defined in:
- lib/vimamsa/gui_menu.rb
Instance Method Summary collapse
- #add_menu_items ⇒ Object
- #add_to_menu(_mpath, x) ⇒ Object
- #build_menu(nfo, parent) ⇒ Object
-
#initialize(menubar) ⇒ Menu
constructor
A new instance of Menu.
Constructor Details
#initialize(menubar) ⇒ Menu
Returns a new instance of Menu.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/vimamsa/gui_menu.rb', line 58 def initialize() # nfo["file"] = { :items => {}, :label => "File" } # nfo["actions"] = { :items => {}, :label => "Actions" } # nfo["help"] = { :items => {}, :label => "Help" } @nfo = {} # add_to_menu("help.extra.keybindings", { :label => "Show keybindings" }) # add_to_menu("help.extra.nfo.keybindings", { :label => "Show keybindings" }) # add_to_menu("help.keybindings", { :label => "Show keybindings <span foreground='#888888' >C ? k</span>" }) #font='12' weight='ultrabold' for k, v in @nfo (v, ) end end |
Instance Method Details
#add_menu_items ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/vimamsa/gui_menu.rb', line 18 def () "File.Example", { :label => "<span foreground='#888888'>Action, [mode] key binding</span>", :action => nil } "File.Save", { :label => "Save", :action => :buf_save } "File.Save as", { :label => "Save As...", :action => :buf_save_as } "File.Open", { :label => "Open", :action => :open_file_dialog } "File.New", { :label => "New file", :action => :buf_new } "File.Revert", { :label => "Reload file from disk", :action => :buf_revert } "File.List", { :label => "List open files", :action => :start_buf_manager } "File.Quit", { :label => "Quit", :action => :quit } "Edit.Undo", { :label => "Undo edit", :action => :edit_undo } "Edit.Redo", { :label => "Redo edit", :action => :edit_redo } "Edit.SearchReplace", { :label => "Search and replace", :action => :gui_search_replace } "Edit.Find", { :label => "Find", :action => :find_in_buffer } "Actions.SearchForActions", { :label => "Search for Actions", :action => :search_actions } "Actions.Grep", { :label => "Grep lines", :action => :invoke_grep_search } "Actions.FileHistoryFinder", { :label => "Search files in history", :action => :gui_file_history_finder } "Actions.experimental.Diff", { :label => "Show Diff of\nunsaved changes", :action => :diff_buffer } "Actions.experimental.EnableDebug", { :label => "Enable debug", :action => :enable_debug } "Actions.experimental.DisableDebug", { :label => "Disable debug", :action => :disable_debug } "Actions.experimental.ShowImages", { :label => "Show images ⟦img:path⟧", :action => :show_images } "Actions.EncryptFile", { :label => "Encrypt file", :action => :encrypt_file } "Help.KeyBindings", { :label => "Show key bindings", :action => :show_key_bindings } #TODO: :auto_indent_buffer # add_to_menu "Actions.Ack", { :label => "source code search (Ack)", :action => :ack_search } end |
#add_to_menu(_mpath, x) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/vimamsa/gui_menu.rb', line 3 def (_mpath, x) mpath = _mpath.split(".") curnfo = @nfo for y in mpath debug(curnfo.inspect) if y.equal?(mpath.last) curnfo[y] = x elsif curnfo[y].nil? curnfo[y] = { :label => y, :items => {} } end curnfo[y][:items] = {} if curnfo[y][:items].class != Hash curnfo = curnfo[y][:items] end #end for end |
#build_menu(nfo, parent) ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/vimamsa/gui_menu.rb', line 76 def (nfo, parent) = Gtk::Menu.new if nfo[:action] kbd_str = "" for mode_str in ["C", "V"] c_kbd = vma.kbd.act_bindings[mode_str][nfo[:action]] if c_kbd.class == String kbd_str = " <span foreground='#888888'><span weight='bold'>[#{mode_str}]</span> #{c_kbd}</span>" break end end label_str = nfo[:label] + kbd_str = Gtk::MenuItem.new(:label => label_str) .children[0].set_markup(label_str) .signal_connect("activate") do call_action(nfo[:action]) end else = Gtk::MenuItem.new(:label => nfo[:label]) .children[0].set_markup(nfo[:label]) end if !nfo[:items].nil? and !nfo[:items].empty? for k2, item in nfo[:items] (item, ) end . = end parent.append() end |