Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Games
KMuddy
Commits
9ffa69e1
Commit
9ffa69e1
authored
May 25, 2019
by
Tomas Mecir
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
don't spam NAWS all the time
parent
faa01e04
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
38 deletions
+40
-38
kmuddy/ctelnet.cpp
kmuddy/ctelnet.cpp
+31
-30
libs/cconsole.cpp
libs/cconsole.cpp
+8
-7
libs/cconsole.h
libs/cconsole.h
+1
-1
No files found.
kmuddy/ctelnet.cpp
View file @
9ffa69e1
...
@@ -293,6 +293,9 @@ void cTelnet::reset ()
...
@@ -293,6 +293,9 @@ void cTelnet::reset ()
//reset telnet status
//reset telnet status
d
->
iac
=
d
->
iac2
=
d
->
insb
=
false
;
d
->
iac
=
d
->
iac2
=
d
->
insb
=
false
;
d
->
command
=
""
;
d
->
command
=
""
;
// reset these so that we report dimensions correctly
d
->
curX
=
0
;
d
->
curY
=
0
;
}
}
void
cTelnet
::
socketConnected
()
void
cTelnet
::
socketConnected
()
...
@@ -519,39 +522,37 @@ void cTelnet::windowSizeChanged (int x, int y)
...
@@ -519,39 +522,37 @@ void cTelnet::windowSizeChanged (int x, int y)
//remember the size - we'll need it if NAWS is currently disabled but will
//remember the size - we'll need it if NAWS is currently disabled but will
//be enabled. Also remember it if no connection exists at the moment;
//be enabled. Also remember it if no connection exists at the moment;
//we won't be called again when connecting
//we won't be called again when connecting
d
->
curX
=
x
;
d
->
curY
=
y
;
if
(
!
(
isConnected
()))
if
(
!
(
isConnected
()))
return
;
return
;
if
(
d
->
myOptionState
[
OPT_NAWS
])
//only if we have negotiated this option
if
(
!
d
->
myOptionState
[
OPT_NAWS
])
return
;
//only if we have negotiated this option
{
if
((
x
==
d
->
curX
)
&&
(
y
==
d
->
curY
))
return
;
// don't spam sizes if we have sent the current one already
string
s
;
s
=
TN_IAC
;
string
s
;
s
+=
TN_SB
;
s
=
TN_IAC
;
s
+=
OPT_NAWS
;
s
+=
TN_SB
;
unsigned
char
x1
,
x2
,
y1
,
y2
;
s
+=
OPT_NAWS
;
x1
=
(
unsigned
char
)
x
/
256
;
unsigned
char
x1
,
x2
,
y1
,
y2
;
x2
=
(
unsigned
char
)
x
%
256
;
x1
=
(
unsigned
char
)
x
/
256
;
y1
=
(
unsigned
char
)
y
/
256
;
x2
=
(
unsigned
char
)
x
%
256
;
y2
=
(
unsigned
char
)
y
%
256
;
y1
=
(
unsigned
char
)
y
/
256
;
//IAC must be doubled
y2
=
(
unsigned
char
)
y
%
256
;
s
+=
x1
;
//IAC must be doubled
if
(
x1
==
TN_IAC
)
s
+=
x1
;
s
+=
TN_IAC
;
if
(
x1
==
TN_IAC
)
s
+=
x2
;
if
(
x2
==
TN_IAC
)
s
+=
TN_IAC
;
s
+=
y1
;
if
(
y1
==
TN_IAC
)
s
+=
TN_IAC
;
s
+=
y2
;
if
(
y2
==
TN_IAC
)
s
+=
TN_IAC
;
s
+=
TN_IAC
;
s
+=
TN_IAC
;
s
+=
TN_SE
;
s
+=
x2
;
doSendData
(
s
);
if
(
x2
==
TN_IAC
)
}
s
+=
TN_IAC
;
s
+=
y1
;
if
(
y1
==
TN_IAC
)
s
+=
TN_IAC
;
s
+=
y2
;
if
(
y2
==
TN_IAC
)
s
+=
TN_IAC
;
s
+=
TN_IAC
;
s
+=
TN_SE
;
doSendData
(
s
);
}
}
void
cTelnet
::
sendTelnetOption
(
unsigned
char
type
,
unsigned
char
option
)
void
cTelnet
::
sendTelnetOption
(
unsigned
char
type
,
unsigned
char
option
)
...
...
libs/cconsole.cpp
View file @
9ffa69e1
...
@@ -218,7 +218,7 @@ cConsole::cConsole(QWidget *parent) : QGraphicsView(parent) {
...
@@ -218,7 +218,7 @@ cConsole::cConsole(QWidget *parent) : QGraphicsView(parent) {
viewport
()
->
setCursor
(
Qt
::
IBeamCursor
);
viewport
()
->
setCursor
(
Qt
::
IBeamCursor
);
forceBeginOfLine
();
forceBeginOfLine
();
fixupOutput
();
fixupOutput
(
true
);
}
}
cConsole
::~
cConsole
()
{
cConsole
::~
cConsole
()
{
...
@@ -242,7 +242,7 @@ void cConsole::setFont (QFont f) {
...
@@ -242,7 +242,7 @@ void cConsole::setFont (QFont f) {
d
->
charWidth
=
fm
.
width
(
"m"
);
d
->
charWidth
=
fm
.
width
(
"m"
);
d
->
charHeight
=
fm
.
lineSpacing
()
+
2
;
d
->
charHeight
=
fm
.
lineSpacing
()
+
2
;
fixupOutput
();
fixupOutput
(
true
);
}
}
QFont
cConsole
::
font
()
{
QFont
cConsole
::
font
()
{
...
@@ -415,7 +415,7 @@ void cConsole::addNewText (cTextChunk *chunk, bool endTheLine)
...
@@ -415,7 +415,7 @@ void cConsole::addNewText (cTextChunk *chunk, bool endTheLine)
if
(
!
d
->
atBottom
)
bar
->
setValue
(
bar
->
value
()
-
fheight
);
if
(
!
d
->
atBottom
)
bar
->
setValue
(
bar
->
value
()
-
fheight
);
}
}
fixupOutput
();
fixupOutput
(
false
);
}
}
void
cConsole
::
forceBeginOfLine
()
{
void
cConsole
::
forceBeginOfLine
()
{
...
@@ -459,14 +459,14 @@ void cConsole::pageDown () {
...
@@ -459,14 +459,14 @@ void cConsole::pageDown () {
void
cConsole
::
resizeEvent
(
QResizeEvent
*
)
void
cConsole
::
resizeEvent
(
QResizeEvent
*
)
{
{
fixupOutput
();
fixupOutput
(
true
);
}
}
// this is needed to resize the text display at startup
// this is needed to resize the text display at startup
bool
cConsole
::
viewportEvent
(
QEvent
*
event
)
bool
cConsole
::
viewportEvent
(
QEvent
*
event
)
{
{
if
(
event
->
type
()
==
QEvent
::
Resize
)
if
(
event
->
type
()
==
QEvent
::
Resize
)
fixupOutput
();
fixupOutput
(
true
);
return
QGraphicsView
::
viewportEvent
(
event
);
return
QGraphicsView
::
viewportEvent
(
event
);
}
}
...
@@ -493,7 +493,7 @@ void cConsole::scrollContentsBy (int dx, int dy)
...
@@ -493,7 +493,7 @@ void cConsole::scrollContentsBy (int dx, int dy)
adjustScrollBack
();
adjustScrollBack
();
}
}
void
cConsole
::
fixupOutput
()
void
cConsole
::
fixupOutput
(
bool
sizeChanged
)
{
{
double
h
=
max
((
qreal
)
viewport
()
->
height
(),
d
->
text
->
documentLayout
()
->
documentSize
().
height
());
double
h
=
max
((
qreal
)
viewport
()
->
height
(),
d
->
text
->
documentLayout
()
->
documentSize
().
height
());
scene
()
->
setSceneRect
(
0
,
0
,
viewport
()
->
width
(),
h
);
scene
()
->
setSceneRect
(
0
,
0
,
viewport
()
->
width
(),
h
);
...
@@ -503,7 +503,8 @@ void cConsole::fixupOutput ()
...
@@ -503,7 +503,8 @@ void cConsole::fixupOutput ()
d
->
scrollText
->
updateSize
();
d
->
scrollText
->
updateSize
();
adjustScrollBack
();
adjustScrollBack
();
forceEmitSize
();
if
(
sizeChanged
)
forceEmitSize
();
}
}
void
cConsole
::
linkHovered
(
const
QString
&
link
)
void
cConsole
::
linkHovered
(
const
QString
&
link
)
...
...
libs/cconsole.h
View file @
9ffa69e1
...
@@ -116,7 +116,7 @@ protected:
...
@@ -116,7 +116,7 @@ protected:
bool
viewportEvent
(
QEvent
*
event
)
override
;
bool
viewportEvent
(
QEvent
*
event
)
override
;
virtual
void
scrollContentsBy
(
int
dx
,
int
dy
)
override
;
virtual
void
scrollContentsBy
(
int
dx
,
int
dy
)
override
;
/** called when resizing and when changing font */
/** called when resizing and when changing font */
void
fixupOutput
();
void
fixupOutput
(
bool
sizeChanged
=
false
);
void
adjustScrollBack
();
void
adjustScrollBack
();
void
addNewText
(
cTextChunk
*
chunk
,
bool
endTheLine
);
void
addNewText
(
cTextChunk
*
chunk
,
bool
endTheLine
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment