Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
mensactrl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
stratum0
mensactrl
Commits
cc0e2ff7
Commit
cc0e2ff7
authored
10 years ago
by
rohieb
Browse files
Options
Downloads
Patches
Plain Diff
python: make client.writeline() autoscroll as least surprise
parent
ac6a6e56
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
python/cat.py
+3
-19
3 additions, 19 deletions
python/cat.py
python/client.py
+15
-4
15 additions, 4 deletions
python/client.py
with
18 additions
and
23 deletions
python/cat.py
+
3
−
19
View file @
cc0e2ff7
...
...
@@ -4,24 +4,8 @@ import sys
import
client
# read lines from stdin and write them to the display.
# includes scrolling.
# FIXME: scrolling is slow. use a pixel buffer and blitting.
if
__name__
==
"
__main__
"
:
y
=
0
lines
=
[]
line
=
sys
.
stdin
.
readline
()
while
(
line
!=
""
):
client
.
writeline
(
line
)
line
=
sys
.
stdin
.
readline
()
while
(
line
!=
""
):
client
.
write
(
0
,
y
,
line
)
lines
.
append
(
line
)
if
(
y
==
client
.
NUM_SEG_Y
):
lines
.
reverse
()
lines
.
pop
()
lines
.
reverse
()
y
=
0
for
l
in
lines
:
client
.
write
(
0
,
y
,
l
)
y
+=
1
else
:
y
+=
1
line
=
sys
.
stdin
.
readline
()
This diff is collapsed.
Click to expand it.
python/client.py
+
15
−
4
View file @
cc0e2ff7
...
...
@@ -111,10 +111,21 @@ def write(x, y, string):
if
(
x
>
NUM_SEG_X
):
return
False
# write text at beginning of line and clear remaining horizontal space
def
writeline
(
y
,
string
):
write
(
0
,
y
,
string
)
write
(
len
(
string
),
y
,
'
'
*
(
NUM_SEG_X
-
len
(
string
)))
# write line to screen as if on a terminal, scroll up if neccessary
cur_line
=
-
1
def
writeline
(
string
):
global
cur_line
cur_line
+=
1
if
(
cur_line
>=
NUM_SEG_Y
):
scrollline
()
cur_line
-=
1
write
(
0
,
cur_line
,
string
)
# clear remaining row
clear_chars
=
(
NUM_SEG_X
-
len
(
string
))
screenbuf_blit
(
len
(
string
)
*
PWIDTH
,
cur_line
*
PHEIGHT
,
clear_chars
*
PWIDTH
,
PHEIGHT
,
[
0
]
*
clear_chars
*
PWIDTH
*
PHEIGHT
)
# scroll the content y lines up and clear last line
def
scrollline
(
y
=
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