Module: VER::Methods::Nano
- Defined in:
- lib/ver/methods/nano.rb
Overview
A bunch of methods specific to the Nano keymap.
Class Method Summary collapse
- .ascii(buffer) ⇒ Object
- .ascii_enter(buffer, old, new) ⇒ Object
- .ascii_leave(buffer, old, new) ⇒ Object
- .dumb_home(buffer) ⇒ Object
- .home(buffer) ⇒ Object
- .message(buffer, string) ⇒ Object
- .mumble(string) ⇒ Object
-
.redraw(buffer) ⇒ Object
Noop.
- .smart_home(buffer) ⇒ Object
-
.suspend(buffer) ⇒ Object
Noop.
-
.toggle_auto_indent(buffer) ⇒ Object
Auto indent enable/disable If enabled, indent new lines to the previous line’s indentation.
-
.toggle_backup_files(buffer) ⇒ Object
Backup files enable/disable.
-
.toggle_color_syntax_highlighting(buffer) ⇒ Object
Color syntax highlighting enable/disable.
-
.toggle_convert_typed_tabs_to_spaces(buffer) ⇒ Object
Conversion of typed tabs to spaces enable/disable.
-
.toggle_cursor_pos(buffer) ⇒ Object
Constant cursor position display enable/disable.
-
.toggle_cut_to_end(buffer) ⇒ Object
Cut to end enable/disable.
-
.toggle_dos_mac_format_conversion(buffer) ⇒ Object
No conversion from DOS/Mac format enable/disable.
-
.toggle_help_mode(buffer) ⇒ Object
Help mode enable/disable.
-
.toggle_long_line_wrapping(buffer) ⇒ Object
Long line wrapping enable/disable.
-
.toggle_mouse(buffer) ⇒ Object
Mouse support enable/disable.
-
.toggle_multiple_file_buffers(buffer) ⇒ Object
Multiple file buffers enable/disable.
-
.toggle_one_more_line(buffer) ⇒ Object
Use of one more line for editing enable/disable.
-
.toggle_smart_home_key(buffer) ⇒ Object
Smart home key enable/disable If enabled, this makes the Home key smarter.
-
.toggle_smooth_scrolling(buffer) ⇒ Object
Smooth scrolling enable/disable.
-
.toggle_soft_line_wrapping(buffer) ⇒ Object
Soft line wrapping enable/disable VER will attempt to display the entire contents of a line, even if it is longer than the screen width.
-
.toggle_suspension(buffer) ⇒ Object
Suspension enable/disable.
-
.toggle_whitespace_display(buffer) ⇒ Object
Whitespace display enable/disable.
-
.verbatim(buffer, action) ⇒ Object
Insert the next keystroke verbatim.
-
.verbatim_insert(buffer) ⇒ Object
Insert the keystroke verbatim.
Class Method Details
.ascii(buffer) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/ver/methods/nano.rb', line 25 def ascii(buffer) unicode = buffer.events.last.unicode if unicode =~ /^\d+$/ digits = buffer.store(self, :ascii_digit) digits << unicode.to_i else # do nothing? return end return if digits.size < 3 ord = digits.join.to_i buffer.at_insert.insert(ord.chr) rescue => ex VER.error(ex) buffer.minor_mode(:ascii_digit, :control) else buffer.minor_mode(:ascii_digit, :control) end |
.ascii_enter(buffer, old, new) ⇒ Object
17 18 19 |
# File 'lib/ver/methods/nano.rb', line 17 def ascii_enter(buffer, old, new) buffer.store(self, :ascii_digit, []) end |
.ascii_leave(buffer, old, new) ⇒ Object
21 22 23 |
# File 'lib/ver/methods/nano.rb', line 21 def ascii_leave(buffer, old, new) buffer.store(self, :ascii_digit, nil) end |
.dumb_home(buffer) ⇒ Object
76 77 78 |
# File 'lib/ver/methods/nano.rb', line 76 def dumb_home(buffer) buffer.mark_set(:insert, 'insert linestart') end |
.home(buffer) ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/ver/methods/nano.rb', line 56 def home(buffer) if buffer.store(self, :smart_home) smart_home(buffer) else dumb_home(buffer) end end |
.message(buffer, string) ⇒ Object
205 206 207 |
# File 'lib/ver/methods/nano.rb', line 205 def (buffer, string) buffer. "[ #{string} ]" end |
.mumble(string) ⇒ Object
209 210 211 |
# File 'lib/ver/methods/nano.rb', line 209 def mumble(string) buffer. "[ #{string} ignored, mumble mumble ]" end |
.redraw(buffer) ⇒ Object
Noop
47 48 49 |
# File 'lib/ver/methods/nano.rb', line 47 def redraw(buffer) mumble buffer, "Redraw" end |
.smart_home(buffer) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/ver/methods/nano.rb', line 64 def smart_home(buffer) insert = buffer.index(:insert) x = buffer.get(insert.linestart, insert.lineend).index(/\S/) || 0 y = insert.y if insert.split == [y, x] buffer.mark_set(:insert, 'insert linestart') else buffer.mark_set(:insert, "#{y}.#{x}") end end |
.suspend(buffer) ⇒ Object
Noop
52 53 54 |
# File 'lib/ver/methods/nano.rb', line 52 def suspend(buffer) mumble buffer, "Suspend" end |
.toggle_auto_indent(buffer) ⇒ Object
Auto indent enable/disable If enabled, indent new lines to the previous line’s indentation. Useful when editing source code.
112 113 114 115 116 117 118 |
# File 'lib/ver/methods/nano.rb', line 112 def toggle_auto_indent(buffer) if buffer..autoindent = !buffer..autoindent buffer, "Auto indent enabled" else buffer, "Auto indent disabled" end end |
.toggle_backup_files(buffer) ⇒ Object
Backup files enable/disable
181 182 183 |
# File 'lib/ver/methods/nano.rb', line 181 def toggle_backup_files(buffer) mumble buffer, "Toggle backup files" end |
.toggle_color_syntax_highlighting(buffer) ⇒ Object
Color syntax highlighting enable/disable
166 167 168 |
# File 'lib/ver/methods/nano.rb', line 166 def toggle_color_syntax_highlighting(buffer) mumble buffer, "Toggle color syntax highlighting" end |
.toggle_convert_typed_tabs_to_spaces(buffer) ⇒ Object
Conversion of typed tabs to spaces enable/disable
121 122 123 124 125 126 127 |
# File 'lib/ver/methods/nano.rb', line 121 def toggle_convert_typed_tabs_to_spaces(buffer) if buffer.. = !buffer.. buffer, "Conversion of typed tabs to spaces enabled" else buffer, "Conversion of typed tabs to spaces disabled" end end |
.toggle_cursor_pos(buffer) ⇒ Object
Constant cursor position display enable/disable
81 82 83 84 85 86 87 88 89 90 |
# File 'lib/ver/methods/nano.rb', line 81 def toggle_cursor_pos(buffer) = buffer.status. np = .find{|| .kind_of?(Status::NanoPosition) } if np.toggle buffer, "Constant cursor position display enabled" else buffer, "Constant cursor position display disabled" end end |
.toggle_cut_to_end(buffer) ⇒ Object
Cut to end enable/disable
171 172 173 |
# File 'lib/ver/methods/nano.rb', line 171 def toggle_cut_to_end(buffer) mumble buffer, "Toggle cut to end" end |
.toggle_dos_mac_format_conversion(buffer) ⇒ Object
No conversion from DOS/Mac format enable/disable
196 197 198 |
# File 'lib/ver/methods/nano.rb', line 196 def toggle_dos_mac_format_conversion(buffer) mumble buffer, "Toggle no conversion from DOS/Mac format" end |
.toggle_help_mode(buffer) ⇒ Object
Help mode enable/disable
143 144 145 146 147 148 |
# File 'lib/ver/methods/nano.rb', line 143 def toggle_help_mode(buffer) = buffer.status. np = .find{|| .kind_of?(Status::NanoHelp) } (np.toggle ? "Help mode enabled" : "Help mode disabled") end |
.toggle_long_line_wrapping(buffer) ⇒ Object
Long line wrapping enable/disable
176 177 178 |
# File 'lib/ver/methods/nano.rb', line 176 def toggle_long_line_wrapping(buffer) mumble buffer, "Toggle long line wrapping" end |
.toggle_mouse(buffer) ⇒ Object
Mouse support enable/disable
191 192 193 |
# File 'lib/ver/methods/nano.rb', line 191 def toggle_mouse(buffer) mumble buffer, "Toggle mouse support" end |
.toggle_multiple_file_buffers(buffer) ⇒ Object
Multiple file buffers enable/disable
186 187 188 |
# File 'lib/ver/methods/nano.rb', line 186 def toggle_multiple_file_buffers(buffer) mumble buffer, "Toggle multiple file buffers" end |
.toggle_one_more_line(buffer) ⇒ Object
Use of one more line for editing enable/disable
151 152 153 |
# File 'lib/ver/methods/nano.rb', line 151 def toggle_one_more_line(buffer) mumble buffer, "Toggle one more line ignored" end |
.toggle_smart_home_key(buffer) ⇒ Object
Smart home key enable/disable If enabled, this makes the Home key smarter. When Home is pressed anywhere but at the very beginning of non-whitespace characters on a line, the cursor will jump to that beginning (either forwards or backwards). If the cursor is already at that position, it will jump to the true beginning of the line.
99 100 101 102 103 104 105 106 107 |
# File 'lib/ver/methods/nano.rb', line 99 def toggle_smart_home_key(buffer) if old = buffer.store(self, :smart_home) buffer.store(self, :smart_home, true) buffer, "Smart home key enabled" else buffer.store(self, :smart_home, false) buffer, "Smart home key disabled" end end |
.toggle_smooth_scrolling(buffer) ⇒ Object
Smooth scrolling enable/disable
156 157 158 |
# File 'lib/ver/methods/nano.rb', line 156 def toggle_smooth_scrolling(buffer) mumble buffer, "Toggle smooth scrolling" end |
.toggle_soft_line_wrapping(buffer) ⇒ Object
Soft line wrapping enable/disable VER will attempt to display the entire contents of a line, even if it is longer than the screen width.
132 133 134 135 136 137 138 139 140 |
# File 'lib/ver/methods/nano.rb', line 132 def toggle_soft_line_wrapping(buffer) if buffer.cget(:wrap) == :word buffer.configure wrap: :none buffer, "Soft line wrapping disabled" else buffer.configure wrap: :word buffer, "Soft line wrapping enabled" end end |
.toggle_suspension(buffer) ⇒ Object
Suspension enable/disable
201 202 203 |
# File 'lib/ver/methods/nano.rb', line 201 def toggle_suspension(buffer) mumble buffer, "Toggle suspension" end |
.toggle_whitespace_display(buffer) ⇒ Object
Whitespace display enable/disable
161 162 163 |
# File 'lib/ver/methods/nano.rb', line 161 def toggle_whitespace_display(buffer) mumble buffer, "Toggle whitespace display" end |
.verbatim(buffer, action) ⇒ Object
Insert the next keystroke verbatim
8 9 10 11 |
# File 'lib/ver/methods/nano.rb', line 8 def verbatim(buffer, action) char = buffer.events.last.unicode buffer.insert(:insert, char) end |
.verbatim_insert(buffer) ⇒ Object
Insert the keystroke verbatim
14 15 |
# File 'lib/ver/methods/nano.rb', line 14 def verbatim_insert(buffer) end |