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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d14808a034e6e74e58395601dcfdeec2cf874d69
|
4
|
+
data.tar.gz: 75e679c69ed1ee921fe0c9aa2448157bd19dc6e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f49dccf89740812c59b12e8eb41067cbe5705ef7ec7e3a210d33087c4c8b2b0863c860db0a43ee38f9dd926ee67e3819ae401e2a4b14f17a8ed160b6699f1415
|
7
|
+
data.tar.gz: 2224037570682309e1ce9db6b9245869f5382b71150705caf3bfd802c7a3727dff7aacfcb1cc196d225795bc60ad5214e07b06dc94169a3f41717c9c8c8e7414
|
@@ -55,7 +55,7 @@ class HexViewer
|
|
55
55
|
c = nil
|
56
56
|
loop {
|
57
57
|
@ui.goto(0, @max_scr_ln + 1)
|
58
|
-
printf "%
|
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 = "%
|
147
|
+
FMT = "%08x: %-#{PER_LINE * 3}s| %-#{PER_LINE}s\n"
|
141
148
|
|
142
149
|
def self.line_width
|
143
|
-
#
|
144
|
-
|
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
|
-
#
|
149
|
-
@shift_x +
|
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
|
-
#
|
154
|
-
@shift_x +
|
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
|
-
|
99
|
+
v = @value.encode('UTF-8')
|
100
|
+
s = v[0, max_len]
|
99
101
|
when :str_esc
|
100
|
-
|
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
|
data/lib/kaitai/tui.rb
CHANGED
@@ -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.
|
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-
|
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.
|
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.
|
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
|
|