mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-24 10:22:05 -05:00
Terminal: Various improvements to terminal emulation.
This commit is contained in:
parent
8d36c8f0d8
commit
faaa0dbf1d
3 changed files with 20 additions and 20 deletions
|
@ -376,6 +376,8 @@ void Terminal::set_cursor(unsigned row, unsigned column)
|
|||
invalidate_cursor();
|
||||
m_cursor_row = row;
|
||||
m_cursor_column = column;
|
||||
if (column != columns() - 1)
|
||||
m_stomp = false;
|
||||
invalidate_cursor();
|
||||
}
|
||||
|
||||
|
@ -438,7 +440,7 @@ void Terminal::on_char(byte ch)
|
|||
put_character_at(m_cursor_row, m_cursor_column, ' ');
|
||||
return;
|
||||
}
|
||||
break;
|
||||
return;
|
||||
case '\a':
|
||||
// FIXME: Bell!
|
||||
return;
|
||||
|
@ -459,13 +461,22 @@ void Terminal::on_char(byte ch)
|
|||
return;
|
||||
}
|
||||
|
||||
put_character_at(m_cursor_row, m_cursor_column, ch);
|
||||
|
||||
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);
|
||||
else
|
||||
scroll_up();
|
||||
} else {
|
||||
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)
|
||||
|
|
|
@ -72,6 +72,7 @@ private:
|
|||
byte m_cursor_column { 0 };
|
||||
byte m_saved_cursor_row { 0 };
|
||||
byte m_saved_cursor_column { 0 };
|
||||
bool m_stomp { false };
|
||||
|
||||
Attribute m_current_attribute;
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <SharedGraphics/Painter.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/select.h>
|
||||
#include <gui.h>
|
||||
#include <LibC/gui.h>
|
||||
#include "Terminal.h"
|
||||
|
||||
static void make_shell(int ptm_fd)
|
||||
|
@ -43,7 +43,7 @@ static void make_shell(int ptm_fd)
|
|||
perror("ioctl(TIOCSCTTY)");
|
||||
exit(1);
|
||||
}
|
||||
rc = execve("/bin/sh", nullptr, nullptr);
|
||||
rc = execvp("/bin/sh", nullptr);
|
||||
if (rc < 0) {
|
||||
perror("execve");
|
||||
exit(1);
|
||||
|
@ -111,18 +111,6 @@ int main(int, char**)
|
|||
}
|
||||
assert(nread != 0);
|
||||
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) {
|
||||
terminal.paint();
|
||||
|
|
Loading…
Add table
Reference in a new issue