bubbletea 0.1.4-x86-linux-gnu → 0.1.5-x86-linux-gnu
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 +4 -4
- data/ext/bubbletea/extension.h +4 -0
- data/ext/bubbletea/program.c +17 -6
- data/go/build/linux_386/libbubbletea.a +0 -0
- data/go/keys.go +23 -9
- data/go/keys_test.go +36 -0
- data/lib/bubbletea/3.2/bubbletea.so +0 -0
- data/lib/bubbletea/3.3/bubbletea.so +0 -0
- data/lib/bubbletea/3.4/bubbletea.so +0 -0
- data/lib/bubbletea/4.0/bubbletea.so +0 -0
- data/lib/bubbletea/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c9a5fc8c630fc5b48ba5a95753fde806dd881763c719158ce48192da47b572fc
|
|
4
|
+
data.tar.gz: fb260726787fdd11d4de298dc932127a1e15c6758d753ed893eb1fa42bdab0b0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 959ce5169ec80ec482e87cf813dd9c72f6f523a4171b41a5ee2cadb239ecea71196b9ee7d5ffc633fd4e8396edd103aa3cd884ccb05ca1771e2db5b2ff977f77
|
|
7
|
+
data.tar.gz: 804383961b586541ff582feb36ce7d7fecd53debeadeb772dbafbf52a925d46f81d0e5bdb5d4672544b732b3b265b39372d41d4cadb5036b7f97c15c4cb3b93b
|
data/ext/bubbletea/extension.h
CHANGED
|
@@ -9,8 +9,12 @@ extern VALUE cProgram;
|
|
|
9
9
|
|
|
10
10
|
extern const rb_data_type_t program_type;
|
|
11
11
|
|
|
12
|
+
#define BUBBLETEA_INPUT_BUFFER_SIZE 256
|
|
13
|
+
|
|
12
14
|
typedef struct {
|
|
13
15
|
unsigned long long handle;
|
|
16
|
+
char input[BUBBLETEA_INPUT_BUFFER_SIZE];
|
|
17
|
+
int input_length;
|
|
14
18
|
} bubbletea_program_t;
|
|
15
19
|
|
|
16
20
|
#define GET_PROGRAM(self, program) \
|
data/ext/bubbletea/program.c
CHANGED
|
@@ -27,6 +27,7 @@ const rb_data_type_t program_type = {
|
|
|
27
27
|
static VALUE program_alloc(VALUE klass) {
|
|
28
28
|
bubbletea_program_t *program = ALLOC(bubbletea_program_t);
|
|
29
29
|
program->handle = tea_new_program();
|
|
30
|
+
program->input_length = 0;
|
|
30
31
|
return TypedData_Wrap_Struct(klass, &program_type, program);
|
|
31
32
|
}
|
|
32
33
|
|
|
@@ -158,15 +159,25 @@ static VALUE program_read_raw_input(VALUE self, VALUE timeout_ms) {
|
|
|
158
159
|
static VALUE program_poll_event(VALUE self, VALUE timeout_ms) {
|
|
159
160
|
GET_PROGRAM(self, program);
|
|
160
161
|
|
|
161
|
-
|
|
162
|
-
|
|
162
|
+
if (program->input_length == 0) {
|
|
163
|
+
int bytes_read = tea_input_read_raw(program->handle, program->input, sizeof(program->input), NUM2INT(timeout_ms));
|
|
164
|
+
|
|
165
|
+
if (bytes_read <= 0) {
|
|
166
|
+
return Qnil;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
program->input_length = bytes_read;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
int consumed = 0;
|
|
173
|
+
char *json = tea_parse_input_with_consumed(program->input, program->input_length, &consumed);
|
|
163
174
|
|
|
164
|
-
if (
|
|
165
|
-
|
|
175
|
+
if (consumed <= 0 || consumed > program->input_length) {
|
|
176
|
+
consumed = program->input_length;
|
|
166
177
|
}
|
|
167
178
|
|
|
168
|
-
|
|
169
|
-
|
|
179
|
+
program->input_length -= consumed;
|
|
180
|
+
memmove(program->input, program->input + consumed, program->input_length);
|
|
170
181
|
|
|
171
182
|
if (json == NULL || json[0] == '\0') {
|
|
172
183
|
tea_free(json);
|
|
Binary file
|
data/go/keys.go
CHANGED
|
@@ -334,6 +334,28 @@ func ParseInput(data []byte) (int, string) {
|
|
|
334
334
|
return size, string(jsonBytes)
|
|
335
335
|
}
|
|
336
336
|
|
|
337
|
+
// mouseButton maps mouse report buttons to Bubbletea::MouseMessage buttons
|
|
338
|
+
func mouseButton(button int) int {
|
|
339
|
+
low := button & 3
|
|
340
|
+
|
|
341
|
+
if (button & 64) != 0 {
|
|
342
|
+
switch low {
|
|
343
|
+
case 0:
|
|
344
|
+
return 4 // wheel up
|
|
345
|
+
case 1:
|
|
346
|
+
return 5 // wheel down
|
|
347
|
+
default:
|
|
348
|
+
return 0 // wheel left/right
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
if low == 3 {
|
|
353
|
+
return 0 // none
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
return low + 1
|
|
357
|
+
}
|
|
358
|
+
|
|
337
359
|
// parseMouseSGR parses SGR mouse format: ESC [ < Cb ; Cx ; Cy M/m
|
|
338
360
|
func parseMouseSGR(data []byte) (int, MouseEvent) {
|
|
339
361
|
// Format: \x1b[<button;x;y(M|m)
|
|
@@ -368,7 +390,7 @@ func parseMouseSGR(data []byte) (int, MouseEvent) {
|
|
|
368
390
|
alt := (button & 8) != 0
|
|
369
391
|
ctrl := (button & 16) != 0
|
|
370
392
|
motion := (button & 32) != 0
|
|
371
|
-
buttonNum := button
|
|
393
|
+
buttonNum := mouseButton(button)
|
|
372
394
|
|
|
373
395
|
action := 0 // press
|
|
374
396
|
|
|
@@ -378,14 +400,6 @@ func parseMouseSGR(data []byte) (int, MouseEvent) {
|
|
|
378
400
|
action = 2 // motion
|
|
379
401
|
}
|
|
380
402
|
|
|
381
|
-
if (button & 64) != 0 {
|
|
382
|
-
if buttonNum == 0 {
|
|
383
|
-
buttonNum = 4 // wheel up
|
|
384
|
-
} else if buttonNum == 1 {
|
|
385
|
-
buttonNum = 5 // wheel down
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
|
|
389
403
|
return endIndex + 1, MouseEvent{
|
|
390
404
|
Type: "mouse",
|
|
391
405
|
X: x - 1,
|
data/go/keys_test.go
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
package main
|
|
2
|
+
|
|
3
|
+
import "testing"
|
|
4
|
+
|
|
5
|
+
func TestParseMouseSGR(t *testing.T) {
|
|
6
|
+
tests := []struct {
|
|
7
|
+
name string
|
|
8
|
+
input string
|
|
9
|
+
x, y int
|
|
10
|
+
button, action int
|
|
11
|
+
}{
|
|
12
|
+
{"left press", "\x1b[<0;10;5M", 9, 4, 1, 0},
|
|
13
|
+
{"middle press", "\x1b[<1;10;5M", 9, 4, 2, 0},
|
|
14
|
+
{"right press", "\x1b[<2;10;5M", 9, 4, 3, 0},
|
|
15
|
+
{"left release", "\x1b[<0;10;5m", 9, 4, 1, 1},
|
|
16
|
+
{"left drag", "\x1b[<32;12;5M", 11, 4, 1, 2},
|
|
17
|
+
{"motion without a button", "\x1b[<35;20;8M", 19, 7, 0, 2},
|
|
18
|
+
{"wheel up", "\x1b[<64;1;1M", 0, 0, 4, 0},
|
|
19
|
+
{"wheel down", "\x1b[<65;1;1M", 0, 0, 5, 0},
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
for _, tt := range tests {
|
|
23
|
+
t.Run(tt.name, func(t *testing.T) {
|
|
24
|
+
consumed, event := parseMouseSGR([]byte(tt.input))
|
|
25
|
+
|
|
26
|
+
if consumed != len(tt.input) {
|
|
27
|
+
t.Fatalf("consumed %d bytes, want %d", consumed, len(tt.input))
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if event.X != tt.x || event.Y != tt.y || event.Button != tt.button || event.Action != tt.action {
|
|
31
|
+
t.Errorf("got x=%d y=%d button=%d action=%d, want x=%d y=%d button=%d action=%d",
|
|
32
|
+
event.X, event.Y, event.Button, event.Action, tt.x, tt.y, tt.button, tt.action)
|
|
33
|
+
}
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
data/lib/bubbletea/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bubbletea
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.5
|
|
5
5
|
platform: x86-linux-gnu
|
|
6
6
|
authors:
|
|
7
7
|
- Marco Roth
|
|
@@ -45,6 +45,7 @@ files:
|
|
|
45
45
|
- go/go.sum
|
|
46
46
|
- go/input.go
|
|
47
47
|
- go/keys.go
|
|
48
|
+
- go/keys_test.go
|
|
48
49
|
- go/renderer.go
|
|
49
50
|
- go/terminal.go
|
|
50
51
|
- lib/bubbletea.rb
|