mirror of
https://github.com/taigrr/arduinolibs
synced 2025-01-18 04:33:12 -08:00
Fixes to telnet window size handling
This commit is contained in:
parent
e9e48c0703
commit
57fb8f2fe3
@ -679,7 +679,7 @@ int Terminal::readKey()
|
||||
break;
|
||||
}
|
||||
if (utf8len < sizeof(sb))
|
||||
sb[utf8len++] = 0xFF;
|
||||
sb[utf8len++] = ch;
|
||||
break;
|
||||
|
||||
case STATE_SB_IAC:
|
||||
@ -699,20 +699,14 @@ int Terminal::readKey()
|
||||
width = ncols;
|
||||
if (!height)
|
||||
height = nrows;
|
||||
|
||||
// Filter out obviously bogus values.
|
||||
if (width >= 1 && height >= 1 && width <= 10000 && height <= 10000) {
|
||||
if (width != ncols || height != nrows) {
|
||||
if (setWindowSize(width, height)) {
|
||||
// The window size has changed; notify the caller.
|
||||
ncols = width;
|
||||
nrows = height;
|
||||
ucode = -1;
|
||||
state = STATE_INIT;
|
||||
return KEY_WINSIZE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
state = STATE_INIT;
|
||||
break;
|
||||
}
|
||||
@ -781,6 +775,8 @@ size_t Terminal::writeUnicode(long code)
|
||||
* \param columns The number of columns between 1 and 10000.
|
||||
* \param rows The number of rows between 1 and 10000.
|
||||
*
|
||||
* \return Returns true if the window size has changed.
|
||||
*
|
||||
* This function should be used if the application has some information
|
||||
* about the actual window size. For serial ports, this usually isn't
|
||||
* available but telnet and ssh sessions can get the window size from
|
||||
@ -794,7 +790,7 @@ size_t Terminal::writeUnicode(long code)
|
||||
*
|
||||
* \sa columns(), rows(), readKey()
|
||||
*/
|
||||
void Terminal::setWindowSize(int columns, int rows)
|
||||
bool Terminal::setWindowSize(int columns, int rows)
|
||||
{
|
||||
// Sanity-check the range first.
|
||||
if (columns < 1)
|
||||
@ -805,8 +801,13 @@ void Terminal::setWindowSize(int columns, int rows)
|
||||
rows = 1;
|
||||
else if (rows > 10000)
|
||||
rows = 10000;
|
||||
if (ncols != columns || nrows != rows) {
|
||||
ncols = columns;
|
||||
nrows = rows;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -71,7 +71,7 @@ public:
|
||||
int columns() const { return ncols; }
|
||||
int rows() const { return nrows; }
|
||||
|
||||
void setWindowSize(int columns, int rows);
|
||||
bool setWindowSize(int columns, int rows);
|
||||
|
||||
void clear();
|
||||
void clearToEOL();
|
||||
@ -135,7 +135,7 @@ private:
|
||||
uint8_t state;
|
||||
uint8_t utf8len;
|
||||
uint8_t mod;
|
||||
uint8_t sb[16];
|
||||
uint8_t sb[8];
|
||||
uint8_t flags;
|
||||
|
||||
int matchEscape(int ch);
|
||||
|
Loading…
x
Reference in New Issue
Block a user