Skip to content

[BUG] vt100.h macro definition errors? #15933

@TimJTi

Description

@TimJTi

Description / Steps to reproduce the issue

I am adding a few VT100 escape sequence decode functions to a NuttX console app I am writing and think there are some errors in the vt100.h header file. For example:

#define VT100_CURSORLF(n) {ASCII_ESC, '[', (n), 'D'} /* Move cursor left n lines */

I assume that to use this you would do something like:

static const char g_cursorlf[] = VT100_CURSORLF(1);

but that expands to {ASCII_ESC, '[', (1), 'D'} . Should it not be:

#define VT100_CURSORL('n') {ASCII_ESC, '[', n, 'D'} /* Move cursor left n columns */

If I'm right and not missed anything obvious (i.e. I'm being stupid!) I can submit a PR.
It would be nice if we could use VT100_CURSORL(1) rather than ('1') but my C preprocessor macro skills are not up to it!!

Also, for this, since "n" could be any number (not sure if just 1..9 or if it could be 1..99 or even 1..any) then I think a wildcard alternative might be useful, perhaps like this:

#define VT100_CURSORL {ASCII_ESC, '[', '*', 'D'} /* Move cursor left any number of columns */
this will allow a decode function to skip 1 character (*) or 2 (**) or 3 (***) whilst waiting for the 'D' and then pass the number of columns to move to the function that implements the cursor move. There are no current decode functions for VT100 codes (bar one) so I'm in new territory here.

Does that seem sensible or is there a better "trick" for this?

On which OS does this issue occur?

[OS: Linux]

What is the version of your OS?

Not really relevant!

NuttX Version

master

Issue Architecture

[Arch: all]

Issue Area

[Area: Other]

Host information

No response

Verification

  • I have verified before submitting the report.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Arch: allIssues that apply to all architecturesOS: LinuxIssues related to Linux (building system, etc)Type: BugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions