diakonos 0.8.4 → 0.8.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +15 -0
- data/LICENCE +21 -0
- data/bin/diakonos +0 -0
- data/diakonos-256-colour.conf +93 -0
- data/diakonos.conf +27 -2
- data/lib/diakonos.rb +182 -83
- data/lib/diakonos/buffer.rb +199 -139
- data/lib/diakonos/clipboard.rb +24 -24
- data/lib/diakonos/finding.rb +1 -1
- data/test/buffer-test.rb +46 -30
- data/test/clipboard-test.rb +0 -0
- data/test/diakonos-test.rb +0 -0
- data/test/regexp-test.rb +0 -0
- data/test/sizedarray-test.rb +0 -0
- data/test/string-test.rb +0 -0
- metadata +12 -9
data/lib/diakonos/clipboard.rb
CHANGED
@@ -1,33 +1,33 @@
|
|
1
1
|
module Diakonos
|
2
|
-
|
3
|
-
class Clipboard
|
2
|
+
|
3
|
+
class Clipboard
|
4
4
|
def initialize( max_clips )
|
5
|
-
|
6
|
-
|
5
|
+
@clips = Array.new
|
6
|
+
@max_clips = max_clips
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
def [] ( arg )
|
10
|
-
|
10
|
+
return @clips[ arg ]
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
def clip
|
14
|
-
|
14
|
+
return @clips[ 0 ]
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
# text is an array of Strings
|
18
18
|
# Returns true iff a clip was added,
|
19
19
|
# and only non-nil text can be added.
|
20
20
|
def addClip( text )
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
return false if text == nil
|
22
|
+
@clips.unshift text
|
23
|
+
@clips.pop if @clips.length > @max_clips
|
24
|
+
true
|
25
25
|
end
|
26
26
|
|
27
27
|
def each
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
@clips.each do |clip|
|
29
|
+
yield clip
|
30
|
+
end
|
31
31
|
end
|
32
32
|
|
33
33
|
# text is an array of Strings (lines)
|
@@ -35,13 +35,13 @@ class Clipboard
|
|
35
35
|
# If no current clip, then a new clip is created.
|
36
36
|
# Returns true iff the text was successfully appended.
|
37
37
|
def appendToClip( text )
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
38
|
+
return false if text.nil?
|
39
|
+
return addClip( 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
|
+
return true
|
44
44
|
end
|
45
|
-
end
|
46
|
-
|
45
|
+
end
|
46
|
+
|
47
47
|
end
|
data/lib/diakonos/finding.rb
CHANGED
data/test/buffer-test.rb
CHANGED
@@ -4,34 +4,50 @@ require 'test/unit'
|
|
4
4
|
require 'diakonos'
|
5
5
|
|
6
6
|
class TC_Buffer < Test::Unit::TestCase
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
7
|
+
SAMPLE_FILE = File.dirname( File.expand_path( __FILE__ ) ) + '/sample-file.rb'
|
8
|
+
|
9
|
+
def setup
|
10
|
+
@d = Diakonos::Diakonos.new [ '-e', 'quit' ]
|
11
|
+
@d.start
|
12
|
+
end
|
13
|
+
|
14
|
+
def teardown
|
15
|
+
system "reset"
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_selected_text
|
19
|
+
@d.openFile( SAMPLE_FILE )
|
20
|
+
b = Diakonos::Buffer.new( @d, SAMPLE_FILE, SAMPLE_FILE )
|
21
|
+
@d.anchorSelection
|
22
|
+
@d.cursorDown
|
23
|
+
@d.cursorDown
|
24
|
+
@d.cursorDown
|
25
|
+
@d.copySelection
|
26
|
+
assert_equal(
|
27
|
+
[
|
28
|
+
"#!/usr/bin/env ruby",
|
29
|
+
"",
|
30
|
+
"# This is only a sample file used in the tests.",
|
31
|
+
""
|
32
|
+
],
|
33
|
+
@d.clipboard.clip
|
34
|
+
)
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_replace
|
38
|
+
@d.openFile SAMPLE_FILE
|
39
|
+
b = Diakonos::Buffer.new( @d, SAMPLE_FILE, SAMPLE_FILE )
|
40
|
+
b.find( [ /only/ ], :down, "\\2", Diakonos::CHOICE_YES_AND_STOP )
|
41
|
+
assert_equal "# This is a sample file used in the tests.", b[ 2 ]
|
42
|
+
b.find( [ /\bx\b/ ], :down, "\\0_", Diakonos::CHOICE_YES_AND_STOP )
|
43
|
+
assert_equal " @x_ = 1", b[ 6 ]
|
44
|
+
b.find( [ /\b(y)\b/ ], :down, "\\1_", Diakonos::CHOICE_YES_AND_STOP )
|
45
|
+
assert_equal " @y_ = 2", b[ 7 ]
|
46
|
+
b.find( [ /puts (\w+)/ ], :down, "print \\1", Diakonos::CHOICE_YES_AND_STOP )
|
47
|
+
assert_equal " print x", b[ 11 ]
|
48
|
+
b.find( [ /puts (\w+)/ ], :down, "puts \\1, \\1, \\1", Diakonos::CHOICE_YES_AND_STOP )
|
49
|
+
assert_equal " puts y, y, y", b[ 12 ]
|
50
|
+
b.find( [ /Sample\.(\w+)/ ], :down, "\\1\\\\\\1", Diakonos::CHOICE_YES_AND_STOP )
|
51
|
+
assert_equal "s = new\\new", b[ 16 ]
|
52
|
+
end
|
37
53
|
end
|
data/test/clipboard-test.rb
CHANGED
File without changes
|
data/test/diakonos-test.rb
CHANGED
File without changes
|
data/test/regexp-test.rb
CHANGED
File without changes
|
data/test/sizedarray-test.rb
CHANGED
File without changes
|
data/test/string-test.rb
CHANGED
File without changes
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: diakonos
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
5
|
-
platform:
|
4
|
+
version: 0.8.5
|
5
|
+
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pistos
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-10-03 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -22,20 +22,21 @@ extensions: []
|
|
22
22
|
extra_rdoc_files:
|
23
23
|
- README
|
24
24
|
- CHANGELOG
|
25
|
+
- LICENCE
|
25
26
|
files:
|
26
27
|
- CHANGELOG
|
27
28
|
- README
|
29
|
+
- LICENCE
|
28
30
|
- home-on-save.rb
|
29
31
|
- diakonos.conf
|
32
|
+
- diakonos-256-colour.conf
|
30
33
|
- bin/diakonos
|
31
34
|
- lib/diakonos.rb
|
32
35
|
- lib/diakonos/bignum.rb
|
33
36
|
- lib/diakonos/bookmark.rb
|
34
37
|
- lib/diakonos/buffer-hash.rb
|
35
|
-
- lib/diakonos/clipboard.rb
|
36
38
|
- lib/diakonos/ctag.rb
|
37
39
|
- lib/diakonos/enumerable.rb
|
38
|
-
- lib/diakonos/finding.rb
|
39
40
|
- lib/diakonos/fixnum.rb
|
40
41
|
- lib/diakonos/hash.rb
|
41
42
|
- lib/diakonos/keycode.rb
|
@@ -46,8 +47,10 @@ files:
|
|
46
47
|
- lib/diakonos/window.rb
|
47
48
|
- lib/diakonos/array.rb
|
48
49
|
- lib/diakonos/readline.rb
|
49
|
-
- lib/diakonos/buffer.rb
|
50
50
|
- lib/diakonos/string.rb
|
51
|
+
- lib/diakonos/clipboard.rb
|
52
|
+
- lib/diakonos/finding.rb
|
53
|
+
- lib/diakonos/buffer.rb
|
51
54
|
has_rdoc: false
|
52
55
|
homepage: http://purepistos.net/diakonos
|
53
56
|
post_install_message:
|
@@ -70,15 +73,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
70
73
|
requirements:
|
71
74
|
- curses library for Ruby (not in default Ruby install on Debian or FreeBSD; not sufficiently implemented on Windows)
|
72
75
|
rubyforge_project: diakonos
|
73
|
-
rubygems_version:
|
76
|
+
rubygems_version: 1.2.0
|
74
77
|
signing_key:
|
75
78
|
specification_version: 2
|
76
|
-
summary: A
|
79
|
+
summary: A Linux editor for the masses.
|
77
80
|
test_files:
|
78
|
-
- test/buffer-test.rb
|
79
81
|
- test/clipboard-test.rb
|
80
82
|
- test/diakonos-test.rb
|
81
83
|
- test/hash-test.rb
|
82
84
|
- test/regexp-test.rb
|
83
85
|
- test/sizedarray-test.rb
|
84
86
|
- test/string-test.rb
|
87
|
+
- test/buffer-test.rb
|