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
102068b9
Commit
102068b9
authored
20 years ago
by
rswindell
Browse files
Options
Downloads
Patches
Plain Diff
Renamed CIOLIB_*_MODE enums to CIOLIB_MODE_*.
Using macro for repetitive (copy/paste) calls to initciolib().
parent
d7fa6b3b
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/conio/ciolib.c
+78
-77
78 additions, 77 deletions
src/conio/ciolib.c
src/conio/ciolib.h
+6
-6
6 additions, 6 deletions
src/conio/ciolib.h
with
84 additions
and
83 deletions
src/conio/ciolib.c
+
78
−
77
View file @
102068b9
...
...
@@ -57,12 +57,14 @@ void ciolib_delline(void);
void
ciolib_insline
(
void
);
char
*
ciolib_getpass
(
const
char
*
prompt
);
#define CIOLIB_INIT() { if(!initialized) initciolib(CIOLIB_MODE_AUTO); }
#ifndef _WIN32
#ifndef NO_X
int
try_x_init
(
int
mode
)
{
if
(
!
console_init
())
{
cio_api
.
mode
=
CIOLIB_
X_
MODE
;
cio_api
.
mode
=
CIOLIB_MODE
_X
;
cio_api
.
puttext
=
x_puttext
;
cio_api
.
gettext
=
x_gettext
;
cio_api
.
textattr
=
x_textattr
;
...
...
@@ -87,7 +89,7 @@ int try_x_init(int mode)
int
try_curses_init
(
int
mode
)
{
if
(
curs_initciolib
(
mode
))
{
cio_api
.
mode
=
CIOLIB_CURSES_IBM
_MODE
;
cio_api
.
mode
=
CIOLIB_
MODE_
CURSES_IBM
;
cio_api
.
puttext
=
curs_puttext
;
cio_api
.
gettext
=
curs_gettext
;
cio_api
.
textattr
=
curs_textattr
;
...
...
@@ -112,7 +114,7 @@ int try_curses_init(int mode)
int
try_ansi_init
(
int
mode
)
{
if
(
ansi_initciolib
(
mode
))
{
cio_api
.
mode
=
CIOLIB_
ANSI_MODE
;
cio_api
.
mode
=
CIOLIB_
MODE_ANSI
;
cio_api
.
puttext
=
ansi_puttext
;
cio_api
.
gettext
=
ansi_gettext
;
cio_api
.
textattr
=
ansi_textattr
;
...
...
@@ -134,17 +136,18 @@ int try_ansi_init(int mode)
}
#ifdef _WIN32
#if defined(__BORLANDC__)
#pragma argsused
#endif
int
try_conio_init
(
int
mode
)
{
if
(
mode
==
CIOLIB_MODE_AUTO
);
/* Shut up stupid warning */
/* This should test for something or other */
if
(
isatty
(
fileno
(
stdout
)))
{
cio_api
.
mode
=
CIOLIB_CONIO
_MODE
;
cio_api
.
mode
=
CIOLIB_
MODE_
CONIO
;
cio_api
.
puttext
=
puttext
;
cio_api
.
gettext
=
gettext
;
cio_api
.
textattr
=
textattr
;
cio_api
.
kbhit
=
kbhit
;
// cio_api.delay=delay;
cio_api
.
wherey
=
wherey
;
cio_api
.
wherex
=
wherex
;
cio_api
.
putch
=
putch
;
...
...
@@ -153,7 +156,6 @@ int try_conio_init(int mode)
cio_api
.
setcursortype
=
_setcursortype
;
cio_api
.
getch
=
getch
;
cio_api
.
getche
=
getche
;
// cio_api.beep=beep;
cio_api
.
textmode
=
textmode
;
return
(
1
);
}
...
...
@@ -166,7 +168,7 @@ int try_conio_init(int mode)
int
initciolib
(
int
mode
)
{
switch
(
mode
)
{
case
CIOLIB_
AUTO_MODE
:
case
CIOLIB_
MODE_AUTO
:
#ifdef _WIN32
if
(
!
try_conio_init
(
mode
))
#else
...
...
@@ -176,23 +178,23 @@ int initciolib(int mode)
try_ansi_init
(
mode
);
break
;
#ifdef _WIN32
case
CIOLIB_CONIO
_MODE
:
case
CIOLIB_
MODE_
CONIO
:
try_conio_init
(
mode
);
break
;
#else
case
CIOLIB_CURSES
_MODE
:
case
CIOLIB_CURSES_IBM
_MODE
:
case
CIOLIB_
MODE_
CURSES
:
case
CIOLIB_
MODE_
CURSES_IBM
:
try_curses_init
(
mode
);
break
;
case
CIOLIB_
X_
MODE
:
case
CIOLIB_MODE
_X
:
try_x_init
(
mode
);
break
;
#endif
case
CIOLIB_
ANSI_MODE
:
case
CIOLIB_
MODE_ANSI
:
try_ansi_init
(
mode
);
break
;
}
if
(
cio_api
.
mode
==
CIOLIB_
AUTO_MODE
)
{
if
(
cio_api
.
mode
==
CIOLIB_
MODE_AUTO
)
{
fprintf
(
stderr
,
"CIOLIB initialization failed!"
);
return
(
-
1
);
}
...
...
@@ -209,8 +211,7 @@ int initciolib(int mode)
int
ciolib_kbhit
(
void
)
{
if
(
!
initialized
)
initciolib
(
CIOLIB_AUTO_MODE
);
CIOLIB_INIT
();
if
(
ungotch
)
return
(
1
);
return
(
cio_api
.
kbhit
());
...
...
@@ -220,8 +221,8 @@ int ciolib_getch(void)
{
int
ch
;
if
(
!
initialized
)
initciolib
(
CIOLIB_AUTO_MODE
);
CIOLIB_INIT
();
if
(
ungotch
)
{
ch
=
ungotch
;
ungotch
=
0
;
...
...
@@ -234,8 +235,8 @@ int ciolib_getche(void)
{
int
ch
;
if
(
!
initialized
)
initciolib
(
CIOLIB_AUTO_MODE
);
CIOLIB_INIT
();
if
(
ungotch
)
{
ch
=
ungotch
;
ungotch
=
0
;
...
...
@@ -247,8 +248,8 @@ int ciolib_getche(void)
int
ciolib_ungetch
(
int
ch
)
{
if
(
!
initialized
)
initciolib
(
CIOLIB_AUTO_MODE
);
CIOLIB_INIT
();
if
(
ungotch
)
return
(
EOF
);
ungotch
=
ch
;
...
...
@@ -261,8 +262,8 @@ int ciolib_movetext(int sx, int sy, int ex, int ey, int dx, int dy)
int
height
;
char
*
buf
;
if
(
!
initialized
)
initciolib
(
CIOLIB_AUTO_MODE
);
CIOLIB_INIT
();
width
=
ex
-
sx
;
height
=
ey
-
sy
;
buf
=
(
char
*
)
malloc
((
width
+
1
)
*
(
height
+
1
)
*
2
);
...
...
@@ -287,8 +288,8 @@ char *ciolib_cgets(char *str)
int
chars
;
int
ch
;
if
(
!
initialized
)
initciolib
(
CIOLIB_AUTO_MODE
);
CIOLIB_INIT
();
maxlen
=*
(
unsigned
char
*
)
str
;
while
((
ch
=
ciolib_getche
())
!=
'\n'
)
{
switch
(
ch
)
{
...
...
@@ -326,8 +327,8 @@ int ciolib_cscanf (char *format , ...)
va_list
argptr
;
int
ret
;
if
(
!
initialized
)
initciolib
(
CIOLIB_AUTO_MODE
);
CIOLIB_INIT
();
str
[
0
]
=-
1
;
va_start
(
argptr
,
format
);
ret
=
vsscanf
(
ciolib_cgets
(
str
),
format
,
argptr
);
...
...
@@ -342,8 +343,8 @@ char *ciolib_getpass(const char *prompt)
int
chars
;
int
ch
;
if
(
!
initialized
)
initciolib
(
CIOLIB_AUTO_MODE
);
CIOLIB_INIT
();
ciolib_cputs
((
char
*
)
prompt
);
while
((
ch
=
getch
())
!=
'\n'
)
{
switch
(
ch
)
{
...
...
@@ -374,7 +375,7 @@ char *ciolib_getpass(const char *prompt)
void
ciolib_gettextinfo
(
struct
text_info
*
info
)
{
if
(
!
initialized
)
initciolib
(
CIOLIB_
AUTO_MODE
);
initciolib
(
CIOLIB_
MODE_AUTO
);
else
{
cio_api
.
gettextinfo
(
&
cio_textinfo
);
}
...
...
@@ -400,8 +401,8 @@ void ciolib_wscroll(void)
int
os
;
struct
text_info
ti
;
if
(
!
initialized
)
initciolib
(
CIOLIB_AUTO_MODE
);
CIOLIB_INIT
();
ciolib_gettextinfo
(
&
ti
);
if
(
!
_wscroll
)
return
;
...
...
@@ -418,8 +419,8 @@ int ciolib_wherex(void)
{
int
x
;
if
(
!
initialized
)
initciolib
(
CIOLIB_AUTO_MODE
);
CIOLIB_INIT
();
x
=
cio_api
.
wherex
();
x
=
x
-
cio_textinfo
.
winleft
+
1
;
return
(
x
);
...
...
@@ -429,8 +430,8 @@ int ciolib_wherey(void)
{
int
y
;
if
(
!
initialized
)
initciolib
(
CIOLIB_AUTO_MODE
);
CIOLIB_INIT
();
y
=
cio_api
.
wherey
();
y
=
y
-
cio_textinfo
.
wintop
+
1
;
return
(
y
);
...
...
@@ -442,8 +443,8 @@ void ciolib_gotoxy(int x, int y)
int
ny
;
struct
text_info
ti
;
if
(
!
initialized
)
initciolib
(
CIOLIB_AUTO_MODE
);
CIOLIB_INIT
();
ciolib_gettextinfo
(
&
ti
);
if
(
x
<
1
||
x
>
ti
.
winright
-
ti
.
winleft
+
1
...
...
@@ -457,8 +458,8 @@ void ciolib_gotoxy(int x, int y)
void
ciolib_textmode
(
mode
)
{
if
(
!
initialized
)
initciolib
(
CIOLIB_AUTO_MODE
);
CIOLIB_INIT
();
if
(
mode
==-
1
)
{
ciolib_gettextinfo
(
&
cio_textinfo
);
cio_api
.
textmode
(
lastmode
);
...
...
@@ -478,8 +479,8 @@ void ciolib_textmode(mode)
void
ciolib_window
(
int
sx
,
int
sy
,
int
ex
,
int
ey
)
{
if
(
!
initialized
)
initciolib
(
CIOLIB_AUTO_MODE
);
CIOLIB_INIT
();
ciolib_gettextinfo
(
&
cio_textinfo
);
if
(
sx
<
1
||
sy
<
1
...
...
@@ -504,8 +505,8 @@ void ciolib_clreol(void)
int
os
;
struct
text_info
ti
;
if
(
!
initialized
)
initciolib
(
CIOLIB_AUTO_MODE
);
CIOLIB_INIT
();
ciolib_gettextinfo
(
&
ti
);
os
=
_wscroll
;
_wscroll
=
0
;
...
...
@@ -521,8 +522,8 @@ void ciolib_clrscr(void)
int
width
,
height
;
struct
text_info
ti
;
if
(
!
initialized
)
initciolib
(
CIOLIB_AUTO_MODE
);
CIOLIB_INIT
();
ciolib_gettextinfo
(
&
ti
);
width
=
ti
.
winright
-
ti
.
winleft
+
1
;
...
...
@@ -540,8 +541,8 @@ void ciolib_delline(void)
{
struct
text_info
ti
;
if
(
!
initialized
)
initciolib
(
CIOLIB_AUTO_MODE
);
CIOLIB_INIT
();
ciolib_gettextinfo
(
&
ti
);
ciolib_movetext
(
ti
.
winleft
,
ti
.
cury
+
1
,
ti
.
winright
,
ti
.
winbottom
,
ti
.
winleft
,
ti
.
cury
);
...
...
@@ -554,8 +555,8 @@ void ciolib_insline(void)
{
struct
text_info
ti
;
if
(
!
initialized
)
initciolib
(
CIOLIB_AUTO_MODE
);
CIOLIB_INIT
();
ciolib_gettextinfo
(
&
ti
);
ciolib_movetext
(
ti
.
winleft
,
ti
.
cury
,
ti
.
winright
,
ti
.
winbottom
,
ti
.
winleft
,
ti
.
cury
+
1
);
...
...
@@ -575,8 +576,8 @@ int ciolib_cprintf(char *fmat, ...)
char
*
str
;
#endif
if
(
!
initialized
)
initciolib
(
CIOLIB_AUTO_MODE
);
CIOLIB_INIT
();
va_start
(
argptr
,
fmat
);
#ifdef _WIN32
ret
=
vsnprintf
(
str
,
sizeof
(
str
)
-
1
,
fmat
,
argptr
);
...
...
@@ -603,8 +604,8 @@ int ciolib_cputs(char *str)
int
pos
;
int
ret
=
0
;
if
(
!
initialized
)
initciolib
(
CIOLIB_AUTO_MODE
);
CIOLIB_INIT
();
for
(
pos
=
0
;
str
[
pos
];
pos
++
)
{
ret
=
str
[
pos
];
...
...
@@ -619,8 +620,8 @@ void ciolib_textbackground(int colour)
{
unsigned
char
attr
;
if
(
!
initialized
)
initciolib
(
CIOLIB_AUTO_MODE
);
CIOLIB_INIT
();
ciolib_gettextinfo
(
&
cio_textinfo
);
attr
=
cio_textinfo
.
attribute
;
attr
&=
143
;
...
...
@@ -632,8 +633,8 @@ void ciolib_textcolor(int colour)
{
unsigned
char
attr
;
if
(
!
initialized
)
initciolib
(
CIOLIB_AUTO_MODE
);
CIOLIB_INIT
();
ciolib_gettextinfo
(
&
cio_textinfo
);
attr
=
cio_textinfo
.
attribute
;
attr
&=
240
;
...
...
@@ -645,8 +646,8 @@ void ciolib_highvideo(void)
{
int
attr
;
if
(
!
initialized
)
initciolib
(
CIOLIB_AUTO_MODE
);
CIOLIB_INIT
();
ciolib_gettextinfo
(
&
cio_textinfo
);
attr
=
cio_textinfo
.
attribute
;
attr
|=
8
;
...
...
@@ -657,8 +658,8 @@ void ciolib_lowvideo(void)
{
int
attr
;
if
(
!
initialized
)
initciolib
(
CIOLIB_AUTO_MODE
);
CIOLIB_INIT
();
ciolib_gettextinfo
(
&
cio_textinfo
);
attr
=
cio_textinfo
.
attribute
;
attr
&=
0xf7
;
...
...
@@ -667,49 +668,49 @@ void ciolib_lowvideo(void)
void
ciolib_normvideo
(
void
)
{
if
(
!
initialized
)
initciolib
(
CIOLIB_AUTO_MODE
);
CIOLIB_INIT
();
ciolib_textattr
(
0x07
);
}
int
ciolib_puttext
(
int
a
,
int
b
,
int
c
,
int
d
,
unsigned
char
*
e
)
{
if
(
!
initialized
)
initciolib
(
CIOLIB_AUTO_MODE
);
CIOLIB_INIT
();
return
(
cio_api
.
puttext
(
a
,
b
,
c
,
d
,
e
));
}
int
ciolib_gettext
(
int
a
,
int
b
,
int
c
,
int
d
,
unsigned
char
*
e
)
{
if
(
!
initialized
)
initciolib
(
CIOLIB_AUTO_MODE
);
CIOLIB_INIT
();
return
(
cio_api
.
gettext
(
a
,
b
,
c
,
d
,
e
));
}
void
ciolib_textattr
(
unsigned
char
a
)
{
if
(
!
initialized
)
initciolib
(
CIOLIB_AUTO_MODE
);
CIOLIB_INIT
();
cio_api
.
textattr
(
a
);
}
void
ciolib_delay
(
long
a
)
{
if
(
!
initialized
)
initciolib
(
CIOLIB_AUTO_MODE
);
CIOLIB_INIT
();
cio_api
.
delay
(
a
);
}
int
ciolib_putch
(
unsigned
char
a
)
{
if
(
!
initialized
)
initciolib
(
CIOLIB_AUTO_MODE
);
CIOLIB_INIT
();
return
(
cio_api
.
putch
(
a
));
}
void
ciolib_setcursortype
(
int
a
)
{
if
(
!
initialized
)
initciolib
(
CIOLIB_AUTO_MODE
);
CIOLIB_INIT
();
cio_api
.
setcursortype
(
a
);
}
This diff is collapsed.
Click to expand it.
src/conio/ciolib.h
+
6
−
6
View file @
102068b9
...
...
@@ -4,12 +4,12 @@
#define _CIOLIB_H_
enum
{
CIOLIB_
AUTO_MODE
,
CIOLIB_CURSES
_MODE
,
CIOLIB_CURSES_IBM
_MODE
,
CIOLIB_
ANSI_MODE
,
CIOLIB_
X_
MODE
,
CIOLIB_CONIO
_MODE
CIOLIB_
MODE_AUTO
,
CIOLIB_
MODE_
CURSES
,
CIOLIB_
MODE_
CURSES_IBM
,
CIOLIB_
MODE_ANSI
,
CIOLIB_MODE
_X
,
CIOLIB_
MODE_
CONIO
};
#ifndef __unix__
/* presumably, Win32 */
...
...
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