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

Class Method Details

.dumb_home(text) ⇒ Object



48
49
50
# File 'lib/ver/methods/nano.rb', line 48

def dumb_home(text)
  text.mark_set(:insert, 'insert linestart')
end

.home(text) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/ver/methods/nano.rb', line 28

def home(text)
  if text.store(self, :smart_home)
    smart_home(text)
  else
    dumb_home(text)
  end
end

.message(string) ⇒ Object



177
178
179
# File 'lib/ver/methods/nano.rb', line 177

def message(string)
  VER.message "[ #{string} ]"
end

.mumble(string) ⇒ Object



181
182
183
# File 'lib/ver/methods/nano.rb', line 181

def mumble(string)
  VER.message "[ #{string} ignored, mumble mumble ]"
end

.redraw(text) ⇒ Object

Noop



19
20
21
# File 'lib/ver/methods/nano.rb', line 19

def redraw(text)
  mumble "Redraw"
end

.smart_home(text) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/ver/methods/nano.rb', line 36

def smart_home(text)
  insert = text.index(:insert)
  x = text.get(insert.linestart, insert.lineend).index(/\S/) || 0
  y = insert.y

  if insert.split == [y, x]
    text.mark_set(:insert, 'insert linestart')
  else
    text.mark_set(:insert, "#{y}.#{x}")
  end
end

.suspend(text) ⇒ Object

Noop



24
25
26
# File 'lib/ver/methods/nano.rb', line 24

def suspend(text)
  mumble "Suspend"
end

.toggle_auto_indent(text) ⇒ Object

Auto indent enable/disable If enabled, indent new lines to the previous line’s indentation. Useful when editing source code.



84
85
86
87
88
89
90
# File 'lib/ver/methods/nano.rb', line 84

def toggle_auto_indent(text)
  if text.options.autoindent = !text.options.autoindent
    message "Auto indent enabled"
  else
    message "Auto indent disabled"
  end
end

.toggle_backup_files(text) ⇒ Object

Backup files enable/disable



153
154
155
# File 'lib/ver/methods/nano.rb', line 153

def toggle_backup_files(text)
  mumble "Toggle backup files"
end

.toggle_color_syntax_highlighting(text) ⇒ Object

Color syntax highlighting enable/disable



138
139
140
# File 'lib/ver/methods/nano.rb', line 138

def toggle_color_syntax_highlighting(text)
  mumble "Toggle color syntax highlighting"
end

.toggle_convert_typed_tabs_to_spaces(text) ⇒ Object

Conversion of typed tabs to spaces enable/disable



93
94
95
96
97
98
99
# File 'lib/ver/methods/nano.rb', line 93

def toggle_convert_typed_tabs_to_spaces(text)
  if text.options.expandtab = !text.options.expandtab
    message "Conversion of typed tabs to spaces enabled"
  else
    message "Conversion of typed tabs to spaces disabled"
  end
end

.toggle_cursor_pos(text) ⇒ Object

Constant cursor position display enable/disable



53
54
55
56
57
58
59
60
61
62
# File 'lib/ver/methods/nano.rb', line 53

def toggle_cursor_pos(text)
  widgets = text.status.widgets
  np = widgets.find{|widget| widget.kind_of?(Status::NanoPosition) }

  if np.toggle
    message "Constant cursor position display enabled"
  else
    message "Constant cursor position display disabled"
  end
end

.toggle_cut_to_end(text) ⇒ Object

Cut to end enable/disable



143
144
145
# File 'lib/ver/methods/nano.rb', line 143

def toggle_cut_to_end(text)
  mumble "Toggle cut to end"
end

.toggle_dos_mac_format_conversion(text) ⇒ Object

No conversion from DOS/Mac format enable/disable



168
169
170
# File 'lib/ver/methods/nano.rb', line 168

def toggle_dos_mac_format_conversion(text)
  mumble "Toggle no conversion from DOS/Mac format"
end

.toggle_help_mode(text) ⇒ Object

Help mode enable/disable



115
116
117
118
119
120
# File 'lib/ver/methods/nano.rb', line 115

def toggle_help_mode(text)
  widgets = text.status.widgets
  np = widgets.find{|widget| widget.kind_of?(Status::NanoHelp) }

  message(np.toggle ? "Help mode enabled" : "Help mode disabled")
end

.toggle_long_line_wrapping(text) ⇒ Object

Long line wrapping enable/disable



148
149
150
# File 'lib/ver/methods/nano.rb', line 148

def toggle_long_line_wrapping(text)
  mumble "Toggle long line wrapping"
end

.toggle_mouse(text) ⇒ Object

Mouse support enable/disable



163
164
165
# File 'lib/ver/methods/nano.rb', line 163

def toggle_mouse(text)
  mumble "Toggle mouse support"
end

.toggle_multiple_file_buffers(text) ⇒ Object

Multiple file buffers enable/disable



158
159
160
# File 'lib/ver/methods/nano.rb', line 158

def toggle_multiple_file_buffers(text)
  mumble "Toggle multiple file buffers"
end

.toggle_one_more_line(text) ⇒ Object

Use of one more line for editing enable/disable



123
124
125
# File 'lib/ver/methods/nano.rb', line 123

def toggle_one_more_line(text)
  mumble "Toggle one more line ignored"
end

.toggle_smart_home_key(text) ⇒ 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.



71
72
73
74
75
76
77
78
79
# File 'lib/ver/methods/nano.rb', line 71

def toggle_smart_home_key(text)
  if old = text.store(self, :smart_home)
    text.store(self, :smart_home, true)
    message "Smart home key enabled"
  else
    text.store(self, :smart_home, false)
    message "Smart home key disabled"
  end
end

.toggle_smooth_scrolling(text) ⇒ Object

Smooth scrolling enable/disable



128
129
130
# File 'lib/ver/methods/nano.rb', line 128

def toggle_smooth_scrolling(text)
  mumble "Toggle smooth scrolling"
end

.toggle_soft_line_wrapping(text) ⇒ 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.



104
105
106
107
108
109
110
111
112
# File 'lib/ver/methods/nano.rb', line 104

def toggle_soft_line_wrapping(text)
  if text.cget(:wrap) == :word
    text.configure wrap: :none
    message "Soft line wrapping disabled"
  else
    text.configure wrap: :word
    message "Soft line wrapping enabled"
  end
end

.toggle_suspension(text) ⇒ Object

Suspension enable/disable



173
174
175
# File 'lib/ver/methods/nano.rb', line 173

def toggle_suspension(text)
  mumble "Toggle suspension"
end

.toggle_whitespace_display(text) ⇒ Object

Whitespace display enable/disable



133
134
135
# File 'lib/ver/methods/nano.rb', line 133

def toggle_whitespace_display(text)
  mumble "Toggle whitespace display"
end

.verbatim(text, action) ⇒ Object

Insert the next keystroke verbatim



8
9
10
11
12
# File 'lib/ver/methods/nano.rb', line 8

def verbatim(text, action)
  p text.major_mode.event_history.last
  char = text.major_mode.event_history.last[:unicode]
  text.insert(:insert, char)
end

.verbatim_insert(text) ⇒ Object

Insert the keystroke verbatim



15
16
# File 'lib/ver/methods/nano.rb', line 15

def verbatim_insert(text)
end