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

app/system/vi: Fix broken VI editor #2769

Merged
merged 2 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions system/termcurses/tcurses_vt100.c
Original file line number Diff line number Diff line change
Expand Up @@ -1500,11 +1500,11 @@ FAR struct termcurses_s *tcurses_vt100_initialize(int in_fd, int out_fd)

priv->lflag = cfg.c_lflag;

/* If ECHO enabled, disable it */
/* If ECHO and ICANON enabled, disable it */

if (cfg.c_lflag & ECHO)
if (cfg.c_lflag & (ECHO | ICANON))
{
cfg.c_lflag &= ~ECHO;
cfg.c_lflag &= ~(ECHO | ICANON);
tcsetattr(priv->in_fd, TCSANOW, &cfg);
}
}
Expand Down Expand Up @@ -1546,9 +1546,10 @@ static int tcurses_vt100_terminate(FAR struct termcurses_s *dev)

if (isatty(priv->in_fd))
{
if (tcgetattr(priv->in_fd, &cfg) == 0 && priv->lflag & ECHO)
bl4kraven marked this conversation as resolved.
Show resolved Hide resolved
if ((priv->lflag & (ECHO | ICANON))
&& tcgetattr(priv->in_fd, &cfg) == 0)
{
cfg.c_lflag |= ECHO;
cfg.c_lflag = priv->lflag;
tcsetattr(priv->in_fd, TCSANOW, &cfg);
}
}
Expand Down
2 changes: 2 additions & 0 deletions system/vi/vi.c
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,7 @@ static void vi_write(FAR struct vi_s *vi, FAR const char *buffer,
{
fprintf(stderr, "ERROR: write to stdout failed: %d\n",
errcode);
vi_release(vi);
exit(EXIT_FAILURE);
}
}
Expand Down Expand Up @@ -635,6 +636,7 @@ static int vi_getch(FAR struct vi_s *vi)
{
fprintf(stderr, "ERROR: read from stdin failed: %d\n",
errcode);
vi_release(vi);
exit(EXIT_FAILURE);
}
}
Expand Down
Loading