New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
colon notation for the parser #2241
Conversation
@Tyriar: |
Some notes on the subparams implementation:
|
param = 1; | ||
} | ||
public cursorForward(params: IParams): void { | ||
const param = params.params[0] || 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this will let negative numbers though now unless IParams
handles this, is that a concern? Math.max(params.params[0], 1)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, currently there is no way to set this to a negative value from a sequence. The parser currently applies zero default mode to params (as it always did), maybe just change the params typed array to uint16_t to be on the save side?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thought again about this - imho it can keep it this way as long as we stick to ZDM. If we ever change this, we have to change default handling in all handlers anyway.
src/Types.d.ts
Outdated
/** CSI r */ setScrollRegion(params?: number[], collect?: string): void; | ||
/** CSI s */ saveCursor(params?: number[]): void; | ||
/** CSI u */ restoreCursor(params?: number[]): void; | ||
/** CSI @ */ insertChars(params?: IParams): void; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just checking if params still optional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eww good finding. Def. have to check all handler again, if they check for params
before getting into business. Alternatively we could make params non optional for all handlers, but I am not sure if this would break on direct invocations here and there. So Id have to check this first.
Any preference whether to go with optional / non optional here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the question mark from params
thus making it mandatory. They were not optional on Inputhandler
anyway thus this chance is just getting the interface in line with the class.
* Get a JS array representation of the current parameters and sub parameters. | ||
* The array is structured as follows: | ||
* sequence: "1;2:3:4;5::6" | ||
* array : [1, 2, [3, 4], 5, [-1, 6]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
::
=> -1
? Is that the default value for sub parameters?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kinda.
In the past I had a longer discussion with @egmontkob about ZDM (zero default mode) for params (vte does not do this for params either). We do currently to be in line with the parser from vt100.net, and I would not change that for params unless we run into troubles for a certain sequence.
For subparams there is no ZDM thingy, which means it might be anything. I took -1
a placeholder for default since negative values cannot be reached by normal sequence means. This way the final action can place its real default value whenever it sees -1.
Last changes:
|
typings/xterm.d.ts
Outdated
@@ -499,7 +499,7 @@ declare module 'xterm' { | |||
* The most recently-added handler is tried first. | |||
* @return An IDisposable you can call to remove this handler. | |||
*/ | |||
addCsiHandler(flag: string, callback: (params: number[], collect: string) => boolean): IDisposable; | |||
addCsiHandler(flag: string, callback: (params: IParams, collect: string) => boolean): IDisposable; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should just use (number | number[])[]
here to hide the complexity?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. Note that the translation to (number | number[])[]
by calling Params.toArray()
is ~5 times slower than directly using the Param
type. Imho not a problem, since most handlers will be not invoked often.
@Tyriar Further documented ZDM. If you feel uneasy about it (we are not in line with the latest specs here), we could lift that restriction. For this to work we only have to fix all action handlers in
Edit: Looking at the tests we have for any method in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, great job!
PR to get support for colon parameter notation in the parser. Should fix #2200.
Several things todo:
Params
type to hold params and subparams in a speedy mannerParams
type to parser API and inputhandler methodsCOLORTERM=truecolor
to env