diakonos 0.8.7 → 0.8.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. metadata +38 -59
  2. data/CHANGELOG +0 -238
  3. data/LICENCE +0 -21
  4. data/README +0 -75
  5. data/bin/diakonos +0 -6
  6. data/diakonos-256-colour.conf +0 -102
  7. data/diakonos.conf +0 -1233
  8. data/lib/diakonos.rb +0 -618
  9. data/lib/diakonos/array.rb +0 -15
  10. data/lib/diakonos/bignum.rb +0 -9
  11. data/lib/diakonos/bookmark.rb +0 -50
  12. data/lib/diakonos/buffer-hash.rb +0 -60
  13. data/lib/diakonos/buffer-management.rb +0 -73
  14. data/lib/diakonos/buffer.rb +0 -2044
  15. data/lib/diakonos/clipboard.rb +0 -47
  16. data/lib/diakonos/config.rb +0 -304
  17. data/lib/diakonos/ctag.rb +0 -28
  18. data/lib/diakonos/display.rb +0 -288
  19. data/lib/diakonos/enumerable.rb +0 -15
  20. data/lib/diakonos/finding.rb +0 -32
  21. data/lib/diakonos/fixnum.rb +0 -17
  22. data/lib/diakonos/functions.rb +0 -1420
  23. data/lib/diakonos/grep.rb +0 -78
  24. data/lib/diakonos/hash.rb +0 -108
  25. data/lib/diakonos/help.rb +0 -92
  26. data/lib/diakonos/hooks.rb +0 -13
  27. data/lib/diakonos/interaction.rb +0 -139
  28. data/lib/diakonos/keycode.rb +0 -110
  29. data/lib/diakonos/keying.rb +0 -124
  30. data/lib/diakonos/list.rb +0 -55
  31. data/lib/diakonos/logging.rb +0 -24
  32. data/lib/diakonos/object.rb +0 -6
  33. data/lib/diakonos/readline.rb +0 -274
  34. data/lib/diakonos/regexp.rb +0 -6
  35. data/lib/diakonos/sessions.rb +0 -70
  36. data/lib/diakonos/sized-array.rb +0 -48
  37. data/lib/diakonos/string.rb +0 -326
  38. data/lib/diakonos/text-mark.rb +0 -19
  39. data/lib/diakonos/vendor/fuzzy_file_finder.rb +0 -353
  40. data/lib/diakonos/window.rb +0 -32
  41. data/test/buffer-test.rb +0 -53
  42. data/test/clipboard-test.rb +0 -70
  43. data/test/diakonos-test.rb +0 -14
  44. data/test/hash-test.rb +0 -404
  45. data/test/regexp-test.rb +0 -26
  46. data/test/sizedarray-test.rb +0 -113
  47. data/test/string-test.rb +0 -160
@@ -1,78 +0,0 @@
1
- module Diakonos
2
- def self.grep_array( regexp, array, lines_of_context, prefix, filepath )
3
- num_lines = array.size
4
- line_numbers = []
5
- array.each_with_index do |line,index|
6
- next if line !~ regexp
7
- start_index = [ 0, index - lines_of_context ].max
8
- end_index = [ index + lines_of_context, num_lines-1 ].min
9
- (start_index..end_index).each do |i|
10
- line_numbers << i
11
- end
12
- end
13
-
14
- line_numbers.uniq!
15
- results = []
16
- last_i = line_numbers[ 0 ]
17
- one_result = []
18
- line_numbers.each do |i|
19
- if i - last_i > 1
20
- results << one_result.join( "\n" )
21
- one_result = []
22
- end
23
- one_result << ( "#{prefix}#{i+1}: " << ( "%-300s | #{filepath}:#{i+1}" % array[ i ] ) )
24
- last_i = i
25
- end
26
- if not one_result.empty?
27
- results << one_result.join( "\n" )
28
- end
29
-
30
- results
31
- end
32
-
33
- class Diakonos
34
-
35
- def grep_( regexp_source, *buffers )
36
- original_buffer = @current_buffer
37
- if @current_buffer.changing_selection
38
- selected_text = @current_buffer.copySelection[ 0 ]
39
- end
40
- starting_row, starting_col = @current_buffer.last_row, @current_buffer.last_col
41
-
42
- selected = getUserInput(
43
- "Grep regexp: ",
44
- @rlh_search,
45
- regexp_source || selected_text || ""
46
- ) { |input|
47
- next if input.length < 2
48
- begin
49
- regexp = Regexp.new( input, Regexp::IGNORECASE )
50
- grep_results = buffers.map { |buffer| buffer.grep( regexp ) }.flatten
51
- if settings[ 'grep.context' ] == 0
52
- join_str = "\n"
53
- else
54
- join_str = "\n---\n"
55
- end
56
- with_list_file do |list|
57
- list.puts grep_results.join( join_str )
58
- end
59
- list_buffer = openListBuffer
60
- list_buffer.highlightMatches regexp
61
- list_buffer.display
62
- rescue RegexpError
63
- # Do nothing
64
- end
65
- }
66
-
67
- if selected
68
- spl = selected.split( "| " )
69
- if spl.size > 1
70
- openFile spl[ -1 ]
71
- end
72
- else
73
- original_buffer.cursorTo starting_row, starting_col
74
- end
75
- end
76
-
77
- end
78
- end
@@ -1,108 +0,0 @@
1
- class Hash
2
- # path is an array of hash keys
3
- # This method deletes a path of hash keys, with each step in the path
4
- # being a recursively deeper key in a hash tree.
5
- # Returns the possibly modified hash.
6
- def deleteKeyPath( path )
7
- if path.length > 1
8
- subtree = self[ path[ 0 ] ]
9
- if subtree.respond_to?( :deleteKeyPath )
10
- subtree.deleteKeyPath( path[ 1..-1 ] )
11
- if subtree.empty?
12
- delete( path[ 0 ] )
13
- end
14
- end
15
- elsif path.length == 1
16
- delete( path[ 0 ] )
17
- end
18
-
19
- self
20
- end
21
-
22
- def setKeyPath( path, leaf )
23
- if path.length > 1
24
- node = self[ path[ 0 ] ]
25
- if not node.respond_to?( :setKeyPath )
26
- node = self[ path[ 0 ] ] = Hash.new
27
- end
28
- node.setKeyPath( path[ 1..-1 ], leaf )
29
- elsif path.length == 1
30
- self[ path[ 0 ] ] = leaf
31
- end
32
-
33
- self
34
- end
35
-
36
- def getNode( path )
37
- node = self[ path[ 0 ] ]
38
- if path.length > 1
39
- if node and node.respond_to?( :getNode )
40
- return node.getNode( path[ 1..-1 ] )
41
- end
42
- elsif path.length == 1
43
- return node
44
- end
45
-
46
- nil
47
- end
48
-
49
- def getLeaf( path )
50
- node = getNode( path )
51
- if node.respond_to?( :getNode )
52
- # Only want a leaf node
53
- nil
54
- else
55
- node
56
- end
57
- end
58
-
59
- def leaves( _leaves = Set.new )
60
- each_value do |value|
61
- if value.respond_to?( :leaves )
62
- _leaves.merge value.leaves( _leaves )
63
- else
64
- _leaves << value
65
- end
66
- end
67
-
68
- _leaves
69
- end
70
-
71
- def paths_and_leaves( path_so_far = [], _paths_and_leaves = Set.new )
72
- each do |key, value|
73
- if value.respond_to?( :paths_and_leaves )
74
- _paths_and_leaves.merge(
75
- value.paths_and_leaves(
76
- path_so_far + [ key ],
77
- _paths_and_leaves
78
- )
79
- )
80
- else
81
- _paths_and_leaves << {
82
- :path => path_so_far + [ key ],
83
- :leaf => value
84
- }
85
- end
86
- end
87
-
88
- _paths_and_leaves
89
- end
90
-
91
- def each_path_and_leaf( path_so_far = [] )
92
- each do |key, value|
93
- if value.respond_to?( :each_path_and_leaf )
94
- value.each_path_and_leaf( path_so_far + [ key ] ) { |path, leaf| yield( path, leaf ) }
95
- else
96
- yield( path_so_far + [ key ], value )
97
- end
98
- end
99
- end
100
-
101
- # Implement Ruby 1.9's Hash#key for Ruby 1.8
102
- if ! method_defined?( :key )
103
- def key( *args )
104
- index( *args )
105
- end
106
- end
107
- end
108
-
@@ -1,92 +0,0 @@
1
- module Diakonos
2
- class Diakonos
3
- def init_help
4
- @base_help_dir = "#{@diakonos_home}/help"
5
- mkdir @base_help_dir
6
-
7
- @help_dir = "#{@diakonos_home}/help/#{VERSION}"
8
- if not File.exist?( @help_dir ) or Dir[ "#{@help_dir}/*" ].size == 0
9
- if @testing
10
- `cp -r ./help #{@help_dir}`
11
- else
12
- puts "Help files for this Diakonos version were not found (#{@help_dir})."
13
- puts "Would you like to download the help files right now from the Diakonos website? (y/n)"
14
- answer = $stdin.gets
15
- case answer
16
- when /^y/i
17
- if not fetch_help
18
- $stderr.puts "Failed to get help for version #{VERSION}."
19
- sleep 2
20
- end
21
- end
22
- end
23
- end
24
-
25
- @help_tags = `grep -h Tags #{@help_dir}/* | cut -d ' ' -f 2-`.split.uniq
26
- end
27
-
28
- def fetch_help
29
- require 'open-uri'
30
- success = false
31
- puts "Fetching help documents for version #{VERSION}..."
32
-
33
- filename = "diakonos-help-#{VERSION}.tar.gz"
34
- uri = "http://purepistos.net/diakonos/#{filename}"
35
- tarball = "#{@base_help_dir}/#{filename}"
36
- begin
37
- open( uri ) do |http|
38
- bytes = http.read
39
- File.open( tarball, 'w' ) do |f|
40
- f.print bytes
41
- end
42
- end
43
- mkdir @help_dir
44
- `tar zxf #{tarball} -C #{@base_help_dir}`
45
- success = true
46
- rescue OpenURI::HTTPError => e
47
- $stderr.puts "Failed to fetch from #{uri} ."
48
- end
49
-
50
- success
51
- end
52
-
53
- def open_help_buffer
54
- @help_buffer = openFile( @help_filename )
55
- end
56
- def close_help_buffer
57
- closeFile @help_buffer
58
- @help_buffer = nil
59
- end
60
-
61
- def matching_help_documents( str )
62
- docs = []
63
-
64
- if str =~ %r{^/(.+)$}
65
- regexp = $1
66
- files = Dir[ "#{@help_dir}/*" ].select{ |f|
67
- File.open( f ) { |io| io.grep( /#{regexp}/i ) }.any?
68
- }
69
- else
70
- terms = str.gsub( /[^a-zA-Z0-9-]/, ' ' ).split.join( '|' )
71
- file_grep = `egrep -i -l '^Tags.*\\b(#{terms})\\b' #{@help_dir}/*`
72
- files = file_grep.split( /\s+/ )
73
- end
74
-
75
- files.each do |file|
76
- File.open( file ) do |f|
77
- docs << ( "%-300s | %s" % [ f.gets.strip, file ] )
78
- end
79
- end
80
-
81
- docs.sort { |a,b| a.gsub( /^# (?:an?|the) */i, '# ' ) <=> b.gsub( /^# (?:an?|the) */i, '# ' ) }
82
- end
83
-
84
- def open_help_document( selected_string )
85
- help_file = selected_string.split( "| " )[ -1 ]
86
- if File.exist? help_file
87
- openFile help_file
88
- end
89
- end
90
-
91
- end
92
- end
@@ -1,13 +0,0 @@
1
- module Diakonos
2
- class Diakonos
3
- def register_proc( the_proc, hook_name, priority = 0 )
4
- @hooks[ hook_name ] << { :proc => the_proc, :priority => priority }
5
- end
6
-
7
- def runHookProcs( hook_id, *args )
8
- @hooks[ hook_id ].each do |hook_proc|
9
- hook_proc[ :proc ].call( *args )
10
- end
11
- end
12
- end
13
- end
@@ -1,139 +0,0 @@
1
- module Diakonos
2
-
3
- TAB = 9
4
- ENTER = 13
5
- ESCAPE = 27
6
- BACKSPACE = 127
7
- CTRL_C = 3
8
- CTRL_D = 4
9
- CTRL_K = 11
10
- CTRL_Q = 17
11
- CTRL_H = 263
12
- RESIZE2 = 4294967295
13
-
14
- DO_COMPLETE = true
15
- DONT_COMPLETE = false
16
-
17
- CHOICE_NO = 0
18
- CHOICE_YES = 1
19
- CHOICE_ALL = 2
20
- CHOICE_CANCEL = 3
21
- CHOICE_YES_TO_ALL = 4
22
- CHOICE_NO_TO_ALL = 5
23
- CHOICE_YES_AND_STOP = 6
24
- CHOICE_DELETE = 7
25
- CHOICE_KEYS = [
26
- [ "n".ord, "N".ord ],
27
- [ "y".ord, "Y".ord ],
28
- [ "a".ord, "A".ord ],
29
- [ "c".ord, "C".ord, ESCAPE, CTRL_C, CTRL_D, CTRL_Q ],
30
- [ "e".ord ],
31
- [ "o".ord ],
32
- [ "s".ord ],
33
- [ "d".ord ],
34
- ]
35
- CHOICE_STRINGS = [ '(n)o', '(y)es', '(a)ll', '(c)ancel', 'y(e)s to all', 'n(o) to all', 'yes and (s)top', '(d)elete' ]
36
-
37
- class Diakonos
38
- # completion_array is the array of strings that tab completion can use
39
- def getUserInput( prompt, history = @rlh_general, initial_text = "", completion_array = nil, do_complete = DONT_COMPLETE, on_dirs = :go_into_dirs, &block )
40
- if @playing_macro
41
- retval = @macro_input_history.shift
42
- else
43
- retval = Readline.new( self, @win_interaction, prompt, initial_text, completion_array, history, do_complete, on_dirs, &block ).readline
44
- if @macro_history
45
- @macro_input_history.push retval
46
- end
47
- setILine
48
- end
49
- retval
50
- end
51
-
52
- def interactionBlink( message = nil )
53
- terminateMessage
54
- setILine @settings[ 'interaction.blink_string' ]
55
- sleep @settings[ 'interaction.blink_duration' ]
56
- setILine message if message
57
- end
58
-
59
- # choices should be an array of CHOICE_* constants.
60
- # default is what is returned when Enter is pressed.
61
- def getChoice( prompt, choices, default = nil )
62
- retval = @iterated_choice
63
- if retval
64
- @choice_iterations -= 1
65
- if @choice_iterations < 1
66
- @iterated_choice = nil
67
- @do_display = true
68
- end
69
- return retval
70
- end
71
-
72
- @saved_main_x = @win_main.curx
73
- @saved_main_y = @win_main.cury
74
-
75
- msg = prompt + " "
76
- choice_strings = choices.collect do |choice|
77
- CHOICE_STRINGS[ choice ]
78
- end
79
- msg << choice_strings.join( ", " )
80
-
81
- if default.nil?
82
- showMessage msg
83
- else
84
- setILine msg
85
- end
86
-
87
- c = nil
88
- while retval.nil?
89
- c = @win_interaction.getch.ord
90
-
91
- case c
92
- when Curses::KEY_NPAGE
93
- pageDown
94
- when Curses::KEY_PPAGE
95
- pageUp
96
- else
97
- if @message_expiry and Time.now < @message_expiry
98
- interactionBlink
99
- showMessage msg
100
- else
101
- case c
102
- when ENTER
103
- retval = default
104
- when ?0..?9
105
- if @choice_iterations < 1
106
- @choice_iterations = ( c - ?0 )
107
- else
108
- @choice_iterations = @choice_iterations * 10 + ( c - ?0 )
109
- end
110
- else
111
- choices.each do |choice|
112
- if CHOICE_KEYS[ choice ].include? c
113
- retval = choice
114
- break
115
- end
116
- end
117
- end
118
-
119
- if retval.nil?
120
- interactionBlink( msg )
121
- end
122
- end
123
- end
124
- end
125
-
126
- terminateMessage
127
- setILine
128
-
129
- if @choice_iterations > 0
130
- @choice_iterations -= 1
131
- @iterated_choice = retval
132
- @do_display = false
133
- end
134
-
135
- retval
136
- end
137
-
138
- end
139
- end
@@ -1,110 +0,0 @@
1
- module Diakonos
2
-
3
- module KeyCode
4
- KEYSTRINGS = [
5
- "ctrl+space", # 0
6
- "ctrl+a", # 1
7
- "ctrl+b", # 2
8
- "ctrl+c", # 3
9
- "ctrl+d", # 4
10
- "ctrl+e", # 5
11
- "ctrl+f", # 6
12
- "ctrl+g", # 7
13
- nil, # 8
14
- "tab", # 9
15
- "ctrl+j", # 10
16
- "ctrl+k", # 11
17
- "ctrl+l", # 12
18
- "enter", # 13
19
- "ctrl+n", # 14
20
- "ctrl+o", # 15
21
- "ctrl+p", # 16
22
- "ctrl+q", # 17
23
- "ctrl+r", # 18
24
- "ctrl+s", # 19
25
- "ctrl+t", # 20
26
- "ctrl+u", # 21
27
- "ctrl+v", # 22
28
- "ctrl+w", # 23
29
- "ctrl+x", # 24
30
- "ctrl+y", # 25
31
- "ctrl+z", # 26
32
- "esc", # 27
33
- nil, # 28
34
- nil, # 29
35
- nil, # 30
36
- nil, # 31
37
- "space", # 32
38
- 33.chr, 34.chr, 35.chr, 36.chr, 37.chr, 38.chr, 39.chr,
39
- 40.chr, 41.chr, 42.chr, 43.chr, 44.chr, 45.chr, 46.chr, 47.chr, 48.chr, 49.chr,
40
- 50.chr, 51.chr, 52.chr, 53.chr, 54.chr, 55.chr, 56.chr, 57.chr, 58.chr, 59.chr,
41
- 60.chr, 61.chr, 62.chr, 63.chr, 64.chr, 65.chr, 66.chr, 67.chr, 68.chr, 69.chr,
42
- 70.chr, 71.chr, 72.chr, 73.chr, 74.chr, 75.chr, 76.chr, 77.chr, 78.chr, 79.chr,
43
- 80.chr, 81.chr, 82.chr, 83.chr, 84.chr, 85.chr, 86.chr, 87.chr, 88.chr, 89.chr,
44
- 90.chr, 91.chr, 92.chr, 93.chr, 94.chr, 95.chr, 96.chr, 97.chr, 98.chr, 99.chr,
45
- 100.chr, 101.chr, 102.chr, 103.chr, 104.chr, 105.chr, 106.chr, 107.chr, 108.chr, 109.chr,
46
- 110.chr, 111.chr, 112.chr, 113.chr, 114.chr, 115.chr, 116.chr, 117.chr, 118.chr, 119.chr,
47
- 120.chr, 121.chr, 122.chr, 123.chr, 124.chr, 125.chr, 126.chr,
48
- "backspace" # 127
49
- ]
50
-
51
- def keyString
52
- if self.class == Fixnum
53
- retval = KEYSTRINGS[ self ]
54
- end
55
- if retval.nil?
56
- case self
57
- when Curses::KEY_DOWN
58
- retval = "down"
59
- when Curses::KEY_UP
60
- retval = "up"
61
- when Curses::KEY_LEFT
62
- retval = "left"
63
- when Curses::KEY_RIGHT
64
- retval = "right"
65
- when Curses::KEY_HOME
66
- retval = "home"
67
- when Curses::KEY_END
68
- retval = "end"
69
- when Curses::KEY_IC
70
- retval = "insert"
71
- when Curses::KEY_DC
72
- retval = "delete"
73
- when Curses::KEY_PPAGE
74
- retval = "page-up"
75
- when Curses::KEY_NPAGE
76
- retval = "page-down"
77
- when Curses::KEY_A1
78
- retval = "numpad7"
79
- when Curses::KEY_A3
80
- retval = "numpad9"
81
- when Curses::KEY_B2
82
- retval = "numpad5"
83
- when Curses::KEY_C1
84
- retval = "numpad1"
85
- when Curses::KEY_C3
86
- retval = "numpad3"
87
- when Curses::KEY_FIND
88
- retval = "find"
89
- when Curses::KEY_SELECT
90
- retval = "select"
91
- when Curses::KEY_SUSPEND
92
- retval = "suspend"
93
- when Curses::KEY_F0..(Curses::KEY_F0 + 24)
94
- retval = "f" + (self - Curses::KEY_F0).to_s
95
- when CTRL_H
96
- retval = "ctrl+h"
97
- when Curses::KEY_RESIZE
98
- retval = "resize"
99
- when RESIZE2
100
- retval = "resize2"
101
- end
102
- end
103
- if retval.nil? and self.class == Fixnum
104
- retval = "keycode#{self}"
105
- end
106
- retval
107
- end
108
- end
109
-
110
- end