diakonos 0.8.8 → 0.9.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG +433 -0
  3. data/LICENCE.md +675 -0
  4. data/bin/diakonos +6 -0
  5. data/diakonos-256-colour.conf +220 -0
  6. data/diakonos.conf +1802 -0
  7. data/help/about-help.dhf +31 -0
  8. data/help/clipboard.dhf +45 -0
  9. data/help/close-file.dhf +6 -0
  10. data/help/code-block-navigation.dhf +16 -0
  11. data/help/column-markers.dhf +15 -0
  12. data/help/config.dhf +69 -0
  13. data/help/cursor-stack.dhf +19 -0
  14. data/help/delete.dhf +41 -0
  15. data/help/extensions.dhf +125 -0
  16. data/help/file-type.dhf +24 -0
  17. data/help/key-mapping.dhf +127 -0
  18. data/help/line-numbers.dhf +22 -0
  19. data/help/macros.dhf +27 -0
  20. data/help/new-file.dhf +6 -0
  21. data/help/open-file.dhf +21 -0
  22. data/help/quit.dhf +7 -0
  23. data/help/resizing.dhf +19 -0
  24. data/help/ruby.dhf +17 -0
  25. data/help/save-file.dhf +10 -0
  26. data/help/scripting.dhf +92 -0
  27. data/help/search.dhf +103 -0
  28. data/help/shell.dhf +60 -0
  29. data/help/speed.dhf +23 -0
  30. data/help/support.dhf +15 -0
  31. data/help/switch-buffers.dhf +15 -0
  32. data/help/tabs.dhf +36 -0
  33. data/help/undo.dhf +9 -0
  34. data/help/uninstall.dhf +18 -0
  35. data/help/welcome.dhf +32 -0
  36. data/help/word-wrap.dhf +17 -0
  37. data/lib/diakonos/about.rb +69 -0
  38. data/lib/diakonos/bookmark.rb +46 -0
  39. data/lib/diakonos/buffer/bookmarking.rb +47 -0
  40. data/lib/diakonos/buffer/cursor.rb +335 -0
  41. data/lib/diakonos/buffer/delete.rb +170 -0
  42. data/lib/diakonos/buffer/display.rb +356 -0
  43. data/lib/diakonos/buffer/file.rb +157 -0
  44. data/lib/diakonos/buffer/indentation.rb +175 -0
  45. data/lib/diakonos/buffer/searching.rb +552 -0
  46. data/lib/diakonos/buffer/selection.rb +360 -0
  47. data/lib/diakonos/buffer/undo.rb +73 -0
  48. data/lib/diakonos/buffer-hash.rb +60 -0
  49. data/lib/diakonos/buffer-management.rb +59 -0
  50. data/lib/diakonos/buffer.rb +698 -0
  51. data/lib/diakonos/clipboard-klipper-dbus.rb +62 -0
  52. data/lib/diakonos/clipboard-klipper.rb +62 -0
  53. data/lib/diakonos/clipboard-osx.rb +59 -0
  54. data/lib/diakonos/clipboard-xclip.rb +60 -0
  55. data/lib/diakonos/clipboard.rb +47 -0
  56. data/lib/diakonos/config-file.rb +67 -0
  57. data/lib/diakonos/config.rb +381 -0
  58. data/lib/diakonos/core-ext/enumerable.rb +15 -0
  59. data/lib/diakonos/core-ext/hash.rb +60 -0
  60. data/lib/diakonos/core-ext/object.rb +6 -0
  61. data/lib/diakonos/core-ext/regexp.rb +6 -0
  62. data/lib/diakonos/core-ext/string.rb +122 -0
  63. data/lib/diakonos/ctag.rb +28 -0
  64. data/lib/diakonos/cursor.rb +27 -0
  65. data/lib/diakonos/display/format.rb +75 -0
  66. data/lib/diakonos/display.rb +336 -0
  67. data/lib/diakonos/extension-set.rb +49 -0
  68. data/lib/diakonos/extension.rb +34 -0
  69. data/lib/diakonos/finding.rb +40 -0
  70. data/lib/diakonos/functions/basics.rb +34 -0
  71. data/lib/diakonos/functions/bookmarking.rb +61 -0
  72. data/lib/diakonos/functions/buffers.rb +489 -0
  73. data/lib/diakonos/functions/clipboard.rb +70 -0
  74. data/lib/diakonos/functions/cursor.rb +264 -0
  75. data/lib/diakonos/functions/grepping.rb +83 -0
  76. data/lib/diakonos/functions/indentation.rb +71 -0
  77. data/lib/diakonos/functions/readline.rb +93 -0
  78. data/lib/diakonos/functions/search.rb +179 -0
  79. data/lib/diakonos/functions/selection.rb +98 -0
  80. data/lib/diakonos/functions/sessions.rb +78 -0
  81. data/lib/diakonos/functions/shell.rb +250 -0
  82. data/lib/diakonos/functions/tags.rb +65 -0
  83. data/lib/diakonos/functions/text-manipulation.rb +196 -0
  84. data/lib/diakonos/functions-deprecated.rb +77 -0
  85. data/lib/diakonos/functions.rb +292 -0
  86. data/lib/diakonos/grep.rb +98 -0
  87. data/lib/diakonos/help.rb +47 -0
  88. data/lib/diakonos/hooks.rb +13 -0
  89. data/lib/diakonos/installation.rb +19 -0
  90. data/lib/diakonos/interaction-handler.rb +216 -0
  91. data/lib/diakonos/interaction.rb +52 -0
  92. data/lib/diakonos/key-map.rb +62 -0
  93. data/lib/diakonos/keying.rb +442 -0
  94. data/lib/diakonos/line-mover.rb +42 -0
  95. data/lib/diakonos/list.rb +59 -0
  96. data/lib/diakonos/logging.rb +27 -0
  97. data/lib/diakonos/mode.rb +17 -0
  98. data/lib/diakonos/mouse.rb +18 -0
  99. data/lib/diakonos/number-fitter.rb +11 -0
  100. data/lib/diakonos/range.rb +31 -0
  101. data/lib/diakonos/readline/functions.rb +82 -0
  102. data/lib/diakonos/readline.rb +222 -0
  103. data/lib/diakonos/search.rb +58 -0
  104. data/lib/diakonos/sessions.rb +257 -0
  105. data/lib/diakonos/sized-array.rb +48 -0
  106. data/lib/diakonos/text-mark.rb +19 -0
  107. data/lib/diakonos/vendor/fuzzy_file_finder.rb +365 -0
  108. data/lib/diakonos/version.rb +25 -0
  109. data/lib/diakonos/window.rb +43 -0
  110. data/lib/diakonos.rb +592 -0
  111. metadata +160 -66
@@ -0,0 +1,62 @@
1
+ module Diakonos
2
+
3
+ # Same interface as Diakonos::Clipboard, except interacts with Klipper in KDE4 (via dbus)
4
+ class ClipboardKlipperDBus
5
+
6
+ def initialize
7
+ end
8
+
9
+ # Returns true iff some text was copied to klipper.
10
+ def send_to_klipper( text )
11
+ return false if text.nil?
12
+
13
+ clip_filename = write_to_clip_file( text.join( "\n" ) )
14
+
15
+ # A little shell sorcery to ensure the shell doesn't strip off trailing newlines.
16
+ `clipping=$(cat #{clip_filename};printf "_"); dbus-send --type=method_call --dest=org.kde.klipper /klipper org.kde.klipper.klipper.setClipboardContents string:"${clipping%_}"`
17
+ true
18
+ end
19
+
20
+ def write_to_clip_file( text )
21
+ clip_filename = $diakonos.diakonos_home + "/clip.txt"
22
+ File.open( clip_filename, "w" ) do |f|
23
+ f.print text
24
+ end
25
+ clip_filename
26
+ end
27
+
28
+ # ------------------------------
29
+
30
+ def clip
31
+ text = `dbus-send --print-reply --dest=org.kde.klipper /klipper org.kde.klipper.klipper.getClipboardContents | awk 'BEGIN { output = ""; } { if ( NR > 1 ) { output = output $0 "\\n"; } } END { print substr(output, 12, length(output) - 13); }'`.split( "\n", -1 )
32
+ # getClipboardContents puts an extra newline on end; pop it off.
33
+ text.pop
34
+ text
35
+ end
36
+
37
+ # text is an array of Strings
38
+ # Returns true iff a clip was added,
39
+ # and only non-nil text can be added.
40
+ def add_clip( text )
41
+ return false if text.nil?
42
+ send_to_klipper text
43
+ end
44
+
45
+ # no-op.
46
+ def each
47
+ end
48
+
49
+ # text is an array of Strings (lines)
50
+ # Appends the lines to the current clip.
51
+ # If no current clip, then a new clip is created.
52
+ # Returns true iff the text was successfully appended.
53
+ def append_to_clip( text )
54
+ return false if text.nil?
55
+
56
+ last_clip = clip
57
+ last_clip.pop if last_clip[ -1 ] == ""
58
+ send_to_klipper last_clip + text
59
+ end
60
+ end
61
+
62
+ end
@@ -0,0 +1,62 @@
1
+ module Diakonos
2
+
3
+ # Same interface as Diakonos::Clipboard, except interacts with Klipper in KDE 3 (via dcop)
4
+ class ClipboardKlipper
5
+
6
+ def initialize
7
+ end
8
+
9
+ # Returns true iff some text was copied to klipper.
10
+ def send_to_klipper( text )
11
+ return false if text.nil?
12
+
13
+ clip_filename = write_to_clip_file( text.join( "\n" ) )
14
+
15
+ # A little shell sorcery to ensure the shell doesn't strip off trailing newlines.
16
+ `clipping=$(cat #{clip_filename};printf "_"); dcop klipper klipper setClipboardContents "${clipping%_}"`
17
+ true
18
+ end
19
+
20
+ def write_to_clip_file( text )
21
+ clip_filename = $diakonos.diakonos_home + "/clip.txt"
22
+ File.open( clip_filename, "w" ) do |f|
23
+ f.print text
24
+ end
25
+ clip_filename
26
+ end
27
+
28
+ # ------------------------------
29
+
30
+ def clip
31
+ text = `dcop klipper klipper getClipboardContents`.split( "\n", -1 )
32
+ # getClipboardContents puts an extra newline on end; pop it off.
33
+ text.pop
34
+ text
35
+ end
36
+
37
+ # text is an array of Strings
38
+ # Returns true iff a clip was added,
39
+ # and only non-nil text can be added.
40
+ def add_clip( text )
41
+ return false if text.nil?
42
+ send_to_klipper text
43
+ end
44
+
45
+ # no-op.
46
+ def each
47
+ end
48
+
49
+ # text is an array of Strings (lines)
50
+ # Appends the lines to the current clip.
51
+ # If no current clip, then a new clip is created.
52
+ # Returns true iff the text was successfully appended.
53
+ def append_to_clip( text )
54
+ return false if text.nil?
55
+
56
+ last_clip = clip
57
+ last_clip.pop if last_clip[ -1 ] == ""
58
+ send_to_klipper last_clip + text
59
+ end
60
+ end
61
+
62
+ end
@@ -0,0 +1,59 @@
1
+ module Diakonos
2
+
3
+ # Same interface as Diakonos::Clipboard, except interacts with pbcopy and
4
+ # pbpaste on OSX
5
+ class ClipboardOSX
6
+
7
+ def initialize
8
+ end
9
+
10
+ # @return true iff some text was copied to pbcopy
11
+ def send_to_pbcopy(text)
12
+ return false if text.nil?
13
+
14
+ clip_filename = write_to_clip_file( text.join( "\n" ) )
15
+ `pbcopy < #{clip_filename}`
16
+
17
+ true
18
+ end
19
+
20
+ # TODO: DRY this up with other Clipboard classes
21
+ def write_to_clip_file(text)
22
+ clip_filename = $diakonos.diakonos_home + "/clip.txt"
23
+ File.open( clip_filename, "w" ) do |f|
24
+ f.print text
25
+ end
26
+ clip_filename
27
+ end
28
+
29
+ # ------------------------------
30
+
31
+ def clip
32
+ `pbpaste`.split( "\n", -1 )
33
+ end
34
+
35
+ # @param [Array<String>] text
36
+ # @return true iff a clip was added
37
+ def add_clip(text)
38
+ send_to_pbcopy text
39
+ end
40
+
41
+ # no-op
42
+ def each
43
+ end
44
+
45
+ # @param [Array<String>] lines of text
46
+ # Appends the lines to the current clip.
47
+ # If no current clip, then a new clip is created.
48
+ # @return true iff the text was successfully appended
49
+ def append_to_clip(text)
50
+ return false if text.nil?
51
+
52
+ last_clip = clip
53
+ last_clip.pop if last_clip[-1] == ""
54
+
55
+ send_to_pbcopy last_clip + text
56
+ end
57
+ end
58
+
59
+ end
@@ -0,0 +1,60 @@
1
+ module Diakonos
2
+
3
+ # Same interface as Diakonos::Clipboard, except interacts with xclip
4
+ class ClipboardXClip
5
+
6
+ def initialize
7
+ end
8
+
9
+ # Returns true iff some text was copied to xclip.
10
+ def send_to_xclip( text )
11
+ return false if text.nil?
12
+ clip_filename = write_to_clip_file( text.join( "\n" ) )
13
+ t = Thread.new do
14
+ `xclip -i #{clip_filename}`
15
+ end
16
+ `xclip -o` # Unfreeze xclip
17
+ t.terminate
18
+ true
19
+ end
20
+
21
+ def write_to_clip_file( text )
22
+ clip_filename = $diakonos.diakonos_home + "/clip.txt"
23
+ File.open( clip_filename, "w" ) do |f|
24
+ f.print text
25
+ end
26
+ clip_filename
27
+ end
28
+
29
+ # ------------------------------
30
+
31
+ def clip
32
+ `xclip -o`.split( "\n", -1 )
33
+ end
34
+
35
+ # text is an array of Strings
36
+ # Returns true iff a clip was added,
37
+ # and only non-nil text can be added.
38
+ def add_clip( text )
39
+ return false if text.nil?
40
+ send_to_xclip text
41
+ end
42
+
43
+ # no-op.
44
+ def each
45
+ end
46
+
47
+ # text is an array of Strings (lines)
48
+ # Appends the lines to the current clip.
49
+ # If no current clip, then a new clip is created.
50
+ # Returns true iff the text was successfully appended.
51
+ def append_to_clip( text )
52
+ return false if text.nil?
53
+
54
+ last_clip = clip
55
+ last_clip.pop if last_clip[ -1 ] == ""
56
+ send_to_xclip last_clip + text
57
+ end
58
+ end
59
+
60
+ end
@@ -0,0 +1,47 @@
1
+ module Diakonos
2
+
3
+ class Clipboard
4
+ def initialize( max_clips )
5
+ @clips = Array.new
6
+ @max_clips = max_clips
7
+ end
8
+
9
+ def [] ( arg )
10
+ @clips[ arg ]
11
+ end
12
+
13
+ def clip
14
+ @clips[ 0 ]
15
+ end
16
+
17
+ # text is an array of Strings
18
+ # Returns true iff a clip was added,
19
+ # and only non-nil text can be added.
20
+ def add_clip( text )
21
+ return false if text.nil?
22
+ @clips.unshift text
23
+ @clips.pop if @clips.length > @max_clips
24
+ true
25
+ end
26
+
27
+ def each
28
+ @clips.each do |clip|
29
+ yield clip
30
+ end
31
+ end
32
+
33
+ # text is an array of Strings (lines)
34
+ # Appends the lines to the current clip.
35
+ # If no current clip, then a new clip is created.
36
+ # Returns true iff the text was successfully appended.
37
+ def append_to_clip( text )
38
+ return false if text.nil?
39
+ return add_clip( text ) if @clips.length == 0
40
+ last_clip = @clips[ 0 ]
41
+ last_clip.pop if last_clip[ -1 ] == ""
42
+ @clips[ 0 ] = last_clip + text
43
+ true
44
+ end
45
+ end
46
+
47
+ end
@@ -0,0 +1,67 @@
1
+ module Diakonos
2
+ # Should inheritance be used in this file instead?
3
+
4
+ module ConfigFileDescription
5
+ def to_s
6
+ "#{@filename}\t(#{self.inclusion_description})"
7
+ end
8
+
9
+ def name_as_includer
10
+ @filename
11
+ end
12
+
13
+ def inclusion_description
14
+ "included by #{@including_config_file.name_as_includer}"
15
+ end
16
+ end
17
+
18
+ class ConfigFile
19
+ attr_reader :filename
20
+ attr_accessor :problems
21
+
22
+ include ConfigFileDescription
23
+
24
+ def initialize(filename, including_config_file)
25
+ @filename, @including_config_file = filename, including_config_file
26
+ @problems = []
27
+ end
28
+
29
+ def ==(other_config_file)
30
+ @filename == other_config_file.filename
31
+ end
32
+
33
+ def each_line_with_index
34
+ # TODO: Refactor line_number into index, then +1 before yielding
35
+ IO.readlines(@filename).each_with_index do |line, line_number|
36
+ line.chomp!
37
+ # Skip comments
38
+ next if line[0] == ?#
39
+
40
+ yield line, line_number
41
+ end
42
+ end
43
+ end
44
+
45
+ class ConfigFileUnreadable
46
+ include ConfigFileDescription
47
+
48
+ def initialize(filename, including_config_file)
49
+ @filename, @including_config_file = filename, including_config_file
50
+ end
51
+
52
+ def problems
53
+ ["Configuration file #{self} was not found"]
54
+ end
55
+
56
+ def each_line_with_index
57
+ end
58
+ end
59
+
60
+ class ConfigFileNull
61
+ include ConfigFileDescription
62
+
63
+ def name_as_includer
64
+ "Diakonos"
65
+ end
66
+ end
67
+ end