1

I would like to know if there is a way to know if DECCKM function (specifying whether or not to use ANSI cursor sequences) has been set or not.

I'm connecting to a process via ptrace so I have no way to know if the sequences ^[[?1h or ^[[?1l have been sent to the terminal before making the connection.

Is there some string sequence that, when sent to the terminal, will allow me to query the state of Cursor Keys Mode? Or is there some C function/syscall that can do it? As I'm debugging the process I can fake both terminal input and call system functions on behalf of the debugged process so I'm just interested in knowing how can you perform the check as if you were writing the program and had access to the source code.

Grimflo
  • 116
  • 4
  • I don't think there is any way other than pressing the arrow keys and seeing the returned sequence. – ninjalj Nov 01 '11 at 19:05
  • Thank you for your comment but, as I'm using ptrace to connect to the process, there is no way for me to press any arrow key :) – Grimflo Nov 01 '11 at 19:32
  • Are you specifically interested in finding out if DECCKM has been set e.g. to verify the program state? Or do you just want to make sure that the terminal is in the right mode before you use it? – thkala Nov 02 '11 at 08:04
  • In this particular case, I'm reading the input on my terminal and forwarding it (by faking syscalls return values and writing to memory) to the ptraced process. The problem is if DECCKM is set in the debugged program and is not set in my terminal, the cursor sequences that come from my stdin don't match the ones expected by the traced process and don't move its cursor. I want to check if DECCKM is set in the remote terminal and set it locally if it is, so that the arrow key sequences expected by my terminal and the remote terminal match. – Grimflo Nov 02 '11 at 09:58

1 Answers1

2

Use DECRQM to inquire status of DECCKM.

sendmoreinfo
  • 582
  • 6
  • 22