ansi-sys 0.7.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog +5 -0
- data/lib/ansisys.rb +20 -3
- data/spec/character_screen_spec.rb +18 -0
- data/website/index.html +8 -8
- metadata +2 -2
data/ChangeLog
CHANGED
data/lib/ansisys.rb
CHANGED
@@ -12,7 +12,7 @@ module AnsiSys
|
|
12
12
|
module VERSION #:nodoc:
|
13
13
|
MAJOR = 0
|
14
14
|
MINOR = 7
|
15
|
-
TINY =
|
15
|
+
TINY = 1
|
16
16
|
|
17
17
|
STRING = [MAJOR, MINOR, TINY].join('.')
|
18
18
|
end
|
@@ -101,6 +101,7 @@ module AnsiSys
|
|
101
101
|
def echo_on(screen, cursor)
|
102
102
|
each_char do |c|
|
103
103
|
w = width(c)
|
104
|
+
cursor.fit!(w)
|
104
105
|
screen.write(c, w, cursor.cur_col, cursor.cur_row, @sgr.dup)
|
105
106
|
cursor.advance!(w)
|
106
107
|
end
|
@@ -194,13 +195,29 @@ module AnsiSys
|
|
194
195
|
r = nil
|
195
196
|
@cur_col += width
|
196
197
|
if @cur_col > @max_col
|
198
|
+
line_feed!
|
199
|
+
r = "\n"
|
200
|
+
end
|
201
|
+
return r
|
202
|
+
end
|
203
|
+
|
204
|
+
# check if a character with _width_ fits within the maximum columns,
|
205
|
+
# feed a line if not
|
206
|
+
def fit!(width = 1)
|
207
|
+
r = nil
|
208
|
+
if @cur_col + width > @max_col + 1
|
209
|
+
line_feed!
|
197
210
|
r = "\n"
|
198
|
-
@cur_col = 1
|
199
|
-
@cur_row += 1
|
200
211
|
end
|
201
212
|
return r
|
202
213
|
end
|
203
214
|
|
215
|
+
# feed a line
|
216
|
+
def line_feed!
|
217
|
+
@cur_col = 1
|
218
|
+
@cur_row += 1
|
219
|
+
@max_row = @cur_row if @max_row and @cur_row > @max_row
|
220
|
+
end
|
204
221
|
end
|
205
222
|
|
206
223
|
# Select Graphic Rendition
|
@@ -30,3 +30,21 @@ _SCREEN
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
+
describe "Wide-characters echoed on right edge of a Screen" do
|
34
|
+
before do
|
35
|
+
$KCODE = 'u'
|
36
|
+
@string = "\346\227\245\346\234\254\350\252\236" # `Nihongo' in UTF-8
|
37
|
+
@char = Characters.new(@string, SGR.new)
|
38
|
+
@screen = Screen.new(Screen.default_css_colors, 3)
|
39
|
+
@cursor = Cursor.new(1, 1, 3)
|
40
|
+
@char.echo_on(@screen, @cursor)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should fit in the width" do
|
44
|
+
@screen.render(:text).should == <<_SCREEN.chomp
|
45
|
+
\346\227\245
|
46
|
+
\346\234\254
|
47
|
+
\350\252\236
|
48
|
+
_SCREEN
|
49
|
+
end
|
50
|
+
end
|
data/website/index.html
CHANGED
@@ -33,12 +33,9 @@
|
|
33
33
|
<h1>Ruby-ANSI.SYS</h1>
|
34
34
|
<div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/ansi-sys"; return false'>
|
35
35
|
<p>Get Version</p>
|
36
|
-
<a href="http://rubyforge.org/projects/ansi-sys" class="numbers">0.
|
36
|
+
<a href="http://rubyforge.org/projects/ansi-sys" class="numbers">0.7.1</a>
|
37
37
|
</div>
|
38
|
-
<
|
39
|
-
|
40
|
-
|
41
|
-
<h2>What</h2>
|
38
|
+
<h2>What</h2>
|
42
39
|
|
43
40
|
|
44
41
|
<p>MS-DOS console (with <code>DEVICE=ANSI.SYS</code>), Linux
|
@@ -85,9 +82,12 @@ misc/plugin directory and configure Hiki to enable the plugin.</p>
|
|
85
82
|
<p>As a Ruby library:</p>
|
86
83
|
|
87
84
|
|
88
|
-
<pre>
|
85
|
+
<pre>
|
86
|
+
require 'ansisys'
|
87
|
+
terminal = AnsiSys::Terminal.new
|
89
88
|
terminal.echo("ansi-escaped-text")
|
90
|
-
terminal.render #=> HTML fragment
|
89
|
+
terminal.render #=> HTML fragment
|
90
|
+
</pre>
|
91
91
|
|
92
92
|
<p>As a Hiki plugin:</p>
|
93
93
|
|
@@ -110,7 +110,7 @@ terminal.render #=> HTML fragment</pre>
|
|
110
110
|
<p>Please refer
|
111
111
|
<a href="rdoc/files/License_txt.html">License.txt</a></p>
|
112
112
|
<p class="coda">
|
113
|
-
zunda,
|
113
|
+
zunda, 3rd November 2007<br>
|
114
114
|
Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
|
115
115
|
</p>
|
116
116
|
</div>
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
|
|
3
3
|
specification_version: 1
|
4
4
|
name: ansi-sys
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.7.
|
7
|
-
date: 2007-11-
|
6
|
+
version: 0.7.1
|
7
|
+
date: 2007-11-16 00:00:00 -10:00
|
8
8
|
summary: Ruby-ANSI.SYS is a library to render texts with ANSI escape sequences.
|
9
9
|
require_paths:
|
10
10
|
- lib
|