Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
orbutils
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
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nick Thomas
orbutils
Commits
7e09e836
Commit
7e09e836
authored
7 years ago
by
Jeremy Soller
Browse files
Options
Downloads
Patches
Plain Diff
Resizable character map
parent
94a608ca
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/character_map/main.rs
+43
-45
43 additions, 45 deletions
src/character_map/main.rs
with
43 additions
and
45 deletions
src/character_map/main.rs
+
43
−
45
View file @
7e09e836
...
@@ -7,32 +7,9 @@ use std::cmp::max;
...
@@ -7,32 +7,9 @@ use std::cmp::max;
use
std
::
env
;
use
std
::
env
;
use
orbclient
::{
Color
,
Renderer
,
Window
,
EventOption
,
K_ESC
};
use
orbclient
::{
Color
,
Renderer
,
Window
,
WindowFlag
,
EventOption
};
use
orbfont
::
Font
;
use
orbfont
::
Font
;
fn
event_loop
(
window
:
&
mut
Window
){
loop
{
for
event
in
window
.events
()
{
if
let
EventOption
::
Key
(
key_event
)
=
event
.to_option
()
{
if
key_event
.pressed
&&
key_event
.scancode
==
K_ESC
{
return
;
}
}
if
let
EventOption
::
Quit
(
_
)
=
event
.to_option
()
{
return
;
}
}
}
}
fn
error_msg
(
window
:
&
mut
Window
,
msg
:
&
str
)
{
let
mut
x
=
0
;
for
c
in
msg
.chars
()
{
window
.char
(
x
,
0
,
c
,
Color
::
rgb
(
255
,
255
,
255
));
x
+=
8
;
}
}
fn
main
()
{
fn
main
()
{
let
(
title
,
font_res
)
=
match
env
::
args
()
.nth
(
1
)
{
let
(
title
,
font_res
)
=
match
env
::
args
()
.nth
(
1
)
{
Some
(
arg
)
=>
(
arg
.clone
(),
Font
::
from_path
(
&
arg
)),
Some
(
arg
)
=>
(
arg
.clone
(),
Font
::
from_path
(
&
arg
)),
...
@@ -49,38 +26,59 @@ fn main() {
...
@@ -49,38 +26,59 @@ fn main() {
font
.render
(
"stuvwxyz.?!"
,
64.0
),
font
.render
(
"stuvwxyz.?!"
,
64.0
),
font
.render
(
"0123456789 "
,
64.0
)
font
.render
(
"0123456789 "
,
64.0
)
];
];
let
mut
width
=
0
;
let
mut
width
=
0
;
let
mut
height
=
0
;
let
mut
height
=
0
;
for
line
in
lines
.iter
()
{
for
line
in
lines
.iter
()
{
width
=
max
(
width
,
line
.width
());
width
=
max
(
width
,
line
.width
());
height
+=
line
.height
();
height
+=
line
.height
();
}
}
let
mut
window
=
Window
::
new
(
-
1
,
-
1
,
let
redraw
=
move
|
window
:
&
mut
Window
|
{
max
(
320
,
width
),
window
.set
(
Color
::
rgb
(
255
,
255
,
255
));
max
(
32
,
height
),
let
mut
y
=
0
;
&
(
"Character Map ("
.to_string
()
+
&
title
+
")"
))
for
line
in
lines
.iter
()
{
.unwrap
();
line
.draw
(
window
,
0
,
y
,
Color
::
rgb
(
0
,
0
,
0
));
window
.set
(
Color
::
rgb
(
255
,
255
,
255
));
y
+=
line
.height
()
as
i32
;
let
mut
y
=
0
;
}
for
line
in
lines
.iter
()
{
window
.sync
();
line
.draw
(
&
mut
window
,
0
,
y
,
Color
::
rgb
(
0
,
0
,
0
));
};
y
+=
line
.height
()
as
i32
;
let
mut
window
=
Window
::
new_flags
(
-
1
,
-
1
,
max
(
320
,
width
),
max
(
32
,
height
),
&
format!
(
"{} - Character Map"
,
title
),
&
[
WindowFlag
::
Resizable
])
.unwrap
();
redraw
(
&
mut
window
);
loop
{
for
event
in
window
.events
()
{
match
event
.to_option
()
{
EventOption
::
Resize
(
_
)
=>
redraw
(
&
mut
window
),
EventOption
::
Quit
(
_
)
=>
return
,
_
=>
()
}
}
}
}
window
.sync
();
event_loop
(
&
mut
window
);
},
},
Err
(
err
)
=>
{
Err
(
err
)
=>
{
let
mut
window
=
Window
::
new
(
-
1
,
let
mut
window
=
Window
::
new
(
-
1
,
-
1
,
320
,
32
,
&
format!
(
"{} - Character Map"
,
title
))
-
1
,
.unwrap
();
320
,
32
,
&
(
"Character Map ("
.to_string
()
+
&
title
+
")"
))
.unwrap
();
window
.set
(
Color
::
rgb
(
0
,
0
,
0
));
window
.set
(
Color
::
rgb
(
0
,
0
,
0
));
error_msg
(
&
mut
window
,
&
format!
(
"{}"
,
err
));
let
mut
x
=
0
;
for
c
in
format!
(
"{}"
,
err
)
.chars
()
{
window
.char
(
x
,
0
,
c
,
Color
::
rgb
(
255
,
255
,
255
));
x
+=
8
;
}
window
.sync
();
window
.sync
();
event_loop
(
&
mut
window
);
loop
{
for
event
in
window
.events
()
{
match
event
.to_option
()
{
EventOption
::
Quit
(
_
)
=>
return
,
_
=>
()
}
}
}
}
}
}
}
}
}
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