Skip to content
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

attempt to add basic syntax highlighting #33

Open
CDitzel opened this issue Aug 22, 2024 · 0 comments
Open

attempt to add basic syntax highlighting #33

CDitzel opened this issue Aug 22, 2024 · 0 comments

Comments

@CDitzel
Copy link

CDitzel commented Aug 22, 2024

mg/display.c

Line 330 in 32efa25

vp->v_text[vtcol++] = c;

so I tried to implement a basic syntax highlighting by first trying to color in digits.
I tried to utilize ANSI escape codes as follows

	} else if (isprint(c)){
	    if (isdigit(c)){
		char buf[5];
		int clen = snprintf(buf, sizeof(buf), "\x1b[35m");
		for(uint32_t i = 0; i < 5; ++i){
		    vp->v_text[vtcol++] = buf[i];
		} 
		vp->v_text[vtcol++] = c;
		clen = snprintf(buf, sizeof(buf), "\x1b[39m");
		for(uint32_t i = 0; i < 5; ++i){
		    vp->v_text[vtcol++] = buf[i];
		} 
	    }
	    else
		vp->v_text[vtcol++] = c;
	}

but this does not seem to work as it only hides the digits and shrinks the modeline.

Anyone any idea on how to proceed here?
Uploading gh.png…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant