question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Stabilize IParser API

See original GitHub issue

It’s currently flagged experimental:

https://github.com/xtermjs/xterm.js/blob/bd0d267d972a1aab4777cddecf9bf8196d7aa44f/typings/xterm.d.ts#L418-L422

@jerch any concerns about calling this stable? Any more tweaks in mind?

Not sure how many users there are but here’s VS Code’s single usage which seems to work well:

https://github.com/microsoft/vscode/blob/1beea2f864c1f403ab225dbadfdc398d76faef94/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts#L499-L505

My only thought is we should think about the verb (add, register, etc.) and figure out where we want to go. I think add feels a little strange without a remove, VS Code uses register for providers/handlers/factories:

Screen Shot 2019-12-05 at 2 35 11 PM

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:26 (26 by maintainers)

github_iconTop GitHub Comments

2reactions
jerchcommented, Dec 6, 2019

@sdegutis Thx for the feedback. A few notes from my side:

Right now I have to do this: […code]

Yes thats currently the only way to hook up something like a state change listener. But keep in mind that DECSET can freely stack param values, thus you will miss 1049 if its not the first param, e.g. CSI ? ... ; 1049 ; ... h.

About regexp: Your regexp idea will not work for a simple reason - the parser acts on UTF32 codepoints not strings (and I am not keen to write a regexp parser for this lol). The function identifier gets translated into numbers which form a jump table key of handlers in the parser. Thats a quite low level processing of data, but the only way to keep the parser fast (in fact the key -> target jump is still quite costly).

A more general note on regexp and ANSI sequences - its almost impossible to get this right. There are simply too many ifs and elses in the parsing state that you would have to pull into the regexp itself. I think all regexp based packages trying to strip sequences from data get this wrong. To correctly grab DECSET 1049 by a regexp it would look more like:

/(([\x1b][\[])|[\x9b])[?][0-9;]*?1049((h|l)|(;[0-9;]+?)(h|l))/

(This is still slightly wrong but who cares, guess you get my point…)

So imho regexp doesnt work here for those two reasons.

1reaction
jerchcommented, Dec 21, 2019

@Tyriar To sum this up here - from my side this looks ready to get “official”. Gonna address the documentation issue separately with an article about sequences and hooks on the website.

Read more comments on GitHub >

github_iconTop Results From Across the Web

IParser (HAPI FHIR - Core Library 6.3.5-SNAPSHOT API)
A parser, which can be used to convert between HAPI FHIR model/structure objects, and their respective String wire formats, in either XML or...
Read more >
NVIDIA Deep Learning TensorRT Documentation
This NVIDIA TensorRT Developer Guide demonstrates how to use the C++ and Python APIs for implementing the most common deep learning layers.
Read more >
konst - Rust - Docs.rs
This crate provides: Const fn equivalents of standard library functions and methods. Compile-time parsing through the Parser type, and parser_method macro.
Read more >
AvaloniaUI/Avalonia - Gitter
Load(Stream stream, IParser parser) ---> System.MissingMethodException: Constructor on type 'Avalonia.Controls.Html.HtmlControl' not found. at System.
Read more >
konst - crates.io: Rust Package Registry
Rust crates-io api-docs. Const equivalents of std functions and ... Use this whenever mutable references in const contexts are stabilized.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found