drgxfs
drgxfs

Reputation: 1127

Dynamic syntax highlighting in Python

I am writing an interpreter in Python where the user has to type Prolog code and I'd like to implement dynamic syntax highlighting. So far my application (which should be cross-platform) is reading input and printing from/to the command prompt (on Windows). I've been looking at the pygments library, but I have no clue on how to modify the current line (being typed) on the command prompt.

So, I've also been looking at the curses library to implement an UI but that would leave Windows users out. Any suggestions? I just need to implement a quick UI to be able to dynamically highlight what is being typed.

Upvotes: 2

Views: 368

Answers (1)

f p
f p

Reputation: 3223

It appears that you can't wait for a return. To deal with input one char at a time you need something like getch.

Upvotes: 1

Related Questions