aligrudi / neatvi

A small vi/ex editor for editing UTF-8 text
http://litcave.rudi.ir/
305 stars 25 forks source link

Restore terminal state when neatvi exits #76

Open lobre opened 9 months ago

lobre commented 9 months ago

From what I have read from raw mode in the terminal, there is way to "restore" the terminal state when the application exits, so that the terminal goes back to where it was.

It means storing the original state in memory though.

See this link or the below snippet for more info.

struct termios orig_termios;

void disableRawMode() {
  tcsetattr(STDIN_FILENO, TCSAFLUSH, &orig_termios);
}

Is there a good reason why it is not implemented in neatvi? The outcome is that I continue to see some part of the editing session when I quit neatvi, instead of just being back to where I was before launching it.

aligrudi commented 9 months ago

Loric Brevet @.***> wrote:

From what I have read from raw mode in the terminal, there is way to "restore" the terminal state when the application exits, so that the terminal goes back to where it was.

It means storing the original state in memory though.

See this link or the below snippet for more info.

struct termios orig_termios;

void disableRawMode() {
  tcsetattr(STDIN_FILENO, TCSAFLUSH, &orig_termios);
}

Is there a good reason why it is not implemented in neatvi? The outcome is that I continue to see some part of the editing session when I quit neatvi, instead of just being back to where I was before launching it.

Neatvi restores terminal state but not terminal contents.

Ali
lobre commented 8 months ago

Neatvi restores terminal state but not terminal contents.

Would it be using too much memory if it would restore terminal contents?