diakonos 0.8.11 → 0.9.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG +439 -0
- data/LICENCE.md +675 -0
- data/bin/diakonos +6 -0
- data/diakonos-256-colour.conf +220 -0
- data/diakonos.conf +1802 -0
- data/help/about-help.dhf +31 -0
- data/help/clipboard.dhf +45 -0
- data/help/close-file.dhf +6 -0
- data/help/code-block-navigation.dhf +16 -0
- data/help/column-markers.dhf +15 -0
- data/help/config.dhf +69 -0
- data/help/cursor-stack.dhf +19 -0
- data/help/delete.dhf +41 -0
- data/help/extensions.dhf +125 -0
- data/help/file-type.dhf +24 -0
- data/help/key-mapping.dhf +127 -0
- data/help/line-numbers.dhf +22 -0
- data/help/macros.dhf +27 -0
- data/help/new-file.dhf +6 -0
- data/help/open-file.dhf +21 -0
- data/help/quit.dhf +7 -0
- data/help/resizing.dhf +19 -0
- data/help/ruby.dhf +17 -0
- data/help/save-file.dhf +10 -0
- data/help/scripting.dhf +92 -0
- data/help/search.dhf +103 -0
- data/help/shell.dhf +60 -0
- data/help/speed.dhf +23 -0
- data/help/support.dhf +15 -0
- data/help/switch-buffers.dhf +15 -0
- data/help/tabs.dhf +36 -0
- data/help/undo.dhf +9 -0
- data/help/uninstall.dhf +18 -0
- data/help/welcome.dhf +32 -0
- data/help/word-wrap.dhf +17 -0
- data/lib/diakonos/about.rb +70 -0
- data/lib/diakonos/bookmark.rb +46 -0
- data/lib/diakonos/buffer/bookmarking.rb +47 -0
- data/lib/diakonos/buffer/cursor.rb +335 -0
- data/lib/diakonos/buffer/delete.rb +170 -0
- data/lib/diakonos/buffer/display.rb +362 -0
- data/lib/diakonos/buffer/file.rb +157 -0
- data/lib/diakonos/buffer/indentation.rb +175 -0
- data/lib/diakonos/buffer/searching.rb +552 -0
- data/lib/diakonos/buffer/selection.rb +360 -0
- data/lib/diakonos/buffer/undo.rb +73 -0
- data/lib/diakonos/buffer-hash.rb +60 -0
- data/lib/diakonos/buffer-management.rb +59 -0
- data/lib/diakonos/buffer.rb +698 -0
- data/lib/diakonos/clipboard-klipper-dbus.rb +62 -0
- data/lib/diakonos/clipboard-klipper.rb +62 -0
- data/lib/diakonos/clipboard-osx.rb +59 -0
- data/lib/diakonos/clipboard-xclip.rb +60 -0
- data/lib/diakonos/clipboard.rb +47 -0
- data/lib/diakonos/config-file.rb +67 -0
- data/lib/diakonos/config.rb +382 -0
- data/lib/diakonos/core-ext/enumerable.rb +15 -0
- data/lib/diakonos/core-ext/hash.rb +60 -0
- data/lib/diakonos/core-ext/object.rb +6 -0
- data/lib/diakonos/core-ext/regexp.rb +6 -0
- data/lib/diakonos/core-ext/string.rb +122 -0
- data/lib/diakonos/ctag.rb +28 -0
- data/lib/diakonos/cursor.rb +27 -0
- data/lib/diakonos/display/format.rb +75 -0
- data/lib/diakonos/display.rb +336 -0
- data/lib/diakonos/extension-set.rb +49 -0
- data/lib/diakonos/extension.rb +34 -0
- data/lib/diakonos/finding.rb +40 -0
- data/lib/diakonos/functions/basics.rb +34 -0
- data/lib/diakonos/functions/bookmarking.rb +61 -0
- data/lib/diakonos/functions/buffers.rb +491 -0
- data/lib/diakonos/functions/clipboard.rb +70 -0
- data/lib/diakonos/functions/cursor.rb +264 -0
- data/lib/diakonos/functions/grepping.rb +83 -0
- data/lib/diakonos/functions/indentation.rb +71 -0
- data/lib/diakonos/functions/readline.rb +93 -0
- data/lib/diakonos/functions/search.rb +179 -0
- data/lib/diakonos/functions/selection.rb +98 -0
- data/lib/diakonos/functions/sessions.rb +78 -0
- data/lib/diakonos/functions/shell.rb +250 -0
- data/lib/diakonos/functions/tags.rb +65 -0
- data/lib/diakonos/functions/text-manipulation.rb +196 -0
- data/lib/diakonos/functions-deprecated.rb +77 -0
- data/lib/diakonos/functions.rb +292 -0
- data/lib/diakonos/grep.rb +98 -0
- data/lib/diakonos/help.rb +47 -0
- data/lib/diakonos/hooks.rb +13 -0
- data/lib/diakonos/installation.rb +19 -0
- data/lib/diakonos/interaction-handler.rb +216 -0
- data/lib/diakonos/interaction.rb +52 -0
- data/lib/diakonos/key-map.rb +62 -0
- data/lib/diakonos/keying.rb +442 -0
- data/lib/diakonos/line-mover.rb +42 -0
- data/lib/diakonos/list.rb +59 -0
- data/lib/diakonos/logging.rb +27 -0
- data/lib/diakonos/mode.rb +17 -0
- data/lib/diakonos/mouse.rb +18 -0
- data/lib/diakonos/number-fitter.rb +11 -0
- data/lib/diakonos/range.rb +31 -0
- data/lib/diakonos/readline/functions.rb +82 -0
- data/lib/diakonos/readline.rb +223 -0
- data/lib/diakonos/search.rb +58 -0
- data/lib/diakonos/sessions.rb +257 -0
- data/lib/diakonos/sized-array.rb +48 -0
- data/lib/diakonos/text-mark.rb +19 -0
- data/lib/diakonos/vendor/fuzzy_file_finder.rb +386 -0
- data/lib/diakonos/version.rb +25 -0
- data/lib/diakonos/window.rb +43 -0
- data/lib/diakonos.rb +592 -0
- metadata +160 -68
@@ -0,0 +1,75 @@
|
|
1
|
+
module Diakonos
|
2
|
+
module Display
|
3
|
+
def self.to_colour_constant( str )
|
4
|
+
case str.downcase
|
5
|
+
when "black", "0"
|
6
|
+
Curses::COLOR_BLACK
|
7
|
+
when "red", "1"
|
8
|
+
Curses::COLOR_RED
|
9
|
+
when "green", "2"
|
10
|
+
Curses::COLOR_GREEN
|
11
|
+
when "yellow", "brown", "3"
|
12
|
+
Curses::COLOR_YELLOW
|
13
|
+
when "blue", "4"
|
14
|
+
Curses::COLOR_BLUE
|
15
|
+
when "magenta", "purple", "5"
|
16
|
+
Curses::COLOR_MAGENTA
|
17
|
+
when "cyan", "6"
|
18
|
+
Curses::COLOR_CYAN
|
19
|
+
when "white", "7"
|
20
|
+
Curses::COLOR_WHITE
|
21
|
+
else
|
22
|
+
str.to_i
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.to_formatting( str )
|
27
|
+
formatting = Curses::A_NORMAL
|
28
|
+
|
29
|
+
str.split( /\s+/ ).each do |format|
|
30
|
+
colour_number = format.to_i
|
31
|
+
if colour_number > Curses::COLOR_WHITE
|
32
|
+
formatting |= Curses::color_pair( colour_number )
|
33
|
+
elsif format.downcase == 'normal'
|
34
|
+
formatting = Curses::A_NORMAL
|
35
|
+
else
|
36
|
+
formatting |= case format.downcase
|
37
|
+
when "black", "0"
|
38
|
+
Curses::color_pair( Curses::COLOR_BLACK )
|
39
|
+
when "red", "1"
|
40
|
+
Curses::color_pair( Curses::COLOR_RED )
|
41
|
+
when "green", "2"
|
42
|
+
Curses::color_pair( Curses::COLOR_GREEN )
|
43
|
+
when "yellow", "brown", "3"
|
44
|
+
Curses::color_pair( Curses::COLOR_YELLOW )
|
45
|
+
when "blue", "4"
|
46
|
+
Curses::color_pair( Curses::COLOR_BLUE )
|
47
|
+
when "magenta", "purple", "5"
|
48
|
+
Curses::color_pair( Curses::COLOR_MAGENTA )
|
49
|
+
when "cyan", "6"
|
50
|
+
Curses::color_pair( Curses::COLOR_CYAN )
|
51
|
+
when "white", "7"
|
52
|
+
Curses::color_pair( Curses::COLOR_WHITE )
|
53
|
+
when "standout", "s", "so"
|
54
|
+
Curses::A_STANDOUT
|
55
|
+
when "underline", "u", "un", "ul"
|
56
|
+
Curses::A_UNDERLINE
|
57
|
+
when "reverse", "r", "rev", "inverse", "i", "inv"
|
58
|
+
Curses::A_REVERSE
|
59
|
+
when "blink", "bl", "blinking"
|
60
|
+
Curses::A_BLINK
|
61
|
+
when "dim", "d"
|
62
|
+
Curses::A_DIM
|
63
|
+
when "bold", "b", "bo"
|
64
|
+
Curses::A_BOLD
|
65
|
+
else
|
66
|
+
0
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
formatting
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,336 @@
|
|
1
|
+
require 'curses'
|
2
|
+
|
3
|
+
module Diakonos
|
4
|
+
DO_REDRAW = true
|
5
|
+
DONT_REDRAW = false
|
6
|
+
|
7
|
+
class Diakonos
|
8
|
+
attr_reader :win_main, :display_mutex, :win_line_numbers
|
9
|
+
|
10
|
+
def cleanup_display
|
11
|
+
return if @testing
|
12
|
+
|
13
|
+
@win_main.close if @win_main
|
14
|
+
@win_status.close if @win_status
|
15
|
+
@win_interaction.close if @win_interaction
|
16
|
+
@win_context.close if @win_context
|
17
|
+
@win_line_numbers.close if @win_line_numbers
|
18
|
+
|
19
|
+
Curses::close_screen
|
20
|
+
end
|
21
|
+
|
22
|
+
def initialize_display
|
23
|
+
if ! @testing
|
24
|
+
cleanup_display
|
25
|
+
|
26
|
+
Curses::init_screen
|
27
|
+
Curses::nonl
|
28
|
+
Curses::raw
|
29
|
+
Curses::noecho
|
30
|
+
if @settings['mouse']
|
31
|
+
Curses::mousemask(Curses::ALL_MOUSE_EVENTS)
|
32
|
+
end
|
33
|
+
|
34
|
+
if Curses::has_colors?
|
35
|
+
Curses::start_color
|
36
|
+
Curses::use_default_colors
|
37
|
+
|
38
|
+
# -1 means use the terminal's current/default background, which may even have some transparency
|
39
|
+
background_colour = settings['colour.background'] || -1
|
40
|
+
Curses::init_pair( Curses::COLOR_BLACK, Curses::COLOR_BLACK, background_colour )
|
41
|
+
Curses::init_pair( Curses::COLOR_RED, Curses::COLOR_RED, background_colour )
|
42
|
+
Curses::init_pair( Curses::COLOR_GREEN, Curses::COLOR_GREEN, background_colour )
|
43
|
+
Curses::init_pair( Curses::COLOR_YELLOW, Curses::COLOR_YELLOW, background_colour )
|
44
|
+
Curses::init_pair( Curses::COLOR_BLUE, Curses::COLOR_BLUE, background_colour )
|
45
|
+
Curses::init_pair( Curses::COLOR_MAGENTA, Curses::COLOR_MAGENTA, background_colour )
|
46
|
+
Curses::init_pair( Curses::COLOR_CYAN, Curses::COLOR_CYAN, background_colour )
|
47
|
+
Curses::init_pair( Curses::COLOR_WHITE, Curses::COLOR_WHITE, background_colour )
|
48
|
+
@colour_pairs.each do |cp|
|
49
|
+
Curses::init_pair( cp[ :number ], cp[ :fg ], cp[ :bg ] )
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
if settings[ 'view.line_numbers' ]
|
55
|
+
@win_line_numbers = ::Diakonos::Window.new( main_window_height, settings[ 'view.line_numbers.width' ], 0, 0 )
|
56
|
+
@win_main = ::Diakonos::Window.new( main_window_height, Curses::cols - settings[ 'view.line_numbers.width' ], 0, settings[ 'view.line_numbers.width' ] )
|
57
|
+
else
|
58
|
+
@win_main = ::Diakonos::Window.new( main_window_height, Curses::cols, 0, 0 )
|
59
|
+
@win_line_numbers = nil
|
60
|
+
end
|
61
|
+
@win_status = ::Diakonos::Window.new( 1, Curses::cols, Curses::lines - 2, 0 )
|
62
|
+
@win_status.attrset @settings[ 'status.format' ]
|
63
|
+
@win_interaction = ::Diakonos::Window.new( 1, Curses::cols, Curses::lines - 1, 0 )
|
64
|
+
|
65
|
+
@interaction_handler = InteractionHandler.new(
|
66
|
+
win_main: @win_main,
|
67
|
+
win_interaction: @win_interaction,
|
68
|
+
cursor_manager: self,
|
69
|
+
testing: @testing,
|
70
|
+
choice_delay: @settings['interaction.choice_delay'],
|
71
|
+
blink_string: @settings['interaction.blink_string'],
|
72
|
+
blink_duration: @settings['interaction.blink_duration']
|
73
|
+
)
|
74
|
+
|
75
|
+
if @settings['context.visible']
|
76
|
+
if @settings['context.combined']
|
77
|
+
pos = 1
|
78
|
+
else
|
79
|
+
pos = 3
|
80
|
+
end
|
81
|
+
@win_context = ::Diakonos::Window.new( 1, Curses::cols, Curses::lines - pos, 0 )
|
82
|
+
else
|
83
|
+
@win_context = nil
|
84
|
+
end
|
85
|
+
|
86
|
+
if ! @testing
|
87
|
+
@win_main.keypad( true )
|
88
|
+
@win_status.keypad( true )
|
89
|
+
@win_interaction.keypad( true )
|
90
|
+
if @win_line_numbers
|
91
|
+
@win_line_numbers.keypad( true )
|
92
|
+
end
|
93
|
+
if @win_context
|
94
|
+
@win_context.keypad( true )
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
@modes[ 'edit' ].window = @win_main
|
99
|
+
@modes[ 'input' ].window = @win_interaction
|
100
|
+
|
101
|
+
@win_interaction.refresh
|
102
|
+
@win_main.refresh
|
103
|
+
if @win_line_numbers
|
104
|
+
@win_line_numbers.refresh
|
105
|
+
end
|
106
|
+
|
107
|
+
if @buffers
|
108
|
+
@buffers.each do |buffer|
|
109
|
+
buffer.reset_display
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
def redraw
|
115
|
+
load_configuration
|
116
|
+
initialize_display
|
117
|
+
update_status_line
|
118
|
+
update_context_line
|
119
|
+
display_buffer buffer_current
|
120
|
+
end
|
121
|
+
|
122
|
+
def main_window_height
|
123
|
+
# One line for the status line
|
124
|
+
# One line for the input line
|
125
|
+
# One line for the context line
|
126
|
+
retval = Curses::lines - 2
|
127
|
+
if @settings['context.visible'] && ! @settings['context.combined']
|
128
|
+
retval = retval - 1
|
129
|
+
end
|
130
|
+
retval
|
131
|
+
end
|
132
|
+
|
133
|
+
def main_window_width
|
134
|
+
Curses::cols
|
135
|
+
end
|
136
|
+
|
137
|
+
def set_iline(s = "")
|
138
|
+
@interaction_handler.set_iline s
|
139
|
+
end
|
140
|
+
|
141
|
+
def set_iline_if_empty(s)
|
142
|
+
@interaction_handler.set_iline_if_empty s
|
143
|
+
end
|
144
|
+
|
145
|
+
def set_status_variable( identifier, value )
|
146
|
+
@status_vars[ identifier ] = value
|
147
|
+
end
|
148
|
+
|
149
|
+
def build_status_line( truncation = 0 )
|
150
|
+
var_array = Array.new
|
151
|
+
@settings[ "status.vars" ].each do |var|
|
152
|
+
case var
|
153
|
+
when "buffer_number"
|
154
|
+
var_array.push buffer_to_number( buffer_current )
|
155
|
+
when "col"
|
156
|
+
var_array.push( buffer_current.last_screen_col + 1 )
|
157
|
+
when "filename"
|
158
|
+
name = buffer_current.nice_name
|
159
|
+
var_array.push name[ ([ truncation, name.length ].min)..-1 ]
|
160
|
+
when "modified"
|
161
|
+
if buffer_current.modified?
|
162
|
+
var_array.push @settings[ "status.modified_str" ]
|
163
|
+
else
|
164
|
+
var_array.push ""
|
165
|
+
end
|
166
|
+
when "num_buffers"
|
167
|
+
var_array.push @buffers.length
|
168
|
+
when "num_lines"
|
169
|
+
var_array.push buffer_current.length
|
170
|
+
when "row", "line"
|
171
|
+
var_array.push( buffer_current.last_row + 1 )
|
172
|
+
when "read_only"
|
173
|
+
if buffer_current.read_only
|
174
|
+
var_array.push @settings[ "status.read_only_str" ]
|
175
|
+
else
|
176
|
+
var_array.push ""
|
177
|
+
end
|
178
|
+
when "selecting"
|
179
|
+
if buffer_current.changing_selection
|
180
|
+
var_array.push @settings[ "status.selecting_str" ]
|
181
|
+
else
|
182
|
+
var_array.push ""
|
183
|
+
end
|
184
|
+
when 'selection_mode'
|
185
|
+
case buffer_current.selection_mode
|
186
|
+
when :block
|
187
|
+
var_array.push 'block'
|
188
|
+
else
|
189
|
+
var_array.push ''
|
190
|
+
end
|
191
|
+
when 'session_name'
|
192
|
+
var_array.push @session.name
|
193
|
+
when "type"
|
194
|
+
var_array.push buffer_current.original_language
|
195
|
+
when /^@/
|
196
|
+
var_array.push @status_vars[ var ]
|
197
|
+
end
|
198
|
+
end
|
199
|
+
str = nil
|
200
|
+
begin
|
201
|
+
status_left = @settings[ "status.left" ]
|
202
|
+
field_count = status_left.count "%"
|
203
|
+
status_left = status_left % var_array[ 0...field_count ]
|
204
|
+
status_right = @settings[ "status.right" ] % var_array[ field_count..-1 ]
|
205
|
+
filler_string = @settings[ "status.filler" ]
|
206
|
+
fill_amount = (Curses::cols - status_left.length - status_right.length) / filler_string.length
|
207
|
+
if fill_amount > 0
|
208
|
+
filler = filler_string * fill_amount
|
209
|
+
else
|
210
|
+
filler = ""
|
211
|
+
end
|
212
|
+
str = status_left + filler + status_right
|
213
|
+
rescue ArgumentError, TypeError => e
|
214
|
+
debug_log e
|
215
|
+
debug_log e.backtrace[ 0 ]
|
216
|
+
debug_log "var_array: #{var_array.inspect}"
|
217
|
+
str = "%-#{Curses::cols}s" % "(status line configuration error)"
|
218
|
+
end
|
219
|
+
str
|
220
|
+
end
|
221
|
+
protected :build_status_line
|
222
|
+
|
223
|
+
def update_status_line
|
224
|
+
return if @testing
|
225
|
+
|
226
|
+
str = build_status_line
|
227
|
+
if str.length > Curses::cols
|
228
|
+
str = build_status_line( str.length - Curses::cols )
|
229
|
+
end
|
230
|
+
Curses::curs_set 0
|
231
|
+
@win_status.setpos( 0, 0 )
|
232
|
+
@win_status.addstr str
|
233
|
+
@win_status.refresh
|
234
|
+
Curses::curs_set 1
|
235
|
+
end
|
236
|
+
|
237
|
+
def update_context_line
|
238
|
+
return if @testing
|
239
|
+
return if @win_context.nil?
|
240
|
+
|
241
|
+
@context_thread.exit if @context_thread
|
242
|
+
@context_thread = Thread.new do
|
243
|
+
context = buffer_current.context
|
244
|
+
|
245
|
+
Curses::curs_set 0
|
246
|
+
@win_context.setpos( 0, 0 )
|
247
|
+
chars_printed = 0
|
248
|
+
if context.length > 0
|
249
|
+
truncation = [ @settings[ "context.max_levels" ], context.length ].min
|
250
|
+
max_length = [
|
251
|
+
( Curses::cols / truncation ) - @settings[ "context.separator" ].length,
|
252
|
+
( @settings[ "context.max_segment_width" ] || Curses::cols )
|
253
|
+
].min
|
254
|
+
line = nil
|
255
|
+
context_subset = context[ 0...truncation ]
|
256
|
+
context_subset = context_subset.collect do |line|
|
257
|
+
line.strip[ 0...max_length ]
|
258
|
+
end
|
259
|
+
|
260
|
+
context_subset.each do |line|
|
261
|
+
@win_context.attrset @settings[ "context.format" ]
|
262
|
+
@win_context.addstr line
|
263
|
+
chars_printed += line.length
|
264
|
+
@win_context.attrset @settings[ "context.separator.format" ]
|
265
|
+
@win_context.addstr @settings[ "context.separator" ]
|
266
|
+
chars_printed += @settings[ "context.separator" ].length
|
267
|
+
end
|
268
|
+
end
|
269
|
+
|
270
|
+
@context_line_mutex.synchronize do
|
271
|
+
@win_context.attrset @settings[ "context.format" ]
|
272
|
+
@win_context.addstr( " " * ( Curses::cols - chars_printed ) )
|
273
|
+
@win_context.refresh
|
274
|
+
end
|
275
|
+
@display_mutex.synchronize do
|
276
|
+
@win_main.setpos( buffer_current.last_screen_y, buffer_current.last_screen_x )
|
277
|
+
@win_main.refresh
|
278
|
+
end
|
279
|
+
Curses::curs_set 1
|
280
|
+
end
|
281
|
+
|
282
|
+
@context_thread.priority = -2
|
283
|
+
end
|
284
|
+
|
285
|
+
def display_buffer( buffer )
|
286
|
+
return if @testing
|
287
|
+
return if ! @do_display
|
288
|
+
|
289
|
+
Thread.new do
|
290
|
+
|
291
|
+
if ! @display_mutex.try_lock
|
292
|
+
@display_queue_mutex.synchronize do
|
293
|
+
@display_queue = buffer
|
294
|
+
end
|
295
|
+
else
|
296
|
+
begin
|
297
|
+
Curses::curs_set 0
|
298
|
+
buffer.display
|
299
|
+
Curses::curs_set 1
|
300
|
+
rescue Exception => e
|
301
|
+
$diakonos.log( "Display Exception:" )
|
302
|
+
$diakonos.log( e.message )
|
303
|
+
$diakonos.log( e.backtrace.join( "\n" ) )
|
304
|
+
show_exception e
|
305
|
+
end
|
306
|
+
|
307
|
+
@display_mutex.unlock
|
308
|
+
|
309
|
+
@display_queue_mutex.synchronize do
|
310
|
+
if @display_queue
|
311
|
+
b = @display_queue
|
312
|
+
@display_queue = nil
|
313
|
+
display_buffer b
|
314
|
+
end
|
315
|
+
end
|
316
|
+
end
|
317
|
+
|
318
|
+
end
|
319
|
+
|
320
|
+
end
|
321
|
+
|
322
|
+
def refresh_all
|
323
|
+
@win_main.refresh
|
324
|
+
if @win_context
|
325
|
+
@win_context.refresh
|
326
|
+
end
|
327
|
+
@win_status.refresh
|
328
|
+
@win_interaction.refresh
|
329
|
+
if @win_line_numbers
|
330
|
+
@win_line_numbers.refresh
|
331
|
+
end
|
332
|
+
end
|
333
|
+
|
334
|
+
end
|
335
|
+
|
336
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Diakonos
|
2
|
+
|
3
|
+
class ExtensionSet
|
4
|
+
|
5
|
+
def initialize( root_dir )
|
6
|
+
@extensions = Hash.new
|
7
|
+
@root_dir = File.expand_path( root_dir )
|
8
|
+
end
|
9
|
+
|
10
|
+
def scripts
|
11
|
+
@extensions.values.find_all { |e| e }.map { |e| e.scripts }.flatten
|
12
|
+
end
|
13
|
+
|
14
|
+
# @return an Array of configuration filenames to parse
|
15
|
+
def load( dir )
|
16
|
+
@extensions[ dir ] = false
|
17
|
+
|
18
|
+
confs_to_parse = []
|
19
|
+
ext_dir = File.join( @root_dir, dir )
|
20
|
+
info = YAML.load_file( File.join( ext_dir, 'info.yaml' ) )
|
21
|
+
|
22
|
+
if info[ 'requirements' ] && info[ 'requirements' ][ 'diakonos' ]
|
23
|
+
this_version = ::Diakonos.parse_version( ::Diakonos::VERSION )
|
24
|
+
min_version = ::Diakonos.parse_version( info[ 'requirements' ][ 'diakonos' ][ 'minimum' ] )
|
25
|
+
if min_version && this_version >= min_version
|
26
|
+
extension = Extension.new( ext_dir )
|
27
|
+
@extensions[ dir ] = extension
|
28
|
+
confs_to_parse += extension.confs
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
confs_to_parse
|
33
|
+
end
|
34
|
+
|
35
|
+
def loaded?( ext_dir )
|
36
|
+
@extensions[ ext_dir ]
|
37
|
+
end
|
38
|
+
|
39
|
+
def loaded_extensions
|
40
|
+
@extensions.values.find_all { |e| e }
|
41
|
+
end
|
42
|
+
|
43
|
+
def not_loaded_extensions
|
44
|
+
@extensions.keys.find_all { |e| ! loaded?( e ) }
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Diakonos
|
2
|
+
|
3
|
+
class Extension
|
4
|
+
|
5
|
+
attr_reader :dir, :scripts, :confs
|
6
|
+
|
7
|
+
def initialize( dir )
|
8
|
+
@scripts = []
|
9
|
+
@confs = []
|
10
|
+
@dir = File.basename( dir )
|
11
|
+
@info = YAML.load_file( File.join( dir, 'info.yaml' ) )
|
12
|
+
|
13
|
+
Dir[ File.join( dir, '**', '*.rb' ) ].each do |ext_file|
|
14
|
+
@scripts << ext_file
|
15
|
+
end
|
16
|
+
|
17
|
+
Dir[ File.join( dir, "*.conf" ) ].each do |conf_file|
|
18
|
+
@confs << conf_file
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def []( key )
|
23
|
+
@info[ key ]
|
24
|
+
end
|
25
|
+
|
26
|
+
[ 'name', 'description', 'version' ].each do |m|
|
27
|
+
define_method( m ) do
|
28
|
+
@info[ m ]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Diakonos
|
2
|
+
|
3
|
+
class Finding
|
4
|
+
include RangeDelegator
|
5
|
+
|
6
|
+
def self.confirm(range_, regexps, lines, search_area, regexp_match)
|
7
|
+
matches = true
|
8
|
+
range = range_.dup
|
9
|
+
|
10
|
+
i = range.start_row + 1
|
11
|
+
regexps[1..-1].each do |re|
|
12
|
+
if lines[i] !~ re
|
13
|
+
matches = false
|
14
|
+
break
|
15
|
+
end
|
16
|
+
range.end_row = i
|
17
|
+
range.end_col = Regexp.last_match[0].length
|
18
|
+
i += 1
|
19
|
+
end
|
20
|
+
|
21
|
+
if (
|
22
|
+
matches &&
|
23
|
+
search_area.contains?( range.start_row, range.start_col ) &&
|
24
|
+
search_area.contains?( range.end_row, range.end_col - 1 )
|
25
|
+
)
|
26
|
+
Finding.new(range, regexp_match)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def initialize(range, regexp_match)
|
31
|
+
@range = range
|
32
|
+
@regexp_match = regexp_match
|
33
|
+
end
|
34
|
+
|
35
|
+
def captured_group(index)
|
36
|
+
@regexp_match[index]
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Diakonos
|
2
|
+
module Functions
|
3
|
+
|
4
|
+
# Move one character left, then delete one character.
|
5
|
+
#
|
6
|
+
# @see Diakonos::Buffer#delete
|
7
|
+
def backspace
|
8
|
+
if( buffer_current.changing_selection || cursor_left( Buffer::STILL_TYPING ) )
|
9
|
+
delete
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
# Insert a carriage return (newline) at the current cursor location.
|
14
|
+
# Deletes any currently selected text.
|
15
|
+
def carriage_return
|
16
|
+
buffer_current.carriage_return
|
17
|
+
buffer_current.delete_selection
|
18
|
+
end
|
19
|
+
|
20
|
+
# Calls Buffer#delete on the current buffer.
|
21
|
+
def delete
|
22
|
+
buffer_current.delete
|
23
|
+
end
|
24
|
+
|
25
|
+
# Deletes the current line and adds it to the clipboard.
|
26
|
+
def delete_line
|
27
|
+
removed_text = buffer_current.delete_line
|
28
|
+
if removed_text
|
29
|
+
@clipboard.add_clip( [ removed_text, "" ] )
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module Diakonos
|
2
|
+
module Functions
|
3
|
+
|
4
|
+
def add_named_bookmark( name_ = nil )
|
5
|
+
if name_.nil?
|
6
|
+
name = get_user_input "Bookmark name: "
|
7
|
+
else
|
8
|
+
name = name_
|
9
|
+
end
|
10
|
+
|
11
|
+
if name
|
12
|
+
@bookmarks[ name ] = Bookmark.new( buffer_current, buffer_current.current_row, buffer_current.current_column, name )
|
13
|
+
set_iline "Added bookmark #{@bookmarks[ name ].to_s}."
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def go_to_named_bookmark( name_ = nil )
|
18
|
+
if name_.nil?
|
19
|
+
name = get_user_input "Bookmark name: "
|
20
|
+
else
|
21
|
+
name = name_
|
22
|
+
end
|
23
|
+
|
24
|
+
if name
|
25
|
+
bookmark = @bookmarks[ name ]
|
26
|
+
if bookmark
|
27
|
+
switch_to( bookmark.buffer )
|
28
|
+
bookmark.buffer.cursor_to( bookmark.row, bookmark.col, Buffer::DO_DISPLAY )
|
29
|
+
else
|
30
|
+
set_iline "No bookmark named '#{name}'."
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def go_to_next_bookmark
|
36
|
+
buffer_current.go_to_next_bookmark
|
37
|
+
end
|
38
|
+
|
39
|
+
def go_to_previous_bookmark
|
40
|
+
buffer_current.go_to_previous_bookmark
|
41
|
+
end
|
42
|
+
|
43
|
+
def remove_named_bookmark( name_ = nil )
|
44
|
+
if name_.nil?
|
45
|
+
name = get_user_input "Bookmark name: "
|
46
|
+
else
|
47
|
+
name = name_
|
48
|
+
end
|
49
|
+
|
50
|
+
if name
|
51
|
+
bookmark = @bookmarks.delete name
|
52
|
+
set_iline "Removed bookmark #{bookmark.to_s}."
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def toggle_bookmark
|
57
|
+
buffer_current.toggle_bookmark
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|