mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 00:42:44 +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; | ||||
|     case 1: | ||||
|         // FIXME: Clear from cursor to beginning of screen.
 | ||||
|         unimplemented_escape(); | ||||
|         // Clear from cursor to beginning of line.
 | ||||
|         for (int i = 0; i < m_cursor_column; ++i) { | ||||
|             put_character_at(m_cursor_row, i, ' '); | ||||
|         } | ||||
|         break; | ||||
|     case 2: | ||||
|         unimplemented_escape(); | ||||
|  | @ -504,7 +506,10 @@ void Terminal::on_char(byte ch) | |||
|     case ExpectBracket: | ||||
|         if (ch == '[') | ||||
|             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; | ||||
|         else | ||||
|             m_escape_state = Normal; | ||||
|  | @ -545,10 +550,13 @@ void Terminal::on_char(byte ch) | |||
|     case ExpectFinal: | ||||
|         if (is_valid_final_character(ch)) { | ||||
|             m_escape_state = Normal; | ||||
|             execute_escape_sequence(ch); | ||||
|             if (!m_swallow_current) | ||||
|                 execute_escape_sequence(ch); | ||||
|             m_swallow_current = false; | ||||
|             return; | ||||
|         } | ||||
|         m_escape_state = Normal; | ||||
|         m_swallow_current = false; | ||||
|         return; | ||||
|     case Normal: | ||||
|         break; | ||||
|  | @ -559,6 +567,7 @@ void Terminal::on_char(byte ch) | |||
|         return; | ||||
|     case '\033': | ||||
|         m_escape_state = ExpectBracket; | ||||
|         m_swallow_current = false; | ||||
|         return; | ||||
|     case 8: // Backspace
 | ||||
|         if (m_cursor_column) { | ||||
|  |  | |||
|  | @ -145,6 +145,8 @@ private: | |||
| 
 | ||||
|     int m_ptm_fd { -1 }; | ||||
| 
 | ||||
|     bool m_swallow_current { false }; | ||||
| 
 | ||||
|     bool m_in_active_window { false }; | ||||
|     bool m_need_full_flush { false }; | ||||
| 
 | ||||
|  |  | |||
|  | @ -6,6 +6,7 @@ | |||
| #include <alloca.h> | ||||
| #include <assert.h> | ||||
| #include <errno.h> | ||||
| #include <ctype.h> | ||||
| #include <AK/Assertions.h> | ||||
| #include <AK/Types.h> | ||||
| #include <Kernel/Syscall.h> | ||||
|  | @ -404,11 +405,61 @@ int atexit(void (*function)()) | |||
|     assert(false); | ||||
| } | ||||
| 
 | ||||
| long strtol(const char*, char** endptr, int base) | ||||
| long strtol(const char* str, char** endptr, int base) | ||||
| { | ||||
|     (void)endptr; | ||||
|     (void)base; | ||||
|     assert(false); | ||||
|     const char* s = str; | ||||
|     unsigned long acc; | ||||
|     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) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling