Code Monkey home page Code Monkey logo

Comments (19)

o-sdn-o avatar o-sdn-o commented on August 22, 2024 1

vim(:set mouse=a) and htop request CSI ? 1000 h SET_VT200_MOUSE

image

Currently only CSI ? 1006 h SET_SGR_EXT_MODE_MOUSE protocol is supported, I started making support for 1000-1003 modes as well as 1006 😊

from vtm.

o-sdn-o avatar o-sdn-o commented on August 22, 2024 1

NASA's Mars 2020 Perseverance Rover Landing live broadcast begins 🀞

from vtm.

ismail-yilmaz avatar ismail-yilmaz commented on August 22, 2024 1

@o-sdn-o ,

As you can see, not all terminals and apps implement the sequences and follow the rules strictly. :) In an ideal world, unrecognized or irregular sequences would be ignored by all terminal emulators or apps. In practice, however, they simply breaks some of them; even valid but unrecognized sequences break them (e.g initial implementation of DEC's DCS sequences by some popular apps caused a lot of trouble some time ago.). And it is hard to change established behavior. Still, IME, the sane route to take would be to concieve a private sequence and corresponding mode, if you really need one. The other factor is both VT and CLI app developers would be reluctant to introduce a new sequence and mode., for good reasons.

I will have the time to check the release tomorrow, and provide more feedback.

Cheers

from vtm.

o-sdn-o avatar o-sdn-o commented on August 22, 2024 1

Everything here seems to be done and works fine, but if something is wrong, I'll reopen this issue.

from vtm.

ismail-yilmaz avatar ismail-yilmaz commented on August 22, 2024

Ok, thanks. It is nice to see this tool is getting better each day.

from vtm.

o-sdn-o avatar o-sdn-o commented on August 22, 2024

Done. X11 mouse tracking protocol CSI ? 1000 h is now supported by vtm.

I have also updated the release for linux.

from vtm.

o-sdn-o avatar o-sdn-o commented on August 22, 2024

Do you think the modes 1001-1003 should be implemented, or 1000 will suffice?
What applications use these modes and are they even needed in the current reality?

Now when an application requests any of these modes, it uses mode 1000 instead. I don't know if this behavior is enough.

from vtm.

ismail-yilmaz avatar ismail-yilmaz commented on August 22, 2024

Do you think the modes 1001-1003 should be implemented, or 1000 will suffice?
What applications use these modes and are they even needed in the current reality?

Now when an application requests any of these modes, it uses mode 1000 instead. I don't know if this behavior is enough.

No, mode 1000 will not suffice as it only reports mouse button press and release. It does not report motion. (at least it shouldn't).

The problem I've encountered with your multiplexer is not that it uses mode 1006. In fact it is the recommended mode. All the mode 1006 does is translate the terminal response for the modes 1000, 1002 and 1003 to SGR format. Hence SGR mode should also report wheel ups and downs (they are buttons 4 and 5, or 64 and 65 in SGR mode). (Except for the legacy X10 mouse tracking mode `9', which is deprecated anyway)

See this recommendation (as you know, this is still a draft but these recommendations are based on real usages.) It even recommends a precedence among these modes, which works very well in real life scenarios.

from vtm.

o-sdn-o avatar o-sdn-o commented on August 22, 2024

Thank you, now it's all clear 😊

The X11 is a default mouse reporting protocol.
1006 only switches the default mouse reporting protocol to SGR.

1000 mode for buttons tracking
1001 mode for buttons + movements while pressed tracking
1002 mode for buttons + movements tracking

1000 mode for buttons tracking
1002 mode for buttons + movements while pressed tracking
1003 mode for buttons + movements tracking

from vtm.

ismail-yilmaz avatar ismail-yilmaz commented on August 22, 2024

Thank you, now it's all clear blush

The X11 is a default mouse reporting protocol.
1006 only switches the default mouse reporting protocol to SGR.

1000 mode for buttons tracking
1001 mode for buttons + movements while pressed tracking
1002 mode for buttons + movements tracking

Yes, this basically sums up the modes. But there is one thing that is usually overlooked: The default mouse coordinates mode on terminals limit the resolution to 256x256 cells, as it uses a byte oriented protocol. There were other coordinate formats to surpass this limits (mode '1005 - UTF8 and mode '1015 - URXVT), but they are deprecated too. SGR does not have this limit, you can represent coordinates >= 256, as it is a string based protocol. So I would recommend explicitly clamping the mouse coordinates to (0-255) when you are not using the mode 1006 and disable the upper limit (or set a sane upper limit, i.e. 64K) when you are using the mode 1006. Forgetting this leads to weird effects on terminal displays >= 256 cells.

from vtm.

o-sdn-o avatar o-sdn-o commented on August 22, 2024

So I would recommend explicitly clamping the mouse coordinates to (0-255) when you are not using the mode 1006

That's right, coordinates are already being cut
https://github.com/netxs-group/VTM/blob/e1b36187f744849dcb9e1ea0b8d67ac5d7cc97fc/src/netxs/console/ansi.hpp#L331-L335

I'm worried about the following question (I can't find the answer anywhere):
Why are all developers against negative parameter values ​​in CSI?
This also applies to the SGR mouse reporting protocol (eg CSI < 32; -10 ; -5 m ) and CSI in general.

Could this be due to the use of some public ANSI VT sequence parsing algorithm that does not allow negative numbers?

I need to use negative numbers when working with the mouse, when the cursor goes out of the window when dragging. I don't know if I should do my own new mouse tracking mode or just allow negative numbers.

Example:
https://www.youtube.com/watch?v=nIujUzl30NI


EDIT:

Standard ECMA-48: Control Functions for Coded Character Sets

5.4 Control sequences

The format of a control sequence is
CSI P ... P I ... I F
where

  • CSI is represented by bit combinations 01/11 (representing ESC) and 05/11 in a 7-bit code or by bit combination 09/11 in an 8-bit code, see 5.3;
  • P ... P are Parameter Bytes, which, if present, consist of bit combinations from 03/00 to 03/15 (ASCII 0123456789:;<=>?);
  • I ... I are Intermediate Bytes, which, if present, consist of bit combinations from 02/00 to 02/15 (ASCII space and !"#$%&'()*+,-./);
  • F the Final Byte.

This standard does not provide for the minus sign as Parameter Bytes.

But everyone assumes that the CSI numeric parameters are a series of semicolon-separated literal numbers, not bytes

Therefore, it is possible to violate (use negative numbers) this standard without spoiling the expected behavior.
What do you think?

from vtm.

ismail-yilmaz avatar ismail-yilmaz commented on August 22, 2024

This standard does not provide for the minus sign as Parameter Bytes. But everyone assumes that the CSI numeric parameters are a series of semicolon-separated literal numbers, not bytes

I suggest you read, if not already did, the DEC STD070 document, aka "the bible".

It explicitly defines the wire formats (ESC,CSI, DCS, OSC, APC, SOS, PM), albeit inconsistent with the later documents or its revisions on some points. See especially the page 3-23 Extension layer (#124 and on in pdf). You'll hopefully find the answer for this question. It explains the specs.

Therefore, it is possible to violate (use negative numbers) this standard without spoiling the expected behavior.

Minus or hypen (0x2d) is reserved. It is in the range of intermediary bytes. (0x20-0x2f) for CSIand 'DCS' sequences. So using it it will break the parsers and violate the protocol. However, if you want to use it internally, you can simply use an PM (Private message, allocated for private use, if you are going to use it internally. And It allows to define your own protocol.

Still, if you are going to define a new command, which I highly recommend avoid using CSI' or 'DCS for this, you can represent negative and positive numbers by using another parameter, which takes 1 for positive, 0 for negative, for example.

from vtm.

ismail-yilmaz avatar ismail-yilmaz commented on August 22, 2024

OTOH, in theory you can use negative numbers in a new OSC function. It accepts 0x20-0x7f as parameter. Still, I am not sure if it would be considered good practice to do so. You can prepend or append P and N to numbers too.

E.g. let's assume that we request from the host app a sum of two signed integers, sum(10, -20) This can be represented as:

  • Valid: OSC 99999 ; P10 ; N20 ST
  • Valid: OSC 99999 ; 1 ; 10 ; 0 ; 20 ST (1=P, 0 = N)
  • AFAIK, formally valid: OSC 99999 ; 10 ; -20 ST

If this function is going to be used internally, as I wrote on my previous message, then you should replace OSC with PM and its specs.

P.S While the OSC initally conceived as having reserved intermediary bytes, in practice, to my knowledge, this has never been actualized.

from vtm.

o-sdn-o avatar o-sdn-o commented on August 22, 2024

Thanks a lot for the link to the DEC STD070 document and helpful thoughts!

With CSI sequences everything is very clear - negative numbers in CSI cannot be used in general.

BUT, from DEC STD070 document:

  • If 3/0 to 3/15 occur after the occurrence of one or more intermediate characters, the sequence is invalid. However, the end of the control sequence is still defined by the final character. Interpretation will continue until a valid final character is received.

This means there will be no side effects when the SGR mouse report with a minus sign is received, no extraneous characters in the input, just the whole sequence will be discarded, which is great.

Now I really want to add a minus sign to the SGR mouse reporting protocol.

Now I really don't want to come up with a new sequence for this, and I'm tempted to take the risk and break the existing order.

Apps that can't interpret the minus sign, they also won't know the new mouse protocol if I have to reinvent it, so this functionality won't be available to them anyway.

from vtm.

o-sdn-o avatar o-sdn-o commented on August 22, 2024

It's not completely clear to me what the consequences/side effects may be, but so far everything looks optimistic.

Probably the biggest problem is that applications can assume that the terminal always emits valid sequences, and with this in mind, make some optimizations.

from vtm.

o-sdn-o avatar o-sdn-o commented on August 22, 2024

A sub-mode is required to enable sending negative coordinates in SGR reports.

For example, the MidnightCommander parser does not discard the entire sequence when it receives a minus sign

https://github.com/MidnightCommander/mc/blob/4ae6cdb774105c6ee7754c19b025f1723ec45ddc/lib/tty/key.c#L775-L798

and extraneous characters appear in the input.

EDIT: It will be something like

  • CSI ? 1003 ; 1006 h ~ CSI ? 1003 ; 1006:0 h - mode for reporting the cursor position strictly inside the viewport (default)
  • CSI ? 1003 ; 1006:1 h - mode for reporting the cursor position regardless of the position inside the viewport (allow outside + negative)

I will now test all popular terminals for side effects when using this sub-mode.

from vtm.

o-sdn-o avatar o-sdn-o commented on August 22, 2024

The idea with sub-modes did not work.
Terminals do not consider 1006:n value to be equivalent to plain 1006.
So I have to do my private mode CSI ? 1003 ; 1006 ; 99999... h.

It is going to be a 10060 mode:

  • Enable mouse reporting outside the viewport (outside + negative coordinates).

from vtm.

o-sdn-o avatar o-sdn-o commented on August 22, 2024

Now negative parameters will only be sent to applications that explicitly ask for it using CSI ? 10060 h.

I've updated the releases.

from vtm.

o-sdn-o avatar o-sdn-o commented on August 22, 2024

Drag-scrolling is one of the key reasons for using the DECSET 10060 Extended SGR mode.

Using the DECSET 10060 Extended SGR mode
vtm drag-scrolling

Without using the DECSET 10060 Extended SGR mode
vtm wo_drag-scrolling

from vtm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.