Module: Tkri::DefaultSettings
- Defined in:
- lib/tkri.rb
Constant Summary collapse
- COMMAND =
{ # Each platform may use a different command. The commands are indexed by any # substring in RUBY_PLATFORM. If none matches the platform, the '__default__' key # is used. '__default__' => 'qri -f ansi "%s"', # The "2>&1" thingy tells UNIX shells to print any error messages to the standard output. # This makes it possible to see, inside Tkri, the errors `qri' (or 'ri') happens to emmit # (this happens seldom, due to bugs in `qri', so it's not a very critical feature). 'linux' => 'qri -f ansi "%s" 2>&1', 'darwin' => 'qri -f ansi "%s" 2>&1', # And here's the command for MS-Windows. # It turns out Windows' CMD.EXE too supports "2>&1". This shell is used on NT-based # systems. (In other words, if you're using the good old Windows 98, you'll have to remove # this "2>&1"). 'mswin' => 'qri.bat -f ansi "%s" 2>&1', }
- VISUALS =
{ # The '__base__' attibutes are applied for every textfield and textarea. # Set the background color and font to whatever you like. # # Font families are designated by an ordered array of names. The first # found on the system will be used. So make sure to put a generic family # name (i.e., one of: 'courier', 'times', 'helvetica') at the end to serve # as a fallback. '__base__' => { :background => '#ffeeff', :font => { :family => ['Bitstream Vera Sans Mono', 'Menlo', 'Monaco', 'Courier'], :size => 10 } }, 'bold' => { :foreground => 'blue', :is_tag => true }, 'italic' => { :foreground => '#6b8e23', :is_tag => true }, # greenish 'code' => { :foreground => '#1874cd', :is_tag => true }, # blueish 'header2' => { :background => '#ffe4b5', :font => { :family => ['Geneva', 'Arial', 'Helvetica'], :size => 12 }, :is_tag => true }, 'header3' => { :background => '#ffe4b5', :font => { :family => ['Geneva', 'Arial', 'Helvetica'], :size => 14 }, :is_tag => true }, 'keyword' => { :foreground => 'red', :is_tag => true }, 'search' => { :background => 'yellow', :is_tag => true }, 'hidden' => { :elide => true, :is_tag => true}, 'tab_button' => { :padx => 10, :font => { :family => ['Bitstream Vera Sans Mono', 'Menlo', 'Monaco', 'Courier'], :size => 10 } }, 'go_button' => { :padx => 20 }, }
- BINDINGS =
{ # The keys (e.g. 'b1001') in this hash are named arbitrarily and are completely # ignored by Tkri. They exist only to enable you to override certain bindings in # your 'rc' file. I'm not going to rename keys, only to add to them (as new # bindings are added to newer versions), so you won't have to update your 'rc' # file whenever you update Tkri. # For the :key syntax, see the Tk manual. The :source is the widget to attach the # binding to. The :commands are methods to execute; they're conveniently prefixed # by 'interactive_' to enable you to easily locate all of them in the source code. 'b1001' => { :key => 'Control-q', :source => 'root', :command => 'interactive_quit' }, 'b1002' => { :key => 'Control-t', :source => 'root', :command => 'interactive_new_tab' }, 'b1003' => { :key => 'Control-w', :source => 'root', :command => 'interactive_close_tab' }, 'b1004' => { :key => 'Control-l', :source => 'root', :command => 'interactive_focus_address' }, # Note: tabs indexes are zero-based. 'b2001' => { :key => 'Alt-Key-1', :source => 'root', :command => 'interactive_switch_to_tab_0' }, 'b2002' => { :key => 'Alt-Key-2', :source => 'root', :command => 'interactive_switch_to_tab_1' }, 'b2003' => { :key => 'Alt-Key-3', :source => 'root', :command => 'interactive_switch_to_tab_2' }, 'b2004' => { :key => 'Alt-Key-4', :source => 'root', :command => 'interactive_switch_to_tab_3' }, 'b2005' => { :key => 'Alt-Key-5', :source => 'root', :command => 'interactive_switch_to_tab_4' }, 'b2006' => { :key => 'Alt-Key-6', :source => 'root', :command => 'interactive_switch_to_tab_5' }, 'b2007' => { :key => 'Alt-Key-7', :source => 'root', :command => 'interactive_switch_to_tab_6' }, 'b2008' => { :key => 'Alt-Key-8', :source => 'root', :command => 'interactive_switch_to_tab_7' }, 'b2009' => { :key => 'Alt-Key-9', :source => 'root', :command => 'interactive_switch_to_tab_8' }, 'b2010' => { :key => 'Alt-Key-0', :source => 'root', :command => 'interactive_switch_to_tab_9' }, # For the following we don't use interactive_close_tab because we want to close the # tab associated with the button, not the current tab. 'b1007' => { :key => 'Button-2', :source => 'tabbutton', :command => 'interactive_close_button_tab' }, # 'Prior' and 'Next' are page up and page down, respectively. 'b1005' => { :key => 'Control-Key-Prior', :source => 'root', :command => 'interactive_switch_to_prev_tab' }, 'b1006' => { :key => 'Control-Key-Next', :source => 'root', :command => 'interactive_switch_to_next_tab' }, 'b1008' => { :key => 'ButtonRelease-1', :source => 'info', :command => 'interactive_goto_topic_under_mouse' }, 'b1008b' => { :key => 'Control-Button-1', :source => 'info', :command => 'interactive_goto_topic_under_caret_or_selected', :cancel_default => true }, 'b1011' => { :key => 'Key-Return', :source => 'info', :command => 'interactive_goto_topic_under_caret_or_selected', :cancel_default => true }, 'b1012' => { :key => 'Key-Return', :source => 'addressbox', :command => 'interactive_goto_topic_in_addressbox' }, # If I make the following "ButtonRelease-2" instead, the <PasteSelection> # cancellation that follows won't work. Strange. 'b1009' => { :key => 'Button-2', :source => 'info', :command => 'interactive_goto_topic_under_mouse_in_new_tab', :cancel_default => true }, # Under X11, Button-2 is also used to paste the selection. So we disable pasting. All # because Tk doesn't support read-only text widgets. 'b1010' => { :key => '<PasteSelection>', :source => 'info', :cancel_default => true }, # History. 'b1013' => { :key => 'ButtonRelease-3', :source => 'info', :command => 'interactive_history_back' }, 'b1014' => { :key => 'Key-BackSpace', :source => 'info', :command => 'interactive_history_back', :cancel_default => true }, 'b1014b' => { :key => 'Alt-Key-Left', :source => 'root', :command => 'interactive_history_back', :cancel_default => true }, 'b1014c' => { :key => 'Alt-Key-Right', :source => 'root', :command => 'interactive_history_forward', :cancel_default => true }, # Tk doesn't support read-only rext widgets. So for every "ascii" global binding we also # need to duplicate it on the 'info' widget, :cancel_default'ing it. # # "Global" bindings are those attached to the 'root' window. For "ascii" bindings make sure # to turn on :when_not_tkentry, or else these events will fire up when the key is pressed in # the addressbox too (which is a widget of type TkEntry). 'b1015' => { :key => 'Key-slash', :source => 'root', :command => 'interactive_initiate_search', :when_not_tkentry => true }, 'b1016' => { :key => 'Key-n', :source => 'root', :command => 'interactive_search_next', :when_not_tkentry => true }, 'b1017' => { :key => 'Key-N', :source => 'root', :command => 'interactive_search_prev', :when_not_tkentry => true }, 'b1018' => { :key => 'Key-u', :source => 'root', :command => 'interactive_go_up', :when_not_tkentry => true }, 'b1019' => { :key => 'Key-slash', :source => 'info', :command => 'interactive_initiate_search', :cancel_default => true }, 'b1020' => { :key => 'Key-n', :source => 'info', :command => 'interactive_search_next', :cancel_default => true }, 'b1021' => { :key => 'Key-N', :source => 'info', :command => 'interactive_search_prev', :cancel_default => true }, 'b1022' => { :key => 'Key-u', :source => 'info', :command => 'interactive_go_up', :cancel_default => true }, }
Class Method Summary collapse
-
.dump ⇒ Object
Dump these settings into an ‘rc’ file.
Class Method Details
.dump ⇒ Object
Dump these settings into an ‘rc’ file.
138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/tkri.rb', line 138 def self.dump require 'yaml' open(Tkri.get_rc_file_path, 'w') do |f| f.puts "#" f.puts "# The documentation for these settings can be found in this file:" f.puts "# " + File.(__FILE__) f.puts "# Also, see the 'About the `rc` file' under the 'Help' menu." f.puts "#" f.puts "# You may erase any setting in this file for which you want to use" f.puts "# the default value." f.puts "#" f.puts({ 'command' => COMMAND, 'visuals' => VISUALS, 'bindings' => BINDINGS }.to_yaml) end end |