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
dccc711a
Commit
dccc711a
authored
17 years ago
by
deuce
Browse files
Options
Downloads
Patches
Plain Diff
Auto-detect number of rows on screen in ANSI mode.
parent
a2b9063f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/conio/ansi_cio.c
+28
-5
28 additions, 5 deletions
src/conio/ansi_cio.c
with
28 additions
and
5 deletions
src/conio/ansi_cio.c
+
28
−
5
View file @
dccc711a
...
...
@@ -64,7 +64,7 @@ sem_t need_key;
static
BOOL
sent_ga
=
FALSE
;
WORD
ansi_curr_attr
=
0x07
<<
8
;
int
ansi_rows
=
24
;
int
ansi_rows
=
-
1
;
int
ansi_cols
=
80
;
int
ansi_got_row
=
0
;
int
ansi_got_col
=
0
;
...
...
@@ -503,7 +503,8 @@ static void ansi_keyparse(void *par)
seq
[
0
]
=
0
;
for
(;;)
{
sem_wait
(
&
goahead
);
if
(
ansi_rows
!=
-
1
)
sem_wait
(
&
goahead
);
if
(
timedout
||
unknown
)
{
for
(
p
=
seq
;
*
p
;
p
++
)
{
ansi_inch
=*
p
;
...
...
@@ -563,6 +564,16 @@ static void ansi_keyparse(void *par)
break
;
}
}
/* ANSI position report? */
if
(
ch
==
'R'
)
{
if
(
strspn
(
seq
,
"
\033
[0123456789;R"
)
==
strlen
(
seq
))
{
p
=
seq
+
2
;
i
=
strtol
(
p
,
&
p
,
10
);
if
(
i
>
ansi_rows
)
ansi_rows
=
i
;
}
unknown
=
0
;
}
if
(
unknown
)
{
sem_post
(
&
goahead
);
continue
;
...
...
@@ -886,7 +897,8 @@ void ansi_fixterm(void)
int
ansi_initciolib
(
long
inmode
)
{
int
i
;
char
*
init
=
"
\033
[0m
\033
[2J
\033
[1;1H"
;
char
*
init
=
"
\033
[s
\033
[99B_
\033
[6n
\033
[u
\033
[0m_
\033
[2J
\033
[H"
;
time_t
start
;
#ifdef _WIN32
if
(
isatty
(
fileno
(
stdin
)))
{
...
...
@@ -923,10 +935,21 @@ int ansi_initciolib(long inmode)
sem_init
(
&
goahead
,
0
,
0
);
sem_init
(
&
need_key
,
0
,
0
);
ansivmem
=
(
WORD
*
)
malloc
(
ansi_rows
*
ansi_cols
*
sizeof
(
WORD
));
ansi_sendstr
(
init
,
-
1
);
_beginthread
(
ansi_keythread
,
1024
,
NULL
);
start
=
time
(
NULL
);
while
(
time
(
NULL
)
-
start
<
5
&&
ansi_rows
==-
1
)
SLEEP
(
1
);
if
(
ansi_rows
==-
1
)
ansi_rows
=
24
;
ansivmem
=
(
WORD
*
)
malloc
(
ansi_rows
*
ansi_cols
*
sizeof
(
WORD
));
for
(
i
=
0
;
i
<
ansi_rows
*
ansi_cols
;
i
++
)
ansivmem
[
i
]
=
0x0720
;
_beginthread
(
ansi_keythread
,
1024
,
NULL
);
/* drain all the semaphores */
sem_reset
(
&
got_key
);
sem_reset
(
&
got_input
);
sem_reset
(
&
used_input
);
sem_reset
(
&
goahead
);
sem_reset
(
&
need_key
);
return
(
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