kaitai-struct-visualizer 0.3 → 0.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 606cb8d727e8b560aa87474311d25b831e3f81f3
4
- data.tar.gz: 87445c8ed759fb11c471ded3e7c99ca86e6352ce
3
+ metadata.gz: d14808a034e6e74e58395601dcfdeec2cf874d69
4
+ data.tar.gz: 75e679c69ed1ee921fe0c9aa2448157bd19dc6e1
5
5
  SHA512:
6
- metadata.gz: ffc2d4c17e093427ef1aa181e8a1b013edfe7a96c860c3047750d8c2373d52f7da506104a8ac55c6fe227dc06fd93d4177ffe56239a5e912569f66599f0a9b07
7
- data.tar.gz: e614e0fc75eef49ea7dd59146e37226edf63a6e1be97d19028d03b1cb805aa04769dea0ba9f985cfe47f0b5b74fc6162e9217ca9e4b81fed20149d5dcb6f6f0b
6
+ metadata.gz: f49dccf89740812c59b12e8eb41067cbe5705ef7ec7e3a210d33087c4c8b2b0863c860db0a43ee38f9dd926ee67e3819ae401e2a4b14f17a8ed160b6699f1415
7
+ data.tar.gz: 2224037570682309e1ce9db6b9245869f5382b71150705caf3bfd802c7a3727dff7aacfcb1cc196d225795bc60ad5214e07b06dc94169a3f41717c9c8c8e7414
@@ -33,5 +33,5 @@ EOF
33
33
  s.add_development_dependency 'rake', '~> 10'
34
34
  # s.add_development_dependency 'rspec', '~> 3'
35
35
 
36
- s.add_dependency 'kaitai-struct', "~> #{s.version}"
36
+ s.add_dependency 'kaitai-struct', "~> 0.4"
37
37
  }
@@ -55,7 +55,7 @@ class HexViewer
55
55
  c = nil
56
56
  loop {
57
57
  @ui.goto(0, @max_scr_ln + 1)
58
- printf "%06x (%d, %d)", @addr, @cur_x, @cur_y
58
+ printf "%08x (%d, %d)", @addr, @cur_x, @cur_y
59
59
 
60
60
  @ui.goto(col_to_col_char(@cur_x), row_to_scr(@cur_y))
61
61
  c = @ui.read_char_mapped
@@ -114,6 +114,13 @@ class HexViewer
114
114
  @cur_x = PER_LINE - 1
115
115
  end
116
116
  clamp_cursor
117
+ when 'w'
118
+ fn = @ui.input_str('Write buffer to file', 'Filename')
119
+ File.open(fn, 'w') { |out|
120
+ out.write(@buf)
121
+ }
122
+ @ui.clear
123
+ redraw
117
124
  when 'q'
118
125
  @tree.do_exit if @tree
119
126
  return
@@ -137,21 +144,21 @@ class HexViewer
137
144
  PER_LINE = 16
138
145
  PER_GROUP = 4
139
146
  PAGE_ROWS = 20
140
- FMT = "%06x: %-#{PER_LINE * 3}s| %-#{PER_LINE}s\n"
147
+ FMT = "%08x: %-#{PER_LINE * 3}s| %-#{PER_LINE}s\n"
141
148
 
142
149
  def self.line_width
143
- #6 + 2 + 3 * PER_LINE + 2 + PER_LINE
144
- 10 + 4 * PER_LINE
150
+ #8 + 2 + 3 * PER_LINE + 2 + PER_LINE
151
+ 12 + 4 * PER_LINE
145
152
  end
146
153
 
147
154
  def col_to_col_hex(c)
148
- #6 + 2 + 3 * c
149
- @shift_x + 8 + 3 * c
155
+ #8 + 2 + 3 * c
156
+ @shift_x + 10 + 3 * c
150
157
  end
151
158
 
152
159
  def col_to_col_char(c)
153
- #6 + 2 + 3 * PER_LINE + 2
154
- @shift_x + 10 + 3 * PER_LINE + c
160
+ #8 + 2 + 3 * PER_LINE + 2
161
+ @shift_x + 12 + 3 * PER_LINE + c
155
162
  end
156
163
 
157
164
  def row_to_scr(r)
@@ -40,6 +40,7 @@ class Node
40
40
  def openable?
41
41
  not (
42
42
  @value.is_a?(Fixnum) or
43
+ @value.is_a?(Bignum) or
43
44
  @value.is_a?(String) or
44
45
  @value.is_a?(Symbol) or
45
46
  @value === true or
@@ -84,7 +85,7 @@ class Node
84
85
 
85
86
  pos = 2 * level + 4 + @id.length
86
87
 
87
- if @value.is_a?(Fixnum)
88
+ if @value.is_a?(Fixnum) or @value.is_a?(Bignum)
88
89
  print " = #{@value}"
89
90
  elsif @value.is_a?(Symbol)
90
91
  print " = #{@value}"
@@ -95,9 +96,11 @@ class Node
95
96
  max_len = @tree.tree_width - pos
96
97
  case @str_mode
97
98
  when :str
98
- s = @value[0, max_len]
99
+ v = @value.encode('UTF-8')
100
+ s = v[0, max_len]
99
101
  when :str_esc
100
- s = @value.inspect[0, max_len]
102
+ v = @value.encode('UTF-8')
103
+ s = v.inspect[0, max_len]
101
104
  when :hex
102
105
  s = first_n_bytes_dump(@value, max_len / 3 + 1)
103
106
  else
@@ -159,7 +162,7 @@ class Node
159
162
  @value = @parent.value.send(@value_method)
160
163
  end
161
164
 
162
- if @value.is_a?(Fixnum) or @value.is_a?(String) or @value.is_a?(Symbol)
165
+ if @value.is_a?(Fixnum) or @value.is_a?(Bignum) or @value.is_a?(String) or @value.is_a?(Symbol)
163
166
  # do nothing else
164
167
  elsif @value.is_a?(Array)
165
168
  clean_id = @id[0] == '@' ? @id[1..-1] : @id
@@ -1,7 +1,7 @@
1
1
  module Kaitai
2
2
  module Struct
3
3
  module Visualizer
4
- VERSION = '0.3'
4
+ VERSION = '0.4'
5
5
  end
6
6
  end
7
7
  end
@@ -1,5 +1,6 @@
1
1
  # coding: utf-8
2
2
  require 'io/console'
3
+ require 'readline'
3
4
 
4
5
  module Kaitai
5
6
 
@@ -141,6 +142,16 @@ class TUI
141
142
  }
142
143
  end
143
144
 
145
+ def input_str(header, msg)
146
+ top_y = @rows / 2 - 5
147
+ draw_rectangle(10, top_y, @cols - 20, 10)
148
+ goto(@cols / 2 - (header.length / 2) - 1, top_y)
149
+ print ' ', header, ' '
150
+
151
+ goto(11, top_y + 1)
152
+ Readline.readline('', false)
153
+ end
154
+
144
155
  def draw_rectangle(x, y, w, h, charset = DOUBLE_CHARSET)
145
156
  goto(x, y)
146
157
  print charset[CHAR_TL]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kaitai-struct-visualizer
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.3'
4
+ version: '0.4'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mikhail Yakshin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-19 00:00:00.000000000 Z
11
+ date: 2016-08-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0.3'
47
+ version: '0.4'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0.3'
54
+ version: '0.4'
55
55
  description: |
56
56
  Kaitai Struct is a declarative language used for describe various binary data structures, laid out in files or in memory: i.e. binary file formats, network stream packet formats, etc.
57
57