mirror of
https://github.com/RGBCube/serenity
synced 2025-07-05 05:47:37 +00:00
Terminal: Enough compat work for Lynx to actually load web pages.
This commit is contained in:
parent
ee0f00c644
commit
b7ad35d040
3 changed files with 70 additions and 8 deletions
|
@ -316,8 +316,10 @@ void Terminal::escape$K(const Vector<unsigned>& params)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
// FIXME: Clear from cursor to beginning of screen.
|
// Clear from cursor to beginning of line.
|
||||||
unimplemented_escape();
|
for (int i = 0; i < m_cursor_column; ++i) {
|
||||||
|
put_character_at(m_cursor_row, i, ' ');
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
unimplemented_escape();
|
unimplemented_escape();
|
||||||
|
@ -504,7 +506,10 @@ void Terminal::on_char(byte ch)
|
||||||
case ExpectBracket:
|
case ExpectBracket:
|
||||||
if (ch == '[')
|
if (ch == '[')
|
||||||
m_escape_state = ExpectParameter;
|
m_escape_state = ExpectParameter;
|
||||||
else if (ch == ']')
|
else if (ch == '(') {
|
||||||
|
m_swallow_current = true;
|
||||||
|
m_escape_state = ExpectParameter;
|
||||||
|
} else if (ch == ']')
|
||||||
m_escape_state = ExpectXtermParameter1;
|
m_escape_state = ExpectXtermParameter1;
|
||||||
else
|
else
|
||||||
m_escape_state = Normal;
|
m_escape_state = Normal;
|
||||||
|
@ -545,10 +550,13 @@ void Terminal::on_char(byte ch)
|
||||||
case ExpectFinal:
|
case ExpectFinal:
|
||||||
if (is_valid_final_character(ch)) {
|
if (is_valid_final_character(ch)) {
|
||||||
m_escape_state = Normal;
|
m_escape_state = Normal;
|
||||||
|
if (!m_swallow_current)
|
||||||
execute_escape_sequence(ch);
|
execute_escape_sequence(ch);
|
||||||
|
m_swallow_current = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_escape_state = Normal;
|
m_escape_state = Normal;
|
||||||
|
m_swallow_current = false;
|
||||||
return;
|
return;
|
||||||
case Normal:
|
case Normal:
|
||||||
break;
|
break;
|
||||||
|
@ -559,6 +567,7 @@ void Terminal::on_char(byte ch)
|
||||||
return;
|
return;
|
||||||
case '\033':
|
case '\033':
|
||||||
m_escape_state = ExpectBracket;
|
m_escape_state = ExpectBracket;
|
||||||
|
m_swallow_current = false;
|
||||||
return;
|
return;
|
||||||
case 8: // Backspace
|
case 8: // Backspace
|
||||||
if (m_cursor_column) {
|
if (m_cursor_column) {
|
||||||
|
|
|
@ -145,6 +145,8 @@ private:
|
||||||
|
|
||||||
int m_ptm_fd { -1 };
|
int m_ptm_fd { -1 };
|
||||||
|
|
||||||
|
bool m_swallow_current { false };
|
||||||
|
|
||||||
bool m_in_active_window { false };
|
bool m_in_active_window { false };
|
||||||
bool m_need_full_flush { false };
|
bool m_need_full_flush { false };
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include <alloca.h>
|
#include <alloca.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <ctype.h>
|
||||||
#include <AK/Assertions.h>
|
#include <AK/Assertions.h>
|
||||||
#include <AK/Types.h>
|
#include <AK/Types.h>
|
||||||
#include <Kernel/Syscall.h>
|
#include <Kernel/Syscall.h>
|
||||||
|
@ -404,11 +405,61 @@ int atexit(void (*function)())
|
||||||
assert(false);
|
assert(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
long strtol(const char*, char** endptr, int base)
|
long strtol(const char* str, char** endptr, int base)
|
||||||
{
|
{
|
||||||
(void)endptr;
|
const char* s = str;
|
||||||
(void)base;
|
unsigned long acc;
|
||||||
assert(false);
|
int c;
|
||||||
|
unsigned long cutoff;
|
||||||
|
int neg = 0;
|
||||||
|
int any;
|
||||||
|
int cutlim;
|
||||||
|
|
||||||
|
do {
|
||||||
|
c = *s++;
|
||||||
|
} while (isspace(c));
|
||||||
|
if (c == '-') {
|
||||||
|
neg = 1;
|
||||||
|
c = *s++;
|
||||||
|
} else if (c == '+')
|
||||||
|
c = *s++;
|
||||||
|
if ((base == 0 || base == 16) &&
|
||||||
|
c == '0' && (*s == 'x' || *s == 'X')) {
|
||||||
|
c = s[1];
|
||||||
|
s += 2;
|
||||||
|
base = 16;
|
||||||
|
}
|
||||||
|
if (base == 0)
|
||||||
|
base = c == '0' ? 8 : 10;
|
||||||
|
|
||||||
|
cutoff = neg ? -(unsigned long)LONG_MIN : LONG_MAX;
|
||||||
|
cutlim = cutoff % (unsigned long)base;
|
||||||
|
cutoff /= (unsigned long)base;
|
||||||
|
for (acc = 0, any = 0;; c = *s++) {
|
||||||
|
if (isdigit(c))
|
||||||
|
c -= '0';
|
||||||
|
else if (isalpha(c))
|
||||||
|
c -= isupper(c) ? 'A' - 10 : 'a' - 10;
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
if (c >= base)
|
||||||
|
break;
|
||||||
|
if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
|
||||||
|
any = -1;
|
||||||
|
else {
|
||||||
|
any = 1;
|
||||||
|
acc *= base;
|
||||||
|
acc += c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (any < 0) {
|
||||||
|
acc = neg ? LONG_MIN : LONG_MAX;
|
||||||
|
errno = ERANGE;
|
||||||
|
} else if (neg)
|
||||||
|
acc = -acc;
|
||||||
|
if (endptr)
|
||||||
|
*endptr = (char*)(any ? s - 1 : str);
|
||||||
|
return acc;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long strtoul(const char*, char** endptr, int base)
|
unsigned long strtoul(const char*, char** endptr, int base)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue