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
c9bc4bc9
Commit
c9bc4bc9
authored
19 years ago
by
deuce
Browse files
Options
Downloads
Patches
Plain Diff
Do cleareol and clearscreen optimizations. List the scroll optimzation is
left.
parent
efed8b82
Branches
Branches containing commit
Tags
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
+99
-18
99 additions, 18 deletions
src/conio/ansi_cio.c
with
99 additions
and
18 deletions
src/conio/ansi_cio.c
+
99
−
18
View file @
c9bc4bc9
...
...
@@ -217,6 +217,7 @@ void ansi_sendstr(char *str,int len)
int
ansi_puttext
(
int
sx
,
int
sy
,
int
ex
,
int
ey
,
void
*
buf
)
{
int
x
,
y
;
int
cx
,
cy
,
i
,
j
;
unsigned
char
*
out
;
WORD
sch
;
struct
text_info
ti
;
...
...
@@ -240,25 +241,103 @@ int ansi_puttext(int sx, int sy, int ex, int ey, void* buf)
out
=
fill
;
attrib
=
ti
.
attribute
;
for
(
y
=
sy
-
1
;
y
<
ey
;
y
++
)
{
for
(
x
=
sx
-
1
;
x
<
ex
;
x
++
)
{
sch
=*
(
out
++
);
if
(
sch
==
27
)
sch
=
' '
;
if
(
sch
==
0
)
sch
=
' '
;
sch
|=
(
*
(
out
++
))
<<
8
;
if
(
ansivmem
[
y
*
ansi_cols
+
x
]
==
sch
)
continue
;
ansivmem
[
y
*
ansi_cols
+
x
]
=
sch
;
ansi_gotoxy
(
x
+
1
,
y
+
1
);
if
(
y
>=
ansi_rows
-
1
&&
x
>=
ansi_cols
-
1
)
continue
;
if
(
attrib
!=
sch
>>
8
)
{
textattr
(
sch
>>
8
);
attrib
=
sch
>>
8
;
i
=
0
;
/* Did a nasty. */
/* Check if this is a nasty scroll */
/* Check if this is a nasty screen clear... */
j
=
0
;
/* We can clearscreen */
if
(
sx
==
1
&&
sy
==
1
&&
ex
==
ti
.
screenwidth
&&
ey
==
ti
.
screenheight
&&
(
*
out
==
' '
||
*
out
==
0
))
{
j
=
1
;
/* We can clearscreen */
for
(
cy
=
sy
-
1
;
cy
<
ey
;
cy
++
)
{
for
(
cx
=
sx
-
1
;
cx
<
ex
;
cx
++
)
{
if
(
out
[(
cy
*
ti
.
screenwidth
+
cx
)
*
2
]
!=*
out
||
out
[(
cy
*
ti
.
screenwidth
+
cx
)
*
2
+
1
]
!=*
(
out
+
1
))
{
j
=
0
;
cx
=
ex
;
cy
=
ey
;
}
}
}
}
if
(
j
)
{
textattr
(
*
(
out
+
1
));
/* Many terminals make ESC[2J home the cursor */
ansi_sendstr
(
"
\033
[2J
\033
[1;1H"
,
-
1
);
ansi_col
=
0
;
ansi_row
=
0
;
memcpy
(
ansivmem
,
out
,
ti
.
screenwidth
*
ti
.
screenheight
*
2
);
i
=
1
;
}
if
(
!
i
)
{
for
(
y
=
sy
-
1
;
y
<
ey
;
y
++
)
{
for
(
x
=
sx
-
1
;
x
<
ex
;
x
++
)
{
/*
* Check if we can use clear2eol now... this means the rest of the
* chars on the line are the same attr, and are all spaces or NULLs
* Also, if there's less than four chars left, it's not worth it.
*/
i
=
0
;
/* number of differing chars from screen */
j
=
1
;
/* Can use clrtoeol? */
for
(
cx
=
x
;
cx
<
ti
.
screenwidth
;
cx
++
)
{
/* Compare to source buffer */
if
(
cx
<
ex
)
{
/* a blank? */
if
(
*
(
out
+
(
cx
-
x
)
*
2
)
==
' '
||
*
(
out
+
(
cx
-
x
)
*
2
)
==
0
)
{
/* same colour? */
if
(
*
(
out
+
(
cx
-
x
)
*
2
+
1
)
==*
(
out
+
1
))
{
/* Is it any change? */
if
(
*
((
WORD
*
)(
out
+
(
cx
-
x
)
*
2
))
!=
ansivmem
[
y
*
2
+
cx
])
/* And it's different! */
i
++
;
}
else
{
j
=
0
;
break
;
}
}
else
{
j
=
0
;
break
;
}
}
else
{
/* Compare to screen */
/* a blank? */
if
((
ansivmem
[
y
*
2
+
cx
]
&
0xff
)
!=
' '
&&
(
ansivmem
[
y
*
2
+
cx
]
&
0xff
)
!=
0
)
{
j
=
0
;
break
;
}
}
}
if
(
j
&&
i
>
3
)
{
ansi_gotoxy
(
x
+
1
,
y
+
1
);
textattr
(
*
(
out
+
1
));
ansi_sendstr
(
"
\033
[K"
,
-
1
);
for
(
cx
=
x
;
cx
<
ex
;
cx
++
)
{
ansivmem
[
y
*
ansi_cols
+
cx
]
=*
(
out
++
);
ansivmem
[
y
*
ansi_cols
+
cx
]
|=
(
*
(
out
++
))
<<
8
;
}
break
;
}
sch
=*
(
out
++
);
if
(
sch
==
27
)
sch
=
' '
;
if
(
sch
==
0
)
sch
=
' '
;
sch
|=
(
*
(
out
++
))
<<
8
;
if
(
ansivmem
[
y
*
ansi_cols
+
x
]
==
sch
)
continue
;
ansivmem
[
y
*
ansi_cols
+
x
]
=
sch
;
ansi_gotoxy
(
x
+
1
,
y
+
1
);
if
(
y
>=
ansi_rows
-
1
&&
x
>=
ansi_cols
-
1
)
continue
;
if
(
attrib
!=
sch
>>
8
)
{
textattr
(
sch
>>
8
);
attrib
=
sch
>>
8
;
}
ansi_sendch
((
char
)(
sch
&
0xff
));
}
ansi_sendch
((
char
)(
sch
&
0xff
));
}
}
...
...
@@ -611,6 +690,8 @@ void ansi_gotoxy(int x, int y)
||
y
>
ansi_rows
)
return
;
/* ToDo optimizations: use tabs for horizontal movement to tabstops */
/* Movement forced... always send position code */
if
(
force_move
)
{
sprintf
(
str
,
"
\033
[%d;%dH"
,
y
,
x
);
...
...
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