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

Use smcup and rmcup to save/restore screen buffer #48

Open
berdon opened this issue Apr 13, 2017 · 1 comment
Open

Use smcup and rmcup to save/restore screen buffer #48

berdon opened this issue Apr 13, 2017 · 1 comment

Comments

@berdon
Copy link

berdon commented Apr 13, 2017

Vim and others appear to do this. It also has the added benefit of fixing Page Up and Page Down on MacOS using Terminal.app.

void initEditor() {
	write(STDOUT_FILENO, "\033[?47h", 6);    // New (smcup)
	EditorConfig.cursor.x = 0;
	EditorConfig.cursor.y = 0;
	if (getWindowSize(&EditorConfig.screenRows, &EditorConfig.screenCols) == -1) die("getWindowSize");
	terminalClearScreen();
}

// ...

void disableRawMode() {
	write(STDOUT_FILENO, "\033[?47l", 6);    // New (rmcup)
	tcsetattr(STDIN_FILENO, TCSAFLUSH, &EditorConfig.orig_termios);
}

More info here.

@berdon
Copy link
Author

berdon commented Apr 13, 2017

For what it's worth - some people don't like the fact that programs use smcup and rmcup.

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