stransi icon indicating copy to clipboard operation
stransi copied to clipboard

Support cursor visibility codes

Open kj7rrv opened this issue 3 years ago • 10 comments

Support cursor visibility codes; closes #16

kj7rrv avatar Jul 07 '22 19:07 kj7rrv

@schneiderfelipe when I call Ansi.escape(), the first Escape object is Escape('\x1b[?25l\x1b[?7l'). It looks like this is two codes. Is that normal?

kj7rrv avatar Jul 07 '22 19:07 kj7rrv

@schneiderfelipe when I call Ansi.escape(), the first Escape object is Escape('\x1b[?25l\x1b[?7l'). It looks like this is two codes. Is that normal?

Probably a bug, likely here https://github.com/getcuia/stransi/blob/6997722fb946aa8ac732b54e3fd623f87706013a/src/stransi/ansi.py#L33-L42 or here https://github.com/getcuia/stransi/blob/6997722fb946aa8ac732b54e3fd623f87706013a/src/stransi/escape.py#L20-L22

I feel stransi doesn't work well with \x1b[?.... It would be nice to test this.

schneiderfelipe avatar Jul 07 '22 20:07 schneiderfelipe

It looks like isescape should be fine; the problem is probably in escapes.

kj7rrv avatar Jul 07 '22 21:07 kj7rrv

It seems like something about \x1b[?25l makes the regex not recognize the end of the code, so it detects \x1b[?7l as part of the same code.

kj7rrv avatar Jul 07 '22 21:07 kj7rrv

The ? is the problem, like you thought.

>>> list(stransi.Ansi('\x1b[?25l\x1b[?7l').escapes())
[Escape('\x1b[?25l\x1b[?7l')]
>>> list(stransi.Ansi('\x1b[25l\x1b[?7l').escapes())
[Escape('\x1b[25l'), Escape('\x1b[?7l')]

kj7rrv avatar Jul 07 '22 21:07 kj7rrv

I fixed the regex in 139aaca.

kj7rrv avatar Jul 07 '22 21:07 kj7rrv

I'm not sure what exactly the ? means; do you know @schneiderfelipe? Now the exception it gives on the neofetch output is ValueError: invalid literal for int() with base 10: '?25'.

kj7rrv avatar Jul 07 '22 21:07 kj7rrv

Okay, it looks like ? means it's a private sequence. To continue using ints, maybe we should represent codes with ? as negative ints? e.g. ?25 becomes -25

kj7rrv avatar Jul 07 '22 21:07 kj7rrv

@schneiderfelipe ab339f9 uses negative ints for private sequences, so now the private codes are properly handled as unsupported codes.

kj7rrv avatar Jul 07 '22 22:07 kj7rrv

Okay, I think this is ready to merge.

kj7rrv avatar Jul 07 '22 22:07 kj7rrv