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
1d08b781
Commit
1d08b781
authored
13 years ago
by
deuce
Browse files
Options
Downloads
Patches
Plain Diff
Use macros for conio functions so that the non-conio ones can take a pointer
to the cterminal structure to permit thread safety.
parent
835a8cc1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/conio/cterm.c
+278
-235
278 additions, 235 deletions
src/conio/cterm.c
src/conio/cterm.h
+20
-0
20 additions, 0 deletions
src/conio/cterm.h
with
298 additions
and
235 deletions
src/conio/cterm.c
+
278
−
235
View file @
1d08b781
...
...
@@ -171,6 +171,49 @@ struct note_params {
int
foreground
;
};
#ifdef CTERM_WITHOUT_CONIO
#define GOTOXY(x,y) cterm->ciolib_gotoxy(cterm, x, y)
#define WHEREX() cterm->ciolib_wherex(cterm)
#define WHEREY() cterm->ciolib_wherey(cterm)
#define GETTEXT(a,b,c,d,e) cterm->ciolib_gettext(cterm, a,b,c,d,e)
#define GETTEXTINFO(a) cterm->ciolib_gettextinfo(cterm,a)
#define TEXTATTR(a) cterm->ciolib_textattr(cterm,a)
#define SETCURSORTYPE(a) cterm->ciolib_setcursortype(cterm,a)
#define MOVETEXT(a,b,c,d,e,f) cterm->ciolib_movetext(cterm,a,b,c,d,e,f)
#define CLREOL() cterm->ciolib_clreol(cterm)
#define CLRSCR() cterm->ciolib_clrscr(cterm)
#define SETVIDEOFLAGS(a) cterm->ciolib_setvideoflags(cterm,a)
#define GETVIDEOFLAGS() cterm->ciolib_getvideoflags(cterm)
#define PUTCH(a) cterm->ciolib_putch(cterm,a)
#define PUTTEXT(a,b,c,d,e) cterm->ciolib_puttext(cterm,a,b,c,d,e)
#define WINDOW(a,b,c,d) cterm->ciolib_window(cterm,a,b,c,d)
#define CPUTS(a) cterm->ciolib_cputs(cterm,a)
#define SETFONT(a,b,c) cterm->ciolib_setfont(cterm,a,b,c)
#else
#define GOTOXY(x,y) cterm->ciolib_gotoxy(x, y)
#define WHEREX() cterm->ciolib_wherex()
#define WHEREY() cterm->ciolib_wherey()
#define GETTEXT(a,b,c,d,e) cterm->ciolib_gettext(a,b,c,d,e)
#define GETTEXTINFO(a) cterm->ciolib_gettextinfo(a)
#define TEXTATTR(a) cterm->ciolib_textattr(a)
#define SETCURSORTYPE(a) cterm->ciolib_setcursortype(a)
#define MOVETEXT(a,b,c,d,e,f) cterm->ciolib_movetext(a,b,c,d,e,f)
#define CLREOL() cterm->ciolib_clreol()
#define CLRSCR() cterm->ciolib_clrscr()
#define SETVIDEOFLAGS(a) cterm->ciolib_setvideoflags(a)
#define GETVIDEOFLAGS() cterm->ciolib_getvideoflags()
#define PUTCH(a) cterm->ciolib_putch(a)
#define PUTTEXT(a,b,c,d,e) cterm->ciolib_puttext(a,b,c,d,e)
#define WINDOW(a,b,c,d) cterm->ciolib_window(a,b,c,d)
#define CPUTS(a) cterm->ciolib_cputs(a)
#define SETFONT(a,b,c) cterm->ciolib_setfont(a,b,c)
#endif
#ifdef CTERM_WITHOUT_CONIO
/*********************************************/
/* These funcions are used when conio is not */
/*********************************************/
#endif
static
void
playnote_thread
(
void
*
args
)
{
...
...
@@ -444,12 +487,12 @@ static void scrolldown(struct cterminal *cterm)
{
int
x
,
y
;
cterm
->
movetext
(
cterm
->
x
,
cterm
->
y
,
cterm
->
x
+
cterm
->
width
-
1
,
cterm
->
y
+
cterm
->
height
-
2
,
cterm
->
x
,
cterm
->
y
+
1
);
x
=
cterm
->
wherex
();
y
=
cterm
->
wherey
();
cterm
->
gotoxy
(
1
,
1
);
cterm
->
clreol
();
cterm
->
gotoxy
(
x
,
y
);
MOVETEXT
(
cterm
->
x
,
cterm
->
y
,
cterm
->
x
+
cterm
->
width
-
1
,
cterm
->
y
+
cterm
->
height
-
2
,
cterm
->
x
,
cterm
->
y
+
1
);
x
=
WHEREX
();
y
=
WHEREY
();
GOTOXY
(
1
,
1
);
CLREOL
();
GOTOXY
(
x
,
y
);
}
static
void
scrollup
(
struct
cterminal
*
cterm
)
...
...
@@ -462,14 +505,14 @@ static void scrollup(struct cterminal *cterm)
memmove
(
cterm
->
scrollback
,
cterm
->
scrollback
+
cterm
->
width
*
2
,
cterm
->
width
*
2
*
(
cterm
->
backlines
-
1
));
cterm
->
backpos
--
;
}
cterm
->
gettext
(
cterm
->
x
,
cterm
->
y
,
cterm
->
x
+
cterm
->
width
-
1
,
cterm
->
y
,
cterm
->
scrollback
+
(
cterm
->
backpos
-
1
)
*
cterm
->
width
*
2
);
GETTEXT
(
cterm
->
x
,
cterm
->
y
,
cterm
->
x
+
cterm
->
width
-
1
,
cterm
->
y
,
cterm
->
scrollback
+
(
cterm
->
backpos
-
1
)
*
cterm
->
width
*
2
);
}
cterm
->
movetext
(
cterm
->
x
,
cterm
->
y
+
1
,
cterm
->
x
+
cterm
->
width
-
1
,
cterm
->
y
+
cterm
->
height
-
1
,
cterm
->
x
,
cterm
->
y
);
x
=
cterm
->
wherex
();
y
=
cterm
->
wherey
();
cterm
->
gotoxy
(
1
,
cterm
->
height
);
cterm
->
clreol
();
cterm
->
gotoxy
(
x
,
y
);
MOVETEXT
(
cterm
->
x
,
cterm
->
y
+
1
,
cterm
->
x
+
cterm
->
width
-
1
,
cterm
->
y
+
cterm
->
height
-
1
,
cterm
->
x
,
cterm
->
y
);
x
=
WHEREX
();
y
=
WHEREY
();
GOTOXY
(
1
,
cterm
->
height
);
CLREOL
();
GOTOXY
(
x
,
y
);
}
static
void
dellines
(
struct
cterminal
*
cterm
,
int
lines
)
...
...
@@ -480,15 +523,15 @@ static void dellines(struct cterminal * cterm, int lines)
if
(
lines
<
1
)
return
;
linestomove
=
cterm
->
height
-
cterm
->
wherey
();
cterm
->
movetext
(
cterm
->
x
,
cterm
->
y
+
cterm
->
wherey
()
-
1
+
lines
,
cterm
->
x
+
cterm
->
width
-
1
,
cterm
->
y
+
cterm
->
height
-
1
,
cterm
->
x
,
cterm
->
y
+
cterm
->
wherey
()
-
1
);
x
=
cterm
->
wherex
();
y
=
cterm
->
wherey
();
linestomove
=
cterm
->
height
-
WHEREY
();
MOVETEXT
(
cterm
->
x
,
cterm
->
y
+
WHEREY
()
-
1
+
lines
,
cterm
->
x
+
cterm
->
width
-
1
,
cterm
->
y
+
cterm
->
height
-
1
,
cterm
->
x
,
cterm
->
y
+
WHEREY
()
-
1
);
x
=
WHEREX
();
y
=
WHEREY
();
for
(
i
=
cterm
->
height
-
lines
+
1
;
i
<=
cterm
->
height
;
i
++
)
{
cterm
->
gotoxy
(
1
,
i
);
cterm
->
clreol
();
GOTOXY
(
1
,
i
);
CLREOL
();
}
cterm
->
gotoxy
(
x
,
y
);
GOTOXY
(
x
,
y
);
}
static
void
clear2bol
(
struct
cterminal
*
cterm
)
...
...
@@ -496,7 +539,7 @@ static void clear2bol(struct cterminal * cterm)
char
*
buf
;
int
i
,
j
,
k
;
k
=
cterm
->
wherex
();
k
=
WHEREX
();
buf
=
(
char
*
)
alloca
(
k
*
2
);
j
=
0
;
for
(
i
=
0
;
i
<
k
;
i
++
)
{
...
...
@@ -506,7 +549,7 @@ static void clear2bol(struct cterminal * cterm)
buf
[
j
++
]
=
' '
;
buf
[
j
++
]
=
cterm
->
attr
;
}
cterm
->
puttext
(
cterm
->
x
,
cterm
->
y
+
cterm
->
wherey
()
-
1
,
cterm
->
x
+
cterm
->
wherex
()
-
1
,
cterm
->
y
+
cterm
->
wherey
()
-
1
,
buf
);
PUTTEXT
(
cterm
->
x
,
cterm
->
y
+
WHEREY
()
-
1
,
cterm
->
x
+
WHEREX
()
-
1
,
cterm
->
y
+
WHEREY
()
-
1
,
buf
);
}
void
cterm_clearscreen
(
struct
cterminal
*
cterm
,
char
attr
)
...
...
@@ -520,10 +563,10 @@ void cterm_clearscreen(struct cterminal *cterm, char attr)
memmove
(
cterm
->
scrollback
,
cterm
->
scrollback
+
cterm
->
width
*
2
*
(
cterm
->
backpos
-
cterm
->
backlines
),
cterm
->
width
*
2
*
(
cterm
->
backlines
-
(
cterm
->
backpos
-
cterm
->
backlines
)));
cterm
->
backpos
=
cterm
->
backlines
;
}
cterm
->
gettext
(
cterm
->
x
,
cterm
->
y
,
cterm
->
x
+
cterm
->
width
-
1
,
cterm
->
y
+
cterm
->
height
-
1
,
cterm
->
scrollback
+
(
cterm
->
backpos
-
cterm
->
height
)
*
cterm
->
width
*
2
);
GETTEXT
(
cterm
->
x
,
cterm
->
y
,
cterm
->
x
+
cterm
->
width
-
1
,
cterm
->
y
+
cterm
->
height
-
1
,
cterm
->
scrollback
+
(
cterm
->
backpos
-
cterm
->
height
)
*
cterm
->
width
*
2
);
}
cterm
->
clrscr
();
cterm
->
gotoxy
(
1
,
1
);
CLRSCR
();
GOTOXY
(
1
,
1
);
}
static
void
do_ansi
(
struct
cterminal
*
cterm
,
char
*
retbuf
,
size_t
retsize
,
int
*
speed
)
...
...
@@ -560,22 +603,22 @@ static void do_ansi(struct cterminal *cterm, char *retbuf, size_t retsize, int *
case
'h'
:
if
(
!
strcmp
(
cterm
->
escbuf
,
"[?25h"
))
{
cterm
->
cursor
=
_NORMALCURSOR
;
cterm
->
_setcursortype
(
cterm
->
cursor
);
SETCURSORTYPE
(
cterm
->
cursor
);
}
if
(
!
strcmp
(
cterm
->
escbuf
,
"[?31h"
))
{
i
=
cterm
->
getvideoflags
();
i
=
GETVIDEOFLAGS
();
i
|=
CIOLIB_VIDEO_ALTCHARS
;
cterm
->
setvideoflags
(
i
);
SETVIDEOFLAGS
(
i
);
}
if
(
!
strcmp
(
cterm
->
escbuf
,
"[?32h"
))
{
i
=
cterm
->
getvideoflags
();
i
=
GETVIDEOFLAGS
();
i
|=
CIOLIB_VIDEO_NOBRIGHT
;
cterm
->
setvideoflags
(
i
);
SETVIDEOFLAGS
(
i
);
}
if
(
!
strcmp
(
cterm
->
escbuf
,
"[?33h"
))
{
i
=
cterm
->
getvideoflags
();
i
=
GETVIDEOFLAGS
();
i
|=
CIOLIB_VIDEO_BGBRIGHT
;
cterm
->
setvideoflags
(
i
);
SETVIDEOFLAGS
(
i
);
}
if
(
!
strcmp
(
cterm
->
escbuf
,
"[=255h"
))
cterm
->
doorway_mode
=
1
;
...
...
@@ -583,22 +626,22 @@ static void do_ansi(struct cterminal *cterm, char *retbuf, size_t retsize, int *
case
'l'
:
if
(
!
strcmp
(
cterm
->
escbuf
,
"[?25l"
))
{
cterm
->
cursor
=
_NOCURSOR
;
cterm
->
_setcursortype
(
cterm
->
cursor
);
SETCURSORTYPE
(
cterm
->
cursor
);
}
if
(
!
strcmp
(
cterm
->
escbuf
,
"[?31l"
))
{
i
=
cterm
->
getvideoflags
();
i
=
GETVIDEOFLAGS
();
i
&=~
CIOLIB_VIDEO_ALTCHARS
;
cterm
->
setvideoflags
(
i
);
SETVIDEOFLAGS
(
i
);
}
if
(
!
strcmp
(
cterm
->
escbuf
,
"[?32l"
))
{
i
=
cterm
->
getvideoflags
();
i
=
GETVIDEOFLAGS
();
i
&=~
CIOLIB_VIDEO_NOBRIGHT
;
cterm
->
setvideoflags
(
i
);
SETVIDEOFLAGS
(
i
);
}
if
(
!
strcmp
(
cterm
->
escbuf
,
"[?33l"
))
{
i
=
cterm
->
getvideoflags
();
i
=
GETVIDEOFLAGS
();
i
&=~
CIOLIB_VIDEO_BGBRIGHT
;
cterm
->
setvideoflags
(
i
);
SETVIDEOFLAGS
(
i
);
}
if
(
!
strcmp
(
cterm
->
escbuf
,
"[=255l"
))
cterm
->
doorway_mode
=
0
;
...
...
@@ -642,44 +685,44 @@ static void do_ansi(struct cterminal *cterm, char *retbuf, size_t retsize, int *
}
switch
(
*
p
)
{
case
'@'
:
/* Insert Char */
i
=
cterm
->
wherex
();
j
=
cterm
->
wherey
();
i
=
WHEREX
();
j
=
WHEREY
();
k
=
strtoul
(
cterm
->
escbuf
+
1
,
NULL
,
10
);
if
(
k
<
1
)
k
=
1
;
if
(
k
>
cterm
->
width
-
j
)
k
=
cterm
->
width
-
j
;
cterm
->
movetext
(
cterm
->
x
+
i
-
1
,
cterm
->
y
+
j
-
1
,
cterm
->
x
+
cterm
->
width
-
1
-
k
,
cterm
->
y
+
j
-
1
,
cterm
->
x
+
i
-
1
+
k
,
cterm
->
y
+
j
-
1
);
MOVETEXT
(
cterm
->
x
+
i
-
1
,
cterm
->
y
+
j
-
1
,
cterm
->
x
+
cterm
->
width
-
1
-
k
,
cterm
->
y
+
j
-
1
,
cterm
->
x
+
i
-
1
+
k
,
cterm
->
y
+
j
-
1
);
for
(
l
=
0
;
l
<
k
;
l
++
)
cterm
->
putch
(
' '
);
cterm
->
gotoxy
(
i
,
j
);
PUTCH
(
' '
);
GOTOXY
(
i
,
j
);
break
;
case
'A'
:
/* Cursor Up */
i
=
strtoul
(
cterm
->
escbuf
+
1
,
NULL
,
10
);
if
(
i
==
0
)
i
=
1
;
i
=
cterm
->
wherey
()
-
i
;
i
=
WHEREY
()
-
i
;
if
(
i
<
1
)
i
=
1
;
cterm
->
gotoxy
(
cterm
->
wherex
(),
i
);
GOTOXY
(
WHEREX
(),
i
);
break
;
case
'B'
:
/* Cursor Down */
i
=
strtoul
(
cterm
->
escbuf
+
1
,
NULL
,
10
);
if
(
i
==
0
)
i
=
1
;
i
=
cterm
->
wherey
()
+
i
;
i
=
WHEREY
()
+
i
;
if
(
i
>
cterm
->
height
)
i
=
cterm
->
height
;
cterm
->
gotoxy
(
cterm
->
wherex
(),
i
);
GOTOXY
(
WHEREX
(),
i
);
break
;
case
'C'
:
/* Cursor Right */
i
=
strtoul
(
cterm
->
escbuf
+
1
,
NULL
,
10
);
if
(
i
==
0
)
i
=
1
;
i
=
cterm
->
wherex
()
+
i
;
i
=
WHEREX
()
+
i
;
if
(
i
>
cterm
->
width
)
i
=
cterm
->
width
;
cterm
->
gotoxy
(
i
,
cterm
->
wherey
());
GOTOXY
(
i
,
WHEREY
());
break
;
case
'D'
:
/* Cursor Left and Font Select */
if
(
*
(
p
-
1
)
==
' '
)
{
/* Font Select */
...
...
@@ -695,7 +738,7 @@ static void do_ansi(struct cterminal *cterm, char *retbuf, size_t retsize, int *
switch
(
i
)
{
case
0
:
/* Only the primary and secondary font is currently supported */
case
1
:
cterm
->
setfont
(
j
,
FALSE
,
i
+
1
);
SETFONT
(
j
,
FALSE
,
i
+
1
);
}
}
}
...
...
@@ -703,29 +746,29 @@ static void do_ansi(struct cterminal *cterm, char *retbuf, size_t retsize, int *
i
=
strtoul
(
cterm
->
escbuf
+
1
,
NULL
,
10
);
if
(
i
==
0
)
i
=
1
;
i
=
cterm
->
wherex
()
-
i
;
i
=
WHEREX
()
-
i
;
if
(
i
<
1
)
i
=
1
;
cterm
->
gotoxy
(
i
,
cterm
->
wherey
());
GOTOXY
(
i
,
WHEREY
());
}
break
;
case
'E'
:
/* Cursor next line */
i
=
strtoul
(
cterm
->
escbuf
+
1
,
NULL
,
10
);
if
(
i
==
0
)
i
=
1
;
i
=
cterm
->
wherey
()
+
i
;
i
=
WHEREY
()
+
i
;
if
(
i
>
cterm
->
height
)
i
=
cterm
->
height
;
cterm
->
gotoxy
(
1
,
i
);
GOTOXY
(
1
,
i
);
break
;
case
'F'
:
/* Cursor preceding line */
i
=
strtoul
(
cterm
->
escbuf
+
1
,
NULL
,
10
);
if
(
i
==
0
)
i
=
1
;
i
=
cterm
->
wherey
()
-
i
;
i
=
WHEREY
()
-
i
;
if
(
i
<
1
)
i
=
1
;
cterm
->
gotoxy
(
1
,
i
);
GOTOXY
(
1
,
i
);
break
;
case
'G'
:
col
=
strtoul
(
cterm
->
escbuf
+
1
,
NULL
,
10
);
...
...
@@ -733,7 +776,7 @@ static void do_ansi(struct cterminal *cterm, char *retbuf, size_t retsize, int *
col
=
1
;
if
(
col
>
cterm
->
width
)
col
=
cterm
->
width
;
cterm
->
gotoxy
(
col
,
cterm
->
wherey
());
GOTOXY
(
col
,
WHEREY
());
break
;
case
'f'
:
case
'H'
:
...
...
@@ -756,34 +799,34 @@ static void do_ansi(struct cterminal *cterm, char *retbuf, size_t retsize, int *
row
=
cterm
->
height
;
if
(
col
>
cterm
->
width
)
col
=
cterm
->
width
;
cterm
->
gotoxy
(
col
,
row
);
GOTOXY
(
col
,
row
);
break
;
case
'J'
:
i
=
strtoul
(
cterm
->
escbuf
+
1
,
NULL
,
10
);
switch
(
i
)
{
case
0
:
cterm
->
clreol
();
row
=
cterm
->
wherey
();
col
=
cterm
->
wherex
();
CLREOL
();
row
=
WHEREY
();
col
=
WHEREX
();
for
(
i
=
row
+
1
;
i
<=
cterm
->
height
;
i
++
)
{
cterm
->
gotoxy
(
1
,
i
);
cterm
->
clreol
();
GOTOXY
(
1
,
i
);
CLREOL
();
}
cterm
->
gotoxy
(
col
,
row
);
GOTOXY
(
col
,
row
);
break
;
case
1
:
clear2bol
(
cterm
);
row
=
cterm
->
wherey
();
col
=
cterm
->
wherex
();
row
=
WHEREY
();
col
=
WHEREX
();
for
(
i
=
row
-
1
;
i
>=
1
;
i
--
)
{
cterm
->
gotoxy
(
1
,
i
);
cterm
->
clreol
();
GOTOXY
(
1
,
i
);
CLREOL
();
}
cterm
->
gotoxy
(
col
,
row
);
GOTOXY
(
col
,
row
);
break
;
case
2
:
cterm_clearscreen
(
cterm
,
(
char
)
cterm
->
attr
);
cterm
->
gotoxy
(
1
,
1
);
GOTOXY
(
1
,
1
);
break
;
}
break
;
...
...
@@ -791,35 +834,35 @@ static void do_ansi(struct cterminal *cterm, char *retbuf, size_t retsize, int *
i
=
strtoul
(
cterm
->
escbuf
+
1
,
NULL
,
10
);
switch
(
i
)
{
case
0
:
cterm
->
clreol
();
CLREOL
();
break
;
case
1
:
clear2bol
(
cterm
);
break
;
case
2
:
row
=
cterm
->
wherey
();
col
=
cterm
->
wherex
();
cterm
->
gotoxy
(
1
,
row
);
cterm
->
clreol
();
cterm
->
gotoxy
(
col
,
row
);
row
=
WHEREY
();
col
=
WHEREX
();
GOTOXY
(
1
,
row
);
CLREOL
();
GOTOXY
(
col
,
row
);
break
;
}
break
;
case
'L'
:
/* Insert line */
row
=
cterm
->
wherey
();
col
=
cterm
->
wherex
();
row
=
WHEREY
();
col
=
WHEREX
();
i
=
strtoul
(
cterm
->
escbuf
+
1
,
NULL
,
10
);
if
(
i
==
0
)
i
=
1
;
if
(
i
>
cterm
->
height
-
row
)
i
=
cterm
->
height
-
row
;
if
(
i
)
cterm
->
movetext
(
cterm
->
x
,
cterm
->
y
+
row
-
1
,
cterm
->
x
+
cterm
->
width
-
1
,
cterm
->
y
+
cterm
->
height
-
1
-
i
,
cterm
->
x
,
cterm
->
y
+
row
-
1
+
i
);
MOVETEXT
(
cterm
->
x
,
cterm
->
y
+
row
-
1
,
cterm
->
x
+
cterm
->
width
-
1
,
cterm
->
y
+
cterm
->
height
-
1
-
i
,
cterm
->
x
,
cterm
->
y
+
row
-
1
+
i
);
for
(
j
=
0
;
j
<
i
;
j
++
)
{
cterm
->
gotoxy
(
1
,
row
+
j
);
cterm
->
clreol
();
GOTOXY
(
1
,
row
+
j
);
CLREOL
();
}
cterm
->
gotoxy
(
col
,
row
);
GOTOXY
(
col
,
row
);
break
;
case
'M'
:
/* ANSI music and also supposed to be delete line! */
if
(
cterm
->
music_enable
==
CTERM_MUSIC_ENABLED
)
{
...
...
@@ -839,18 +882,18 @@ static void do_ansi(struct cterminal *cterm, char *retbuf, size_t retsize, int *
cterm
->
music
=
2
;
break
;
case
'P'
:
/* Delete char */
row
=
cterm
->
wherey
();
col
=
cterm
->
wherex
();
row
=
WHEREY
();
col
=
WHEREX
();
i
=
strtoul
(
cterm
->
escbuf
+
1
,
NULL
,
10
);
if
(
i
==
0
)
i
=
1
;
if
(
i
>
cterm
->
width
-
col
+
1
)
i
=
cterm
->
width
-
col
+
1
;
cterm
->
movetext
(
cterm
->
x
+
col
-
1
+
i
,
cterm
->
y
+
row
-
1
,
cterm
->
x
+
cterm
->
width
-
1
,
cterm
->
y
+
row
-
1
,
cterm
->
x
+
col
-
1
,
cterm
->
y
+
row
-
1
);
cterm
->
gotoxy
(
cterm
->
width
-
i
,
col
);
cterm
->
clreol
();
cterm
->
gotoxy
(
col
,
row
);
MOVETEXT
(
cterm
->
x
+
col
-
1
+
i
,
cterm
->
y
+
row
-
1
,
cterm
->
x
+
cterm
->
width
-
1
,
cterm
->
y
+
row
-
1
,
cterm
->
x
+
col
-
1
,
cterm
->
y
+
row
-
1
);
GOTOXY
(
cterm
->
width
-
i
,
col
);
CLREOL
();
GOTOXY
(
col
,
row
);
break
;
case
'S'
:
i
=
strtoul
(
cterm
->
escbuf
+
1
,
NULL
,
10
);
...
...
@@ -868,35 +911,35 @@ static void do_ansi(struct cterminal *cterm, char *retbuf, size_t retsize, int *
break
;
#if 0
case 'U':
cterm->gettextinfo
(&ti);
GETTEXTINFO
(&ti);
cterm_clearscreen(cterm, ti.normattr);
cterm->gotoxy
(1,1);
GOTOXY
(1,1);
break;
#endif
case
'X'
:
i
=
strtoul
(
cterm
->
escbuf
+
1
,
NULL
,
10
);
if
(
i
<
1
)
i
=
1
;
if
(
i
>
cterm
->
width
-
cterm
->
wherex
())
i
=
cterm
->
width
-
cterm
->
wherex
();
if
(
i
>
cterm
->
width
-
WHEREX
())
i
=
cterm
->
width
-
WHEREX
();
p2
=
alloca
(
i
*
2
);
j
=
0
;
for
(
k
=
0
;
k
<
i
;
k
++
)
{
p2
[
j
++
]
=
' '
;
p2
[
j
++
]
=
cterm
->
attr
;
}
cterm
->
puttext
(
cterm
->
x
+
cterm
->
wherex
()
-
1
,
cterm
->
y
+
cterm
->
wherey
()
-
1
,
cterm
->
x
+
cterm
->
wherex
()
-
1
+
i
-
1
,
cterm
->
y
+
cterm
->
wherey
()
-
1
,
p2
);
PUTTEXT
(
cterm
->
x
+
WHEREX
()
-
1
,
cterm
->
y
+
WHEREY
()
-
1
,
cterm
->
x
+
WHEREX
()
-
1
+
i
-
1
,
cterm
->
y
+
WHEREY
()
-
1
,
p2
);
break
;
case
'Z'
:
i
=
strtoul
(
cterm
->
escbuf
+
1
,
NULL
,
10
);
if
(
i
==
0
&&
cterm
->
escbuf
[
0
]
!=
'0'
)
i
=
1
;
for
(
j
=
(
sizeof
(
cterm_tabs
)
/
sizeof
(
cterm_tabs
[
0
]))
-
1
;
j
>=
0
;
j
--
)
{
if
(
cterm_tabs
[
j
]
<
cterm
->
wherex
())
{
if
(
cterm_tabs
[
j
]
<
WHEREX
())
{
k
=
j
-
i
+
1
;
if
(
k
<
0
)
k
=
0
;
cterm
->
gotoxy
(
cterm_tabs
[
k
],
cterm
->
wherey
());
GOTOXY
(
cterm_tabs
[
k
],
WHEREY
());
break
;
}
}
...
...
@@ -923,10 +966,10 @@ static void do_ansi(struct cterminal *cterm, char *retbuf, size_t retsize, int *
case
'm'
:
*
(
p
--
)
=
0
;
p2
=
cterm
->
escbuf
+
1
;
cterm
->
gettextinfo
(
&
ti
);
GETTEXTINFO
(
&
ti
);
if
(
p2
>
p
)
{
cterm
->
attr
=
ti
.
normattr
;
cterm
->
textattr
(
cterm
->
attr
);
TEXTATTR
(
cterm
->
attr
);
break
;
}
while
((
p
=
strtok
(
p2
,
";"
))
!=
NULL
)
{
...
...
@@ -1032,7 +1075,7 @@ static void do_ansi(struct cterminal *cterm, char *retbuf, size_t retsize, int *
break
;
}
}
cterm
->
textattr
(
cterm
->
attr
);
TEXTATTR
(
cterm
->
attr
);
break
;
case
'n'
:
i
=
strtoul
(
cterm
->
escbuf
+
1
,
NULL
,
10
);
...
...
@@ -1046,7 +1089,7 @@ static void do_ansi(struct cterminal *cterm, char *retbuf, size_t retsize, int *
break
;
case
6
:
if
(
retbuf
!=
NULL
)
{
sprintf
(
tmp
,
"%c[%d;%dR"
,
27
,
cterm
->
wherey
(),
cterm
->
wherex
());
sprintf
(
tmp
,
"%c[%d;%dR"
,
27
,
WHEREY
(),
WHEREX
());
if
(
strlen
(
retbuf
)
+
strlen
(
tmp
)
<
retsize
)
strcat
(
retbuf
,
tmp
);
}
...
...
@@ -1144,13 +1187,13 @@ static void do_ansi(struct cterminal *cterm, char *retbuf, size_t retsize, int *
}
break
;
case
's'
:
cterm
->
save_xpos
=
cterm
->
wherex
();
cterm
->
save_ypos
=
cterm
->
wherey
();
cterm
->
save_xpos
=
WHEREX
();
cterm
->
save_ypos
=
WHEREY
();
break
;
case
'u'
:
if
(
cterm
->
save_ypos
>
0
&&
cterm
->
save_ypos
<=
cterm
->
height
&&
cterm
->
save_xpos
>
0
&&
cterm
->
save_xpos
<=
cterm
->
width
)
{
cterm
->
gotoxy
(
cterm
->
save_xpos
,
cterm
->
save_ypos
);
GOTOXY
(
cterm
->
save_xpos
,
cterm
->
save_ypos
);
}
break
;
case
'y'
:
/* ToDo? VT100 Tests */
...
...
@@ -1270,15 +1313,15 @@ void cterm_start(struct cterminal *cterm)
struct
text_info
ti
;
if
(
!
cterm
->
started
)
{
cterm
->
gettextinfo
(
&
ti
);
GETTEXTINFO
(
&
ti
);
cterm
->
attr
=
ti
.
normattr
;
cterm
->
textattr
(
cterm
->
attr
);
cterm
->
_setcursortype
(
cterm
->
cursor
);
TEXTATTR
(
cterm
->
attr
);
SETCURSORTYPE
(
cterm
->
cursor
);
cterm
->
started
=
1
;
if
(
ti
.
winleft
!=
cterm
->
x
||
ti
.
wintop
!=
cterm
->
y
||
ti
.
winright
!=
cterm
->
x
+
cterm
->
width
-
1
||
ti
.
winleft
!=
cterm
->
y
+
cterm
->
height
-
1
)
cterm
->
window
(
cterm
->
x
,
cterm
->
y
,
cterm
->
x
+
cterm
->
width
-
1
,
cterm
->
y
+
cterm
->
height
-
1
);
WINDOW
(
cterm
->
x
,
cterm
->
y
,
cterm
->
x
+
cterm
->
width
-
1
,
cterm
->
y
+
cterm
->
height
-
1
);
cterm_clearscreen
(
cterm
,
cterm
->
attr
);
cterm
->
gotoxy
(
1
,
1
);
GOTOXY
(
1
,
1
);
}
}
...
...
@@ -1294,8 +1337,8 @@ static void ctputs(struct cterminal *cterm, char *buf)
outp
=
buf
;
oldscroll
=*
cterm
->
_wscroll
;
*
cterm
->
_wscroll
=
0
;
cx
=
cterm
->
wherex
();
cy
=
cterm
->
wherey
();
cx
=
WHEREX
();
cy
=
WHEREY
();
if
(
cterm
->
log
==
CTERM_LOG_ASCII
&&
cterm
->
logfile
!=
NULL
)
fputs
(
buf
,
cterm
->
logfile
);
for
(
p
=
buf
;
*
p
;
p
++
)
{
...
...
@@ -1305,27 +1348,27 @@ static void ctputs(struct cterminal *cterm, char *buf)
break
;
case
'\n'
:
*
p
=
0
;
cterm
->
cputs
(
outp
);
CPUTS
(
outp
);
outp
=
p
+
1
;
if
(
cy
==
cterm
->
height
)
scrollup
(
cterm
);
else
cy
++
;
cterm
->
gotoxy
(
cx
,
cy
);
GOTOXY
(
cx
,
cy
);
break
;
case
'\b'
:
*
p
=
0
;
cterm
->
cputs
(
outp
);
CPUTS
(
outp
);
outp
=
p
+
1
;
if
(
cx
>
1
)
cx
--
;
cterm
->
gotoxy
(
cx
,
cy
);
GOTOXY
(
cx
,
cy
);
break
;
case
7
:
/* Bell */
break
;
case
'\t'
:
*
p
=
0
;
cterm
->
cputs
(
outp
);
CPUTS
(
outp
);
outp
=
p
+
1
;
for
(
i
=
0
;
i
<
sizeof
(
cterm_tabs
)
/
sizeof
(
cterm_tabs
[
0
]);
i
++
)
{
if
(
cterm_tabs
[
i
]
>
cx
)
{
...
...
@@ -1340,7 +1383,7 @@ static void ctputs(struct cterminal *cterm, char *buf)
else
cy
++
;
}
cterm
->
gotoxy
(
cx
,
cy
);
GOTOXY
(
cx
,
cy
);
break
;
default:
if
(
cy
==
cterm
->
height
...
...
@@ -1348,12 +1391,12 @@ static void ctputs(struct cterminal *cterm, char *buf)
char
ch
;
ch
=*
(
p
+
1
);
*
(
p
+
1
)
=
0
;
cterm
->
cputs
(
outp
);
CPUTS
(
outp
);
*
(
p
+
1
)
=
ch
;
outp
=
p
+
1
;
scrollup
(
cterm
);
cx
=
1
;
cterm
->
gotoxy
(
cx
,
cy
);
GOTOXY
(
cx
,
cy
);
}
else
{
if
(
cx
==
cterm
->
width
)
{
...
...
@@ -1367,7 +1410,7 @@ static void ctputs(struct cterminal *cterm, char *buf)
break
;
}
}
cterm
->
cputs
(
outp
);
CPUTS
(
outp
);
*
cterm
->
_wscroll
=
oldscroll
;
}
...
...
@@ -1389,12 +1432,12 @@ char *cterm_write(struct cterminal * cterm, const unsigned char *buf, int buflen
*
cterm
->
hold_update
=
1
;
if
(
retbuf
!=
NULL
)
retbuf
[
0
]
=
0
;
cterm
->
gettextinfo
(
&
ti
);
GETTEXTINFO
(
&
ti
);
if
(
ti
.
winleft
!=
cterm
->
x
||
ti
.
wintop
!=
cterm
->
y
||
ti
.
winright
!=
cterm
->
x
+
cterm
->
width
-
1
||
ti
.
winbottom
!=
cterm
->
y
+
cterm
->
height
-
1
)
cterm
->
window
(
cterm
->
x
,
cterm
->
y
,
cterm
->
x
+
cterm
->
width
-
1
,
cterm
->
y
+
cterm
->
height
-
1
);
cterm
->
gotoxy
(
cterm
->
xpos
,
cterm
->
ypos
);
cterm
->
textattr
(
cterm
->
attr
);
cterm
->
_setcursortype
(
cterm
->
cursor
);
WINDOW
(
cterm
->
x
,
cterm
->
y
,
cterm
->
x
+
cterm
->
width
-
1
,
cterm
->
y
+
cterm
->
height
-
1
);
GOTOXY
(
cterm
->
xpos
,
cterm
->
ypos
);
TEXTATTR
(
cterm
->
attr
);
SETCURSORTYPE
(
cterm
->
cursor
);
ch
[
1
]
=
0
;
if
(
buflen
==-
1
)
buflen
=
strlen
(
buf
);
...
...
@@ -1444,7 +1487,7 @@ char *cterm_write(struct cterminal * cterm, const unsigned char *buf, int buflen
else
FREE_AND_NULL
(
buf
);
}
#
ifndef CTERM_WITHOUT_CONIO
#
endif
cterm
->
font_size
=
0
;
}
}
...
...
@@ -1551,8 +1594,8 @@ char *cterm_write(struct cterminal * cterm, const unsigned char *buf, int buflen
if
(
ch
[
0
]
==
14
)
{
*
cterm
->
hold_update
=
0
;
*
cterm
->
puttext_can_move
=
0
;
cterm
->
gotoxy
(
cterm
->
wherex
(),
cterm
->
wherey
());
cterm
->
_setcursortype
(
cterm
->
cursor
);
GOTOXY
(
WHEREX
(),
WHEREY
());
SETCURSORTYPE
(
cterm
->
cursor
);
*
cterm
->
hold_update
=
1
;
*
cterm
->
puttext_can_move
=
1
;
play_music
(
cterm
);
...
...
@@ -1575,36 +1618,36 @@ char *cterm_write(struct cterminal * cterm, const unsigned char *buf, int buflen
cterm
->
attr
=
1
;
break
;
case
28
:
/* Up (TODO: Wraps??) */
l
=
cterm
->
wherey
()
-
1
;
l
=
WHEREY
()
-
1
;
if
(
l
<
1
)
l
=
cterm
->
height
;
cterm
->
gotoxy
(
cterm
->
wherex
(),
l
);
GOTOXY
(
WHEREX
(),
l
);
break
;
case
29
:
/* Down (TODO: Wraps??) */
l
=
cterm
->
wherey
()
+
1
;
l
=
WHEREY
()
+
1
;
if
(
l
>
cterm
->
height
)
l
=
1
;
cterm
->
gotoxy
(
cterm
->
wherex
(),
l
);
GOTOXY
(
WHEREX
(),
l
);
break
;
case
30
:
/* Left (TODO: Wraps around to same line?) */
l
=
cterm
->
wherex
()
-
1
;
l
=
WHEREX
()
-
1
;
if
(
l
<
1
)
l
=
cterm
->
width
;
cterm
->
gotoxy
(
l
,
cterm
->
wherey
());
GOTOXY
(
l
,
WHEREY
());
break
;
case
31
:
/* Right (TODO: Wraps around to same line?) */
l
=
cterm
->
wherex
()
+
1
;
l
=
WHEREX
()
+
1
;
if
(
l
>
cterm
->
width
)
l
=
1
;
cterm
->
gotoxy
(
l
,
cterm
->
wherey
());
GOTOXY
(
l
,
WHEREY
());
break
;
case
125
:
/* Clear Screen */
cterm_clearscreen
(
cterm
,
cterm
->
attr
);
break
;
case
126
:
/* Backspace (TODO: Wraps around to previous line?) */
/* DOES NOT delete char, merely erases */
k
=
cterm
->
wherey
();
l
=
cterm
->
wherex
()
-
1
;
k
=
WHEREY
();
l
=
WHEREX
()
-
1
;
if
(
l
<
1
)
{
k
--
;
...
...
@@ -1612,13 +1655,13 @@ char *cterm_write(struct cterminal * cterm, const unsigned char *buf, int buflen
break
;
l
=
cterm
->
width
;
}
cterm
->
gotoxy
(
l
,
k
);
cterm
->
putch
(
0
);
cterm
->
gotoxy
(
l
,
k
);
GOTOXY
(
l
,
k
);
PUTCH
(
0
);
GOTOXY
(
l
,
k
);
break
;
/* We abuse the ESC buffer for tab stops */
case
127
:
/* Tab (Wraps around to next line) */
l
=
cterm
->
wherex
();
l
=
WHEREX
();
for
(
k
=
l
+
1
;
k
<=
cterm
->
width
;
k
++
)
{
if
(
cterm
->
escbuf
[
k
])
{
l
=
k
;
...
...
@@ -1627,73 +1670,73 @@ char *cterm_write(struct cterminal * cterm, const unsigned char *buf, int buflen
}
if
(
k
>
cterm
->
width
)
{
l
=
1
;
k
=
cterm
->
wherey
()
+
1
;
k
=
WHEREY
()
+
1
;
if
(
k
>
cterm
->
height
)
{
scrollup
(
cterm
);
k
=
cterm
->
height
;
}
cterm
->
gotoxy
(
l
,
k
);
GOTOXY
(
l
,
k
);
}
else
cterm
->
gotoxy
(
l
,
cterm
->
wherey
());
GOTOXY
(
l
,
WHEREY
());
break
;
case
155
:
/* Return */
k
=
cterm
->
wherey
();
k
=
WHEREY
();
if
(
k
==
cterm
->
height
)
scrollup
(
cterm
);
else
k
++
;
cterm
->
gotoxy
(
1
,
k
);
GOTOXY
(
1
,
k
);
break
;
case
156
:
/* Delete Line */
dellines
(
cterm
,
1
);
cterm
->
gotoxy
(
1
,
cterm
->
wherey
());
GOTOXY
(
1
,
WHEREY
());
break
;
case
157
:
/* Insert Line */
l
=
cterm
->
wherex
();
k
=
cterm
->
wherey
();
l
=
WHEREX
();
k
=
WHEREY
();
if
(
k
<
cterm
->
height
)
cterm
->
movetext
(
cterm
->
x
,
cterm
->
y
+
k
-
1
MOVETEXT
(
cterm
->
x
,
cterm
->
y
+
k
-
1
,
cterm
->
x
+
cterm
->
width
-
1
,
cterm
->
y
+
cterm
->
height
-
2
,
cterm
->
x
,
cterm
->
y
+
k
);
cterm
->
gotoxy
(
1
,
k
);
cterm
->
clreol
();
GOTOXY
(
1
,
k
);
CLREOL
();
break
;
case
158
:
/* Clear Tab */
cterm
->
escbuf
[
cterm
->
wherex
()]
=
0
;
cterm
->
escbuf
[
WHEREX
()]
=
0
;
break
;
case
159
:
/* Set Tab */
cterm
->
escbuf
[
cterm
->
wherex
()]
=
1
;
cterm
->
escbuf
[
WHEREX
()]
=
1
;
break
;
case
253
:
/* Beep */
if
(
!
cterm
->
quiet
)
{
#ifdef __unix__
cterm
->
putch
(
7
);
PUTCH
(
7
);
#else
MessageBeep
(
MB_OK
);
#endif
}
break
;
case
254
:
/* Delete Char */
l
=
cterm
->
wherex
();
k
=
cterm
->
wherey
();
l
=
WHEREX
();
k
=
WHEREY
();
if
(
l
<
cterm
->
width
)
cterm
->
movetext
(
cterm
->
x
+
l
,
cterm
->
y
+
k
-
1
MOVETEXT
(
cterm
->
x
+
l
,
cterm
->
y
+
k
-
1
,
cterm
->
x
+
cterm
->
width
-
1
,
cterm
->
y
+
k
-
1
,
cterm
->
x
+
l
-
1
,
cterm
->
y
+
k
-
1
);
cterm
->
gotoxy
(
cterm
->
width
,
k
);
cterm
->
clreol
();
cterm
->
gotoxy
(
l
,
k
);
GOTOXY
(
cterm
->
width
,
k
);
CLREOL
();
GOTOXY
(
l
,
k
);
break
;
case
255
:
/* Insert Char */
l
=
cterm
->
wherex
();
k
=
cterm
->
wherey
();
l
=
WHEREX
();
k
=
WHEREY
();
if
(
l
<
cterm
->
width
)
cterm
->
movetext
(
cterm
->
x
+
l
-
1
,
cterm
->
y
+
k
-
1
MOVETEXT
(
cterm
->
x
+
l
-
1
,
cterm
->
y
+
k
-
1
,
cterm
->
x
+
cterm
->
width
-
2
,
cterm
->
y
+
k
-
1
,
cterm
->
x
+
l
,
cterm
->
y
+
k
-
1
);
cterm
->
putch
(
0
);
cterm
->
gotoxy
(
l
,
k
);
PUTCH
(
0
);
GOTOXY
(
l
,
k
);
break
;
default:
/* Translate to screen codes */
...
...
@@ -1718,30 +1761,30 @@ char *cterm_write(struct cterminal * cterm, const unsigned char *buf, int buflen
}
ch
[
0
]
=
k
;
ch
[
1
]
=
cterm
->
attr
;
cterm
->
puttext
(
cterm
->
x
+
cterm
->
wherex
()
-
1
,
cterm
->
y
+
cterm
->
wherey
()
-
1
,
cterm
->
x
+
cterm
->
wherex
()
-
1
,
cterm
->
y
+
cterm
->
wherey
()
-
1
,
ch
);
PUTTEXT
(
cterm
->
x
+
WHEREX
()
-
1
,
cterm
->
y
+
WHEREY
()
-
1
,
cterm
->
x
+
WHEREX
()
-
1
,
cterm
->
y
+
WHEREY
()
-
1
,
ch
);
ch
[
1
]
=
0
;
if
(
cterm
->
wherex
()
==
cterm
->
width
)
{
if
(
cterm
->
wherey
()
==
cterm
->
height
)
{
if
(
WHEREX
()
==
cterm
->
width
)
{
if
(
WHEREY
()
==
cterm
->
height
)
{
scrollup
(
cterm
);
cterm
->
gotoxy
(
1
,
cterm
->
wherey
());
GOTOXY
(
1
,
WHEREY
());
}
else
cterm
->
gotoxy
(
1
,
cterm
->
wherey
()
+
1
);
GOTOXY
(
1
,
WHEREY
()
+
1
);
}
else
cterm
->
gotoxy
(
cterm
->
wherex
()
+
1
,
cterm
->
wherey
());
GOTOXY
(
WHEREX
()
+
1
,
WHEREY
());
break
;
}
}
else
{
switch
(
buf
[
j
])
{
case
155
:
/* Return */
k
=
cterm
->
wherey
();
k
=
WHEREY
();
if
(
k
==
cterm
->
height
)
scrollup
(
cterm
);
else
k
++
;
cterm
->
gotoxy
(
1
,
k
);
GOTOXY
(
1
,
k
);
break
;
default:
/* Translate to screen codes */
...
...
@@ -1766,18 +1809,18 @@ char *cterm_write(struct cterminal * cterm, const unsigned char *buf, int buflen
}
ch
[
0
]
=
k
;
ch
[
1
]
=
cterm
->
attr
;
cterm
->
puttext
(
cterm
->
x
+
cterm
->
wherex
()
-
1
,
cterm
->
y
+
cterm
->
wherey
()
-
1
,
cterm
->
x
+
cterm
->
wherex
()
-
1
,
cterm
->
y
+
cterm
->
wherey
()
-
1
,
ch
);
PUTTEXT
(
cterm
->
x
+
WHEREX
()
-
1
,
cterm
->
y
+
WHEREY
()
-
1
,
cterm
->
x
+
WHEREX
()
-
1
,
cterm
->
y
+
WHEREY
()
-
1
,
ch
);
ch
[
1
]
=
0
;
if
(
cterm
->
wherex
()
==
cterm
->
width
)
{
if
(
cterm
->
wherey
()
==
cterm
->
height
)
{
if
(
WHEREX
()
==
cterm
->
width
)
{
if
(
WHEREY
()
==
cterm
->
height
)
{
scrollup
(
cterm
);
cterm
->
gotoxy
(
1
,
cterm
->
height
);
GOTOXY
(
1
,
cterm
->
height
);
}
else
cterm
->
gotoxy
(
1
,
cterm
->
wherey
()
+
1
);
GOTOXY
(
1
,
WHEREY
()
+
1
);
}
else
cterm
->
gotoxy
(
cterm
->
wherex
()
+
1
,
cterm
->
wherey
());
GOTOXY
(
WHEREX
()
+
1
,
WHEREY
());
break
;
}
cterm
->
attr
=
7
;
...
...
@@ -1852,94 +1895,94 @@ char *cterm_write(struct cterminal * cterm, const unsigned char *buf, int buflen
cterm
->
attr
|=
3
;
break
;
}
cterm
->
textattr
(
cterm
->
attr
);
TEXTATTR
(
cterm
->
attr
);
break
;
/* Movement */
case
13
:
/* "\r\n" and disabled reverse. */
case
141
:
cterm
->
gotoxy
(
1
,
cterm
->
wherey
());
GOTOXY
(
1
,
WHEREY
());
/* Fall-through */
case
17
:
if
(
cterm
->
wherey
()
==
cterm
->
height
)
if
(
WHEREY
()
==
cterm
->
height
)
scrollup
(
cterm
);
else
cterm
->
gotoxy
(
cterm
->
wherex
(),
cterm
->
wherey
()
+
1
);
GOTOXY
(
WHEREX
(),
WHEREY
()
+
1
);
break
;
case
147
:
cterm_clearscreen
(
cterm
,
cterm
->
attr
);
/* Fall through */
case
19
:
cterm
->
gotoxy
(
1
,
1
);
GOTOXY
(
1
,
1
);
break
;
case
20
:
/* Delete (Wrapping backspace) */
k
=
cterm
->
wherey
();
l
=
cterm
->
wherex
();
k
=
WHEREY
();
l
=
WHEREX
();
if
(
l
==
1
)
{
if
(
k
==
1
)
break
;
cterm
->
gotoxy
((
l
=
cterm
->
width
),
k
-
1
);
GOTOXY
((
l
=
cterm
->
width
),
k
-
1
);
}
else
cterm
->
gotoxy
(
--
l
,
k
);
GOTOXY
(
--
l
,
k
);
if
(
l
<
cterm
->
width
)
cterm
->
movetext
(
cterm
->
x
+
l
,
cterm
->
y
+
k
-
1
MOVETEXT
(
cterm
->
x
+
l
,
cterm
->
y
+
k
-
1
,
cterm
->
x
+
cterm
->
width
-
1
,
cterm
->
y
+
k
-
1
,
cterm
->
x
+
l
-
1
,
cterm
->
y
+
k
-
1
);
cterm
->
gotoxy
(
cterm
->
width
,
k
);
cterm
->
clreol
();
cterm
->
gotoxy
(
l
,
k
);
GOTOXY
(
cterm
->
width
,
k
);
CLREOL
();
GOTOXY
(
l
,
k
);
break
;
case
157
:
/* Cursor Left (wraps) */
if
(
cterm
->
wherex
()
==
1
)
{
if
(
cterm
->
wherey
()
>
1
)
cterm
->
gotoxy
(
cterm
->
width
,
cterm
->
wherey
()
-
1
);
if
(
WHEREX
()
==
1
)
{
if
(
WHEREY
()
>
1
)
GOTOXY
(
cterm
->
width
,
WHEREY
()
-
1
);
}
else
cterm
->
gotoxy
(
cterm
->
wherex
()
-
1
,
cterm
->
wherey
());
GOTOXY
(
WHEREX
()
-
1
,
WHEREY
());
break
;
case
29
:
/* Cursor Right (wraps) */
if
(
cterm
->
wherex
()
==
cterm
->
width
)
{
if
(
cterm
->
wherey
()
==
cterm
->
height
)
{
if
(
WHEREX
()
==
cterm
->
width
)
{
if
(
WHEREY
()
==
cterm
->
height
)
{
scrollup
(
cterm
);
cterm
->
gotoxy
(
1
,
cterm
->
wherey
());
GOTOXY
(
1
,
WHEREY
());
}
else
cterm
->
gotoxy
(
1
,
cterm
->
wherey
()
+
1
);
GOTOXY
(
1
,
WHEREY
()
+
1
);
}
else
cterm
->
gotoxy
(
cterm
->
wherex
()
+
1
,
cterm
->
wherey
());
GOTOXY
(
WHEREX
()
+
1
,
WHEREY
());
break
;
case
145
:
/* Cursor Up (No scroll */
if
(
cterm
->
wherey
()
>
1
)
cterm
->
gotoxy
(
cterm
->
wherex
(),
cterm
->
wherey
()
-
1
);
if
(
WHEREY
()
>
1
)
GOTOXY
(
WHEREX
(),
WHEREY
()
-
1
);
break
;
case
148
:
/* Insert TODO verify last column */
/* CGTerm does nothing there... we */
/* Erase under cursor. */
l
=
cterm
->
wherex
();
k
=
cterm
->
wherey
();
l
=
WHEREX
();
k
=
WHEREY
();
if
(
l
<=
cterm
->
width
)
cterm
->
movetext
(
cterm
->
x
+
l
-
1
,
cterm
->
y
+
k
-
1
MOVETEXT
(
cterm
->
x
+
l
-
1
,
cterm
->
y
+
k
-
1
,
cterm
->
x
+
cterm
->
width
-
2
,
cterm
->
y
+
k
-
1
,
cterm
->
x
+
l
,
cterm
->
y
+
k
-
1
);
cterm
->
putch
(
' '
);
cterm
->
gotoxy
(
l
,
k
);
PUTCH
(
' '
);
GOTOXY
(
l
,
k
);
break
;
/* Font change... whee! */
case
14
:
/* Lower case font */
if
(
ti
.
currmode
==
C64_40X25
)
cterm
->
setfont
(
33
,
FALSE
,
1
);
SETFONT
(
33
,
FALSE
,
1
);
else
/* Assume C128 */
cterm
->
setfont
(
35
,
FALSE
,
1
);
SETFONT
(
35
,
FALSE
,
1
);
break
;
case
142
:
/* Upper case font */
if
(
ti
.
currmode
==
C64_40X25
)
cterm
->
setfont
(
32
,
FALSE
,
1
);
SETFONT
(
32
,
FALSE
,
1
);
else
/* Assume C128 */
cterm
->
setfont
(
34
,
FALSE
,
1
);
SETFONT
(
34
,
FALSE
,
1
);
break
;
case
18
:
/* Reverse mode on */
cterm
->
c64reversemode
=
1
;
...
...
@@ -1952,7 +1995,7 @@ char *cterm_write(struct cterminal * cterm, const unsigned char *buf, int buflen
case
7
:
/* Beep */
if
(
!
cterm
->
quiet
)
{
#ifdef __unix__
cterm
->
putch
(
7
);
PUTCH
(
7
);
#else
MessageBeep
(
MB_OK
);
#endif
...
...
@@ -1993,18 +2036,18 @@ char *cterm_write(struct cterminal * cterm, const unsigned char *buf, int buflen
k
+=
128
;
ch
[
0
]
=
k
;
ch
[
1
]
=
cterm
->
attr
;
cterm
->
puttext
(
cterm
->
x
+
cterm
->
wherex
()
-
1
,
cterm
->
y
+
cterm
->
wherey
()
-
1
,
cterm
->
x
+
cterm
->
wherex
()
-
1
,
cterm
->
y
+
cterm
->
wherey
()
-
1
,
ch
);
PUTTEXT
(
cterm
->
x
+
WHEREX
()
-
1
,
cterm
->
y
+
WHEREY
()
-
1
,
cterm
->
x
+
WHEREX
()
-
1
,
cterm
->
y
+
WHEREY
()
-
1
,
ch
);
ch
[
1
]
=
0
;
if
(
cterm
->
wherex
()
==
cterm
->
width
)
{
if
(
cterm
->
wherey
()
==
cterm
->
height
)
{
if
(
WHEREX
()
==
cterm
->
width
)
{
if
(
WHEREY
()
==
cterm
->
height
)
{
scrollup
(
cterm
);
cterm
->
gotoxy
(
1
,
cterm
->
wherey
());
GOTOXY
(
1
,
WHEREY
());
}
else
cterm
->
gotoxy
(
1
,
cterm
->
wherey
()
+
1
);
GOTOXY
(
1
,
WHEREY
()
+
1
);
}
else
cterm
->
gotoxy
(
cterm
->
wherex
()
+
1
,
cterm
->
wherey
());
GOTOXY
(
WHEREX
()
+
1
,
WHEREY
());
break
;
}
}
...
...
@@ -2012,18 +2055,18 @@ char *cterm_write(struct cterminal * cterm, const unsigned char *buf, int buflen
if
(
cterm
->
doorway_char
)
{
ctputs
(
cterm
,
prn
);
ch
[
1
]
=
cterm
->
attr
;
cterm
->
puttext
(
cterm
->
x
+
cterm
->
wherex
()
-
1
,
cterm
->
y
+
cterm
->
wherey
()
-
1
,
cterm
->
x
+
cterm
->
wherex
()
-
1
,
cterm
->
y
+
cterm
->
wherey
()
-
1
,
ch
);
PUTTEXT
(
cterm
->
x
+
WHEREX
()
-
1
,
cterm
->
y
+
WHEREY
()
-
1
,
cterm
->
x
+
WHEREX
()
-
1
,
cterm
->
y
+
WHEREY
()
-
1
,
ch
);
ch
[
1
]
=
0
;
if
(
cterm
->
wherex
()
==
cterm
->
width
)
{
if
(
cterm
->
wherey
()
==
cterm
->
height
)
{
if
(
WHEREX
()
==
cterm
->
width
)
{
if
(
WHEREY
()
==
cterm
->
height
)
{
scrollup
(
cterm
);
cterm
->
gotoxy
(
1
,
cterm
->
wherey
());
GOTOXY
(
1
,
WHEREY
());
}
else
cterm
->
gotoxy
(
1
,
cterm
->
wherey
()
+
1
);
GOTOXY
(
1
,
WHEREY
()
+
1
);
}
else
cterm
->
gotoxy
(
cterm
->
wherex
()
+
1
,
cterm
->
wherey
());
GOTOXY
(
WHEREX
()
+
1
,
WHEREY
());
cterm
->
doorway_char
=
0
;
}
else
{
...
...
@@ -2039,7 +2082,7 @@ char *cterm_write(struct cterminal * cterm, const unsigned char *buf, int buflen
fputs
(
"
\x07
"
,
cterm
->
logfile
);
if
(
!
cterm
->
quiet
)
{
#ifdef __unix__
cterm
->
putch
(
7
);
PUTCH
(
7
);
#else
MessageBeep
(
MB_OK
);
#endif
...
...
@@ -2051,7 +2094,7 @@ char *cterm_write(struct cterminal * cterm, const unsigned char *buf, int buflen
if
(
cterm
->
log
==
CTERM_LOG_ASCII
&&
cterm
->
logfile
!=
NULL
)
fputs
(
"
\x0c
"
,
cterm
->
logfile
);
cterm_clearscreen
(
cterm
,
(
char
)
cterm
->
attr
);
cterm
->
gotoxy
(
1
,
1
);
GOTOXY
(
1
,
1
);
break
;
case
27
:
/* ESC */
ctputs
(
cterm
,
prn
);
...
...
@@ -2069,19 +2112,19 @@ char *cterm_write(struct cterminal * cterm, const unsigned char *buf, int buflen
prn
[
0
]
=
0
;
break
;
}
cterm
->
xpos
=
cterm
->
wherex
();
cterm
->
ypos
=
cterm
->
wherey
();
cterm
->
xpos
=
WHEREX
();
cterm
->
ypos
=
WHEREY
();
#if 0
if(ti.winleft != cterm->x || ti.wintop != cterm->y || ti.winright != cterm->x+cterm->width-1 || ti.winleft != cterm->y+cterm->height-1)
cterm->window
(ti.winleft,ti.wintop,ti.winright,ti.winbottom);
cterm->gotoxy
(ti.curx,ti.cury);
cterm->textattr
(ti.attribute);
WINDOW
(ti.winleft,ti.wintop,ti.winright,ti.winbottom);
GOTOXY
(ti.curx,ti.cury);
TEXTATTR
(ti.attribute);
#endif
*
cterm
->
hold_update
=
olddmc
;
*
cterm
->
puttext_can_move
=
oldptnm
;
cterm
->
gotoxy
(
cterm
->
wherex
(),
cterm
->
wherey
());
cterm
->
_setcursortype
(
cterm
->
cursor
);
GOTOXY
(
WHEREX
(),
WHEREY
());
SETCURSORTYPE
(
cterm
->
cursor
);
return
(
retbuf
);
}
...
...
This diff is collapsed.
Click to expand it.
src/conio/cterm.h
+
20
−
0
View file @
1d08b781
...
...
@@ -112,6 +112,25 @@ struct cterminal {
int
cursor
;
// Current cursor mode (Normal or None)
/* conio function pointers */
#ifdef CTERM_WITHOUT_CONIO
void
(
*
ciolib_gotoxy
)
(
struct
cterminal
*
,
int
,
int
);
int
(
*
ciolib_wherex
)
(
struct
cterminal
*
);
int
(
*
ciolib_wherey
)
(
struct
cterminal
*
);
int
(
*
ciolib_gettext
)
(
struct
cterminal
*
,
int
,
int
,
int
,
int
,
unsigned
char
*
);
void
(
*
ciolib_gettextinfo
)
(
struct
cterminal
*
,
struct
text_info
*
);
void
(
*
ciolib_textattr
)
(
struct
cterminal
*
,
int
);
void
(
*
ciolib_setcursortype
)
(
struct
cterminal
*
,
int
);
int
(
*
ciolib_movetext
)
(
struct
cterminal
*
,
int
,
int
,
int
,
int
,
int
,
int
);
void
(
*
ciolib_clreol
)
(
struct
cterminal
*
);
void
(
*
ciolib_clrscr
)
(
struct
cterminal
*
);
void
(
*
ciolib_setvideoflags
)
(
struct
cterminal
*
,
int
flags
);
int
(
*
ciolib_getvideoflags
)
(
struct
cterminal
*
);
int
(
*
ciolib_putch
)
(
struct
cterminal
*
,
int
);
int
(
*
ciolib_puttext
)
(
struct
cterminal
*
,
int
,
int
,
int
,
int
,
unsigned
char
*
);
void
(
*
ciolib_window
)
(
struct
cterminal
*
,
int
,
int
,
int
,
int
);
int
(
*
ciolib_cputs
)
(
struct
cterminal
*
,
char
*
);
int
(
*
ciolib_setfont
)
(
struct
cterminal
*
,
int
font
,
int
force
,
int
font_num
);
#else
void
(
*
ciolib_gotoxy
)
(
int
,
int
);
int
(
*
ciolib_wherex
)
(
void
);
int
(
*
ciolib_wherey
)
(
void
);
...
...
@@ -129,6 +148,7 @@ struct cterminal {
void
(
*
ciolib_window
)
(
int
,
int
,
int
,
int
);
int
(
*
ciolib_cputs
)
(
char
*
);
int
(
*
ciolib_setfont
)
(
int
font
,
int
force
,
int
font_num
);
#endif
int
*
_wscroll
;
int
*
puttext_can_move
;
int
*
hold_update
;
...
...
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