Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sodium
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
29
Issues
29
List
Boards
Labels
Service Desk
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
redox-os
sodium
Commits
d53e951c
Commit
d53e951c
authored
Oct 31, 2015
by
Ticki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Work on the status bar
parent
ecc743fb
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
69 additions
and
20 deletions
+69
-20
TODO.md
TODO.md
+2
-2
exec.rs
exec.rs
+8
-1
graphics.rs
graphics.rs
+40
-15
motion.rs
motion.rs
+9
-1
parse.rs
parse.rs
+10
-1
No files found.
TODO.md
View file @
d53e951c
...
...
@@ -20,7 +20,7 @@ The bug causing these two bugs, is localised to be in position.rs. It resolves b
6) Now go one down
7) You'll end up on e, even though it should be d
-
[
] Crashes when:
-
[
x
] Crashes when:
1) Write abc on line 1
2) Press o to go to the next line
3) Go to normal mode
...
...
@@ -28,4 +28,4 @@ The bug causing these two bugs, is localised to be in position.rs. It resolves b
5) Type text
6) Out of bound (index) error
-
[
] When typing the first char in a line in normal insert mode, it wont go to the next char.
-
[
x
] When typing the first char in a line in normal insert mode, it wont go to the next char.
exec.rs
View file @
d53e951c
...
...
@@ -168,7 +168,14 @@ impl Editor {
self
.goto
(
p
);
}
},
_
=>
{},
Char
(
c
)
=>
{
self
.status_bar.msg
=
format!
(
"Unknown command: {}"
,
c
);
self
.redraw_status_bar
();
}
_
=>
{
self
.status_bar.msg
=
format!
(
"Unknown command"
);
self
.redraw_status_bar
();
},
},
Primitive
(
Insert
(
opt
))
=>
{
self
.insert
(
cmd
.key
,
opt
);
...
...
graphics.rs
View file @
d53e951c
...
...
@@ -64,6 +64,14 @@ impl Editor {
}
}
self
.redraw_status_bar
();
self
.window
.sync
();
}
pub
fn
redraw_status_bar
(
&
mut
self
)
{
let
h
=
self
.window
.height
();
let
w
=
self
.window
.width
();
let
mode
=
self
.cursor
()
.mode
;
self
.window
.rect
(
0
,
h
as
isize
-
18
-
{
if
mode
==
Mode
::
Primitive
(
PrimitiveMode
::
Prompt
)
{
18
...
...
@@ -72,20 +80,14 @@ impl Editor {
}
},
w
,
18
,
Color
::
rgba
(
74
,
74
,
74
,
255
));
for
(
n
,
c
)
in
(
if
self
.status_bar.mode
.len
()
>
w
/
(
8
*
4
)
{
self
.status_bar.mode
.chars
()
.take
(
w
/
(
8
*
4
)
-
5
)
.chain
(
vec!
[
'.'
,
'.'
,
'.'
])
.collect
::
<
Vec
<
_
>>
()
}
else
{
self
.status_bar.mode
.chars
()
.collect
()
})
.into_iter
()
.enumerate
()
{
self
.window
.char
(
n
as
isize
*
8
,
h
as
isize
-
16
-
1
-
{
if
mode
==
Mode
::
Primitive
(
PrimitiveMode
::
Prompt
)
{
16
+
1
+
1
}
else
{
0
}
},
c
,
Color
::
WHITE
);
}
let
sb_mode
=
self
.status_bar.mode
.clone
();
status_bar
(
self
,
sb_mode
,
0
,
4
);
let
sb_file
=
self
.status_bar.file
.clone
();
status_bar
(
self
,
sb_file
,
1
,
4
);
let
sb_cmd
=
self
.status_bar.cmd
.clone
();
status_bar
(
self
,
sb_cmd
,
2
,
4
);
let
sb_msg
=
self
.status_bar.msg
.clone
();
status_bar
(
self
,
sb_msg
,
3
,
4
);
for
(
n
,
c
)
in
self
.prompt
.chars
()
.enumerate
()
{
self
.window
.char
(
n
as
isize
*
8
,
h
as
isize
-
16
-
1
,
c
,
Color
::
WHITE
);
...
...
@@ -95,6 +97,29 @@ impl Editor {
}
}
fn
status_bar
(
editor
:
&
mut
Editor
,
text
:
String
,
a
:
usize
,
b
:
usize
)
{
let
h
=
editor
.window
.height
();
let
w
=
editor
.window
.width
();
let
(
x
,
y
)
=
editor
.pos
();
let
mode
=
editor
.cursor
()
.mode
;
for
(
n
,
c
)
in
(
if
text
.len
()
>
w
/
(
8
*
b
)
{
text
.chars
()
.take
(
w
/
(
8
*
b
)
-
5
)
.chain
(
vec!
[
'.'
,
'.'
,
'.'
])
.collect
::
<
Vec
<
_
>>
()
}
else
{
text
.chars
()
.collect
()
})
.into_iter
()
.enumerate
()
{
editor
.window
.char
(((
w
*
a
)
/
b
)
as
isize
+
(
n
as
isize
*
8
),
h
as
isize
-
16
-
1
-
{
if
mode
==
Mode
::
Primitive
(
PrimitiveMode
::
Prompt
)
{
16
+
1
+
1
}
else
{
0
}
},
c
,
Color
::
WHITE
);
}
}
/// The statubar (showing various info about the current state of the editor)
pub
struct
StatusBar
{
/// The current mode
...
...
@@ -114,7 +139,7 @@ impl StatusBar {
mode
:
"Normal"
.to_string
(),
file
:
String
::
new
(),
cmd
:
String
::
new
(),
msg
:
String
::
new
(),
msg
:
"Welcome to Sodium!"
.to_string
(),
}
}
}
motion.rs
View file @
d53e951c
...
...
@@ -23,7 +23,15 @@ impl Editor {
None
}
},
_
=>
None
,
Char
(
c
)
=>
{
self
.status_bar.msg
=
format!
(
"Motion not defined: '{}'"
,
c
);
self
.redraw_status_bar
();
None
},
_
=>
{
self
.status_bar.msg
=
format!
(
"Motion not defined"
);
None
},
}
}
/// Convert an instruction to a motion (new coordinate) (unbounded)
...
...
parse.rs
View file @
d53e951c
...
...
@@ -38,6 +38,8 @@ impl Editor {
.unwrap_or
(
Event
::
new
())
.to_option
()
{
if
k
.pressed
{
self
.status_bar.cmd
.push
(
k
.character
);
self
.redraw_status_bar
();
return
k
.character
;
}
}
...
...
@@ -54,9 +56,12 @@ impl Editor {
let
mut
shift
=
false
;
let
mut
key
=
Key
::
Null
;
self
.status_bar.cmd
=
String
::
new
();
// self.status_bar.cmd = String::new();
loop
{
if
let
EventOption
::
Key
(
k
)
=
self
.window
.poll
()
.unwrap_or
(
Event
::
new
())
.to_option
()
{
let
c
=
k
.character
;
match
c
{
'\0'
=>
{
...
...
@@ -79,6 +84,9 @@ impl Editor {
}
}
_
=>
if
k
.pressed
{
self
.status_bar.cmd
.push
(
c
);
self
.redraw_status_bar
();
match
self
.cursor
()
.mode
{
Mode
::
Primitive
(
_
)
=>
{
key
=
Key
::
Char
(
c
);
...
...
@@ -131,7 +139,8 @@ impl Editor {
n
//return Inst(if unset { Parameter::Null } else { Parameter::Int(n) }, Key::Char(c));
}
}
};
// self.status_bar.cmd.push(c);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment