Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
0f87d4e2
Commit
0f87d4e2
authored
5 months ago
by
Deucе
Browse files
Options
Downloads
Patches
Plain Diff
Keep a local copy of the screen for windows
Because it screws up the display when you resize the window.
parent
5e8b936c
No related branches found
No related tags found
No related merge requests found
Pipeline
#6907
passed
5 months ago
Stage: build
Stage: test
Stage: cleanup
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/conio/win32cio.c
+30
-6
30 additions, 6 deletions
src/conio/win32cio.c
with
30 additions
and
6 deletions
src/conio/win32cio.c
+
30
−
6
View file @
0f87d4e2
...
...
@@ -125,6 +125,9 @@ CIOLIBEXPORT const struct keyvals keyval[] =
{
0
,
0
,
0
,
0
,
0
}
/** END **/
};
static
uint8_t
*
win32cio_buffer
=
NULL
;
static
size_t
win32cio_buffer_sz
=
0
;
/* Mouse related stuff */
static
int
domouse
=
1
;
static
DWORD
last_state
=
0
;
...
...
@@ -272,10 +275,8 @@ static int win32_keyboardio(int isgetch)
switch
(
input
.
EventType
)
{
case
WINDOW_BUFFER_SIZE_EVENT
:
if
(
input
.
Event
.
WindowBufferSizeEvent
.
dwSize
.
X
!=
cio_textinfo
.
screenwidth
||
input
.
Event
.
WindowBufferSizeEvent
.
dwSize
.
Y
!=
cio_textinfo
.
screenheight
)
{
struct
ciolib_screen
*
screen
=
savescreen
();
win32_textmode
(
cio_textinfo
.
currmode
);
restorescreen
(
screen
);
freescreen
(
screen
);
win32_puttext
(
1
,
1
,
cio_textinfo
.
screenwidth
,
cio_textinfo
.
screenheight
,
win32cio_buffer
);
}
break
;
case
KEY_EVENT
:
...
...
@@ -652,6 +653,22 @@ void win32_textmode(int mode)
modeidx
=
find_vmode
(
mode
);
if
(
modeidx
==
-
1
)
modeidx
=
C80
;
if
(
cio_textinfo
.
currmode
!=
vparams
[
modeidx
].
mode
)
{
size_t
newsz
=
vparams
[
modeidx
].
cols
*
vparams
[
modeidx
].
rows
*
2
;
void
*
tmpbuf
=
realloc
(
win32cio_buffer
,
newsz
);
if
(
tmpbuf
==
NULL
)
{
// Nothing useful to do here.
MessageBoxA
(
NULL
,
"Error reallocating win32cio_buffer"
,
"realloc() failure"
,
MB_OK
|
MB_ICONERROR
);
exit
(
1
);
}
win32cio_buffer
=
tmpbuf
;
win32cio_buffer_sz
=
newsz
;
for
(
i
=
0
;
i
<
newsz
;
i
+=
2
)
{
win32cio_buffer
[
i
]
=
' '
;
win32cio_buffer
[
i
+
1
]
=
vparams
[
modeidx
].
default_attr
;
}
}
sz
.
X
=
cio_textinfo
.
screenwidth
>
vparams
[
modeidx
].
cols
?
cio_textinfo
.
screenwidth
:
vparams
[
modeidx
].
cols
;
sz
.
Y
=
cio_textinfo
.
screenheight
>
vparams
[
modeidx
].
rows
?
cio_textinfo
.
screenheight
:
vparams
[
modeidx
].
rows
;
rc
.
Left
=
0
;
...
...
@@ -662,9 +679,14 @@ void win32_textmode(int mode)
if
((
h
=
GetStdHandle
(
STD_OUTPUT_HANDLE
))
==
INVALID_HANDLE_VALUE
)
return
;
if
(
!
SetConsoleScreenBufferSize
(
h
,
sz
))
{
// Apparently this fails if it's already the specified size.
if
(
GetLastError
()
!=
0xb7
)
return
;
// Note: This fails and returns here with large windows (e.g. width > 255)
DWORD
err
=
GetLastError
();
switch
(
err
)
{
case
0xb7
:
// Apparently this fails if it's already the specified size.
case
0x57
:
// And also if it's smaller than the view rect
break
;
default:
return
;
}
}
if
(
!
SetConsoleWindowInfo
(
h
,
TRUE
,
&
rc
))
return
;
...
...
@@ -787,6 +809,8 @@ int win32_puttext(int left, int top, int right, int bottom, void* buf)
reg
.
Bottom
=
bottom
-
1
;
ci
=
(
CHAR_INFO
*
)
alloca
(
sizeof
(
CHAR_INFO
)
*
(
bs
.
X
*
bs
.
Y
));
for
(
y
=
0
;
y
<
bs
.
Y
;
y
++
)
{
if
(
buf
!=
win32cio_buffer
)
memcpy
(
&
win32cio_buffer
[(
cio_textinfo
.
screenwidth
*
((
top
-
1
)
+
y
)
+
(
left
-
1
))
*
2
],
&
bu
[
y
*
bs
.
X
*
2
],
bs
.
X
*
2
);
for
(
x
=
0
;
x
<
bs
.
X
;
x
++
)
{
ci
[(
y
*
bs
.
X
)
+
x
].
Char
.
AsciiChar
=
bu
[((
y
*
bs
.
X
)
+
x
)
*
2
];
ci
[(
y
*
bs
.
X
)
+
x
].
Attributes
=
DOStoWinAttr
(
bu
[(((
y
*
bs
.
X
)
+
x
)
*
2
)
+
1
]);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment