ansi-sys 0.8.0 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,3 +1,9 @@
1
+ * 2007-11-18 zunda <zunda at freeshell.org>
2
+ - (0.8.1)
3
+ - lib/ansisys.rb: modified Characters#echo_on, Characters#each_char,
4
+ Terminal#render to take kcode as an argument
5
+ - bin/ansi-to-html: modified accordingly
6
+
1
7
  * 2007-11-16 zunda <zunda at freeshell.org>
2
8
  - (0.8.0)
3
9
  - bin/ansi-to-html: modified to guess character codes of the inputs
@@ -1,4 +1,8 @@
1
- == 0.8.0 2007-11-14
1
+ == 0.8.1 2007-11-18
2
+
3
+ * Modified Terminal#render to take kcode as another argument
4
+
5
+ == 0.8.0 2007-11-16
2
6
 
3
7
  * Added a command line interface: bin/ansi-to-html, really
4
8
  * Modified bin/ansi-to-html to guess input character codes
@@ -22,18 +22,16 @@ terminal = AnsiSys::Terminal.new
22
22
  # Print out the HTML while reading
23
23
  puts "<html>\n<head>\n<style>\n#{style}</style>\n</head>\n<body>"
24
24
  srcs.each do |src|
25
- prev_kcode = $KCODE
26
25
  data = File.open(src){|f| f.read}
27
26
  case NKF.guess(data)
28
27
  when NKF::EUC
29
- $KCODE = 'e'
28
+ kcode = 'e'
30
29
  when NKF::SJIS
31
- $KCODE = 's'
30
+ kcode = 's'
32
31
  when NKF::UTF8
33
- $KCODE = 'u'
32
+ kcode = 'u'
34
33
  end
35
- puts terminal.echo(data).render(:html, max_col, nil, colors)
34
+ puts terminal.echo(data).render(:html, max_col, nil, colors, nil, nil, kcode)
36
35
  terminal.echo("\e[2J\e[m")
37
- $KCODE = prev_kcode
38
36
  end
39
37
  puts "</body>\n</html>"
@@ -12,7 +12,7 @@ module AnsiSys
12
12
  module VERSION #:nodoc:
13
13
  MAJOR = 0
14
14
  MINOR = 8
15
- TINY = 0
15
+ TINY = 1
16
16
 
17
17
  STRING = [MAJOR, MINOR, TINY].join('.')
18
18
  end
@@ -98,8 +98,8 @@ module AnsiSys
98
98
 
99
99
  # echo the string onto the _screen_ with initial cursor as _cursor_
100
100
  # _cursor_ position will be changed as the string is echoed
101
- def echo_on(screen, cursor)
102
- each_char do |c|
101
+ def echo_on(screen, cursor, kcode = nil)
102
+ each_char(kcode) do |c|
103
103
  w = width(c)
104
104
  cursor.fit!(w)
105
105
  screen.write(c, w, cursor.cur_col, cursor.cur_row, @sgr.dup)
@@ -110,8 +110,8 @@ module AnsiSys
110
110
 
111
111
  private
112
112
  # iterator on each character
113
- def each_char(&block)
114
- @string.scan(/./).each do |c|
113
+ def each_char(kcode, &block)
114
+ @string.scan(Regexp.new('.', nil, kcode)).each do |c|
115
115
  yield(c)
116
116
  end
117
117
  end
@@ -595,8 +595,9 @@ module AnsiSys
595
595
  # renders the echoed data as _format_ of :html or :text.
596
596
  # _max_col_, _max_row_ can be specified as Integer.
597
597
  # _colors_ can be Screen.default_css_colors(_inverted_, _bright_).
598
- def render(format = :html, max_col = 80, max_row = nil, colors = Screen.default_css_colors, css_class = 'screen', css_style = nil)
599
- screens = populate(format, max_col, max_row, colors)
598
+ def render(format = :html, max_col = 80, max_row = nil, colors = Screen.default_css_colors, css_class = nil, css_style = nil, kcode = nil)
599
+ css_class ||= 'screen'
600
+ screens = populate(format, max_col, max_row, colors, kcode)
600
601
  separator = case format
601
602
  when :html
602
603
  "\n"
@@ -676,7 +677,7 @@ module AnsiSys
676
677
  end
677
678
 
678
679
  private
679
- def populate(format = :html, max_col = 80, max_row = nil, colors = Screen.default_css_colors)
680
+ def populate(format = :html, max_col = 80, max_row = nil, colors = Screen.default_css_colors, kcode = nil)
680
681
  @cursor = Cursor.new(1, 1, max_col, max_row)
681
682
  @stored_cursor = nil
682
683
  @screens = [Screen.new(colors, max_col, max_row)]
@@ -685,7 +686,7 @@ module AnsiSys
685
686
  @stream.each do |type, payload|
686
687
  case type
687
688
  when :string
688
- Characters.new(payload, @sgr).echo_on(@screens[-1], @cursor)
689
+ Characters.new(payload, @sgr).echo_on(@screens[-1], @cursor, kcode)
689
690
  when :code
690
691
  unless Lexer::PARAMETER_AND_LETTER =~ payload
691
692
  raise AnsiSysError, "Invalid code: #{payload.inspect}"
@@ -33,7 +33,7 @@
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.8.0</a>
36
+ <a href="http://rubyforge.org/projects/ansi-sys" class="numbers">0.8.1</a>
37
37
  </div>
38
38
  <h2>What</h2>
39
39
 
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.8.0
7
- date: 2007-11-17 00:00:00 -10:00
6
+ version: 0.8.1
7
+ date: 2007-11-18 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