1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:07:35 +00:00

Terminal: Various improvements to terminal emulation.

This commit is contained in:
Andreas Kling 2019-01-23 19:58:45 +01:00
parent 8d36c8f0d8
commit faaa0dbf1d
3 changed files with 20 additions and 20 deletions

View file

@ -376,6 +376,8 @@ void Terminal::set_cursor(unsigned row, unsigned column)
invalidate_cursor(); invalidate_cursor();
m_cursor_row = row; m_cursor_row = row;
m_cursor_column = column; m_cursor_column = column;
if (column != columns() - 1)
m_stomp = false;
invalidate_cursor(); invalidate_cursor();
} }
@ -438,7 +440,7 @@ void Terminal::on_char(byte ch)
put_character_at(m_cursor_row, m_cursor_column, ' '); put_character_at(m_cursor_row, m_cursor_column, ' ');
return; return;
} }
break; return;
case '\a': case '\a':
// FIXME: Bell! // FIXME: Bell!
return; return;
@ -459,13 +461,22 @@ void Terminal::on_char(byte ch)
return; return;
} }
put_character_at(m_cursor_row, m_cursor_column, ch);
auto new_column = m_cursor_column + 1; auto new_column = m_cursor_column + 1;
if (new_column < columns()) if (new_column < columns()) {
put_character_at(m_cursor_row, m_cursor_column, ch);
set_cursor(m_cursor_row, new_column); set_cursor(m_cursor_row, new_column);
else } else {
scroll_up(); if (m_stomp) {
m_stomp = false;
scroll_up();
put_character_at(m_cursor_row, m_cursor_column, ch);
set_cursor(m_cursor_row, 1);
} else {
// Curious: We wait once on the right-hand side
m_stomp = true;
put_character_at(m_cursor_row, m_cursor_column, ch);
}
}
} }
void Terminal::set_size(word columns, word rows) void Terminal::set_size(word columns, word rows)

View file

@ -72,6 +72,7 @@ private:
byte m_cursor_column { 0 }; byte m_cursor_column { 0 };
byte m_saved_cursor_row { 0 }; byte m_saved_cursor_row { 0 };
byte m_saved_cursor_column { 0 }; byte m_saved_cursor_column { 0 };
bool m_stomp { false };
Attribute m_current_attribute; Attribute m_current_attribute;

View file

@ -10,7 +10,7 @@
#include <SharedGraphics/Painter.h> #include <SharedGraphics/Painter.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/select.h> #include <sys/select.h>
#include <gui.h> #include <LibC/gui.h>
#include "Terminal.h" #include "Terminal.h"
static void make_shell(int ptm_fd) static void make_shell(int ptm_fd)
@ -43,7 +43,7 @@ static void make_shell(int ptm_fd)
perror("ioctl(TIOCSCTTY)"); perror("ioctl(TIOCSCTTY)");
exit(1); exit(1);
} }
rc = execve("/bin/sh", nullptr, nullptr); rc = execvp("/bin/sh", nullptr);
if (rc < 0) { if (rc < 0) {
perror("execve"); perror("execve");
exit(1); exit(1);
@ -111,18 +111,6 @@ int main(int, char**)
} }
assert(nread != 0); assert(nread != 0);
assert(nread == sizeof(event)); assert(nread == sizeof(event));
dbgprintf("(Terminal:%d) ", getpid());
switch (event.type) {
case GUI_Event::Type::Paint: dbgprintf("WID=%x Paint [%d,%d %dx%d]\n", event.window_id, event.paint.rect.location.x, event.paint.rect.location.y, event.paint.rect.size.width, event.paint.rect.size.height); break;
case GUI_Event::Type::MouseDown: dbgprintf("WID=%x MouseDown %d,%d\n", event.window_id, event.mouse.position.x, event.mouse.position.y); break;
case GUI_Event::Type::MouseUp: dbgprintf("WID=%x MouseUp %d,%d\n", event.window_id, event.mouse.position.x, event.mouse.position.y); break;
case GUI_Event::Type::MouseMove: dbgprintf("WID=%x MouseMove %d,%d\n", event.window_id, event.mouse.position.x, event.mouse.position.y); break;
case GUI_Event::Type::KeyDown: dbgprintf("WID=%x KeyDown 0x%b (%c)\n", event.window_id, event.key.character, event.key.character); break;
case GUI_Event::Type::WindowActivated: dbgprintf("WID=%x WindowActivated\n", event.window_id); break;
case GUI_Event::Type::WindowDeactivated: dbgprintf("WID=%x WindowDeactivated\n", event.window_id); break;
default:
ASSERT_NOT_REACHED();
}
if (event.type == GUI_Event::Type::Paint) { if (event.type == GUI_Event::Type::Paint) {
terminal.paint(); terminal.paint();