Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
sodium
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
Frans Klaver
sodium
Commits
ffb461c6
Commit
ffb461c6
authored
9 years ago
by
Ticki
Browse files
Options
Downloads
Patches
Plain Diff
Aaaand, it working (almost)
parent
37f32f45
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
src/buffer.rs
+17
-19
17 additions, 19 deletions
src/buffer.rs
src/editor.rs
+5
-1
5 additions, 1 deletion
src/editor.rs
src/main.rs
+3
-0
3 additions, 0 deletions
src/main.rs
src/mode.rs
+1
-2
1 addition, 2 deletions
src/mode.rs
src/options.rs
+4
-0
4 additions, 0 deletions
src/options.rs
with
30 additions
and
22 deletions
src/buffer.rs
+
17
−
19
View file @
ffb461c6
...
@@ -121,7 +121,7 @@ impl<'a> Buffer<'a> for SplitBuffer {
...
@@ -121,7 +121,7 @@ impl<'a> Buffer<'a> for SplitBuffer {
if
n
<
self
.before
.len
()
{
if
n
<
self
.before
.len
()
{
Some
(
&
self
.before
[
n
])
Some
(
&
self
.before
[
n
])
}
else
if
n
<
self
.len
()
{
}
else
if
n
<
self
.len
()
{
let
n
=
self
.
after
.len
()
-
(
n
-
self
.before
.len
())
-
1
;
let
n
=
self
.
len
()
+
1
-
n
;
Some
(
&
self
.after
[
n
])
Some
(
&
self
.after
[
n
])
}
else
{
}
else
{
None
None
...
@@ -133,7 +133,7 @@ impl<'a> Buffer<'a> for SplitBuffer {
...
@@ -133,7 +133,7 @@ impl<'a> Buffer<'a> for SplitBuffer {
if
n
<
self
.before
.len
()
{
if
n
<
self
.before
.len
()
{
Some
(
&
mut
self
.before
[
n
])
Some
(
&
mut
self
.before
[
n
])
}
else
if
n
<
self
.len
()
{
}
else
if
n
<
self
.len
()
{
let
n
=
self
.
after
.len
()
-
(
n
-
self
.before
.len
())
-
1
;
let
n
=
self
.
len
()
+
1
-
n
;
Some
(
&
mut
self
.after
[
n
])
Some
(
&
mut
self
.after
[
n
])
}
else
{
}
else
{
None
None
...
@@ -145,7 +145,7 @@ impl<'a> Buffer<'a> for SplitBuffer {
...
@@ -145,7 +145,7 @@ impl<'a> Buffer<'a> for SplitBuffer {
if
n
<
self
.before
.len
()
{
if
n
<
self
.before
.len
()
{
self
.before
.remove
(
n
)
self
.before
.remove
(
n
)
}
else
if
n
<
self
.len
()
{
}
else
if
n
<
self
.len
()
{
let
n
=
self
.
after
.len
()
-
(
n
-
self
.before
.len
())
-
1
;
let
n
=
self
.
len
()
+
1
-
n
;
self
.after
.remove
(
n
)
self
.after
.remove
(
n
)
}
else
{
}
else
{
panic!
(
"Out of bound"
);
panic!
(
"Out of bound"
);
...
@@ -157,7 +157,7 @@ impl<'a> Buffer<'a> for SplitBuffer {
...
@@ -157,7 +157,7 @@ impl<'a> Buffer<'a> for SplitBuffer {
if
n
<
self
.before
.len
()
{
if
n
<
self
.before
.len
()
{
self
.before
.insert
(
n
,
line
);
self
.before
.insert
(
n
,
line
);
}
else
if
n
<
self
.len
()
{
}
else
if
n
<
self
.len
()
{
let
n
=
self
.
after
.len
()
-
(
n
-
self
.before
.len
())
-
1
;
let
n
=
self
.
len
()
+
1
-
n
;
self
.after
.insert
(
n
,
line
);
self
.after
.insert
(
n
,
line
);
}
else
{
}
else
{
panic!
(
"Out of bound"
);
panic!
(
"Out of bound"
);
...
@@ -210,19 +210,18 @@ impl<'a> Buffer<'a> for SplitBuffer {
...
@@ -210,19 +210,18 @@ impl<'a> Buffer<'a> for SplitBuffer {
/// Get the leading whitespaces of the nth line. Used for autoindenting.
/// Get the leading whitespaces of the nth line. Used for autoindenting.
fn
get_indent
(
&
self
,
n
:
usize
)
->
&
str
{
fn
get_indent
(
&
self
,
n
:
usize
)
->
&
str
{
let
ln
=
if
let
Some
(
s
)
=
self
.get_line
(
n
)
{
if
let
Some
(
ln
)
=
self
.get_line
(
n
)
{
s
let
mut
len
=
0
;
}
else
{
for
c
in
ln
.chars
()
{
return
""
;
match
c
{
};
'\t'
|
' '
=>
len
+=
1
,
let
mut
len
=
0
;
_
=>
break
,
for
c
in
ln
.chars
()
{
}
match
c
{
'\t'
|
' '
=>
len
+=
1
,
_
=>
break
,
}
}
&
ln
[
..
len
]
}
else
{
""
}
}
&
ln
[
..
len
]
}
}
}
}
...
@@ -265,13 +264,12 @@ impl<'a> Iterator for SplitBufIter<'a> {
...
@@ -265,13 +264,12 @@ impl<'a> Iterator for SplitBufIter<'a> {
type
Item
=
&
'a
String
;
type
Item
=
&
'a
String
;
fn
next
(
&
mut
self
)
->
Option
<&
'a
String
>
{
fn
next
(
&
mut
self
)
->
Option
<&
'a
String
>
{
let
ln
=
self
.line
;
self
.nth
(
1
)
self
.nth
(
ln
)
}
}
fn
nth
(
&
mut
self
,
n
:
usize
)
->
Option
<&
'a
String
>
{
fn
nth
(
&
mut
self
,
n
:
usize
)
->
Option
<&
'a
String
>
{
self
.line
=
n
;
self
.line
+
=
n
;
self
.buffer
.get_line
(
n
)
self
.buffer
.get_line
(
self
.line
)
}
}
fn
count
(
self
)
->
usize
{
fn
count
(
self
)
->
usize
{
...
...
This diff is collapsed.
Click to expand it.
src/editor.rs
+
5
−
1
View file @
ffb461c6
...
@@ -41,7 +41,6 @@ impl Editor {
...
@@ -41,7 +41,6 @@ impl Editor {
/// Create new default state editor
/// Create new default state editor
pub
fn
init
()
{
pub
fn
init
()
{
#[cfg(feature
=
"orbital"
)]
#[cfg(feature
=
"orbital"
)]
let
window
=
Window
::
new
(
-
1
,
-
1
,
700
,
500
,
&
"Sodium"
)
.unwrap
();
let
window
=
Window
::
new
(
-
1
,
-
1
,
700
,
500
,
&
"Sodium"
)
.unwrap
();
...
@@ -74,11 +73,16 @@ impl Editor {
...
@@ -74,11 +73,16 @@ impl Editor {
redraw_task
:
RedrawTask
::
Null
,
redraw_task
:
RedrawTask
::
Null
,
};
};
debugln!
(
editor
,
"Starting Sodium"
);
editor
.redraw
();
editor
.redraw
();
debugln!
(
editor
,
"First redraw of the screen"
);
loop
{
loop
{
let
inp
=
editor
.get_inst
();
let
inp
=
editor
.get_inst
();
if
let
Inst
(
_
,
Cmd
{
key
:
Key
::
Quit
})
=
inp
{
if
let
Inst
(
_
,
Cmd
{
key
:
Key
::
Quit
})
=
inp
{
debugln!
(
editor
,
"C'ya"
);
break
;
break
;
}
}
editor
.exec
(
inp
);
editor
.exec
(
inp
);
...
...
This diff is collapsed.
Click to expand it.
src/main.rs
+
3
−
0
View file @
ffb461c6
...
@@ -3,6 +3,9 @@
...
@@ -3,6 +3,9 @@
#[cfg(feature
=
"orbital"
)]
#[cfg(feature
=
"orbital"
)]
extern
crate
orbital
;
extern
crate
orbital
;
#[macro_use]
pub
mod
debug
;
pub
mod
editor
;
pub
mod
editor
;
pub
mod
buffer
;
pub
mod
buffer
;
pub
mod
parse
;
pub
mod
parse
;
...
...
This diff is collapsed.
Click to expand it.
src/mode.rs
+
1
−
2
View file @
ffb461c6
...
@@ -25,8 +25,7 @@ impl Mode {
...
@@ -25,8 +25,7 @@ impl Mode {
Command
(
Normal
)
=>
"Normal"
,
Command
(
Normal
)
=>
"Normal"
,
Primitive
(
Insert
(
_
))
=>
"Insert"
,
Primitive
(
Insert
(
_
))
=>
"Insert"
,
Primitive
(
Prompt
)
=>
"Prompt"
,
Primitive
(
Prompt
)
=>
"Prompt"
,
}
}
.to_string
()
.to_string
()
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
src/options.rs
+
4
−
0
View file @
ffb461c6
...
@@ -2,6 +2,7 @@ pub struct Options {
...
@@ -2,6 +2,7 @@ pub struct Options {
pub
highlight
:
bool
,
pub
highlight
:
bool
,
pub
autoindent
:
bool
,
pub
autoindent
:
bool
,
pub
line_marker
:
bool
,
pub
line_marker
:
bool
,
pub
debug
:
bool
,
}
}
impl
Options
{
impl
Options
{
...
@@ -11,6 +12,7 @@ impl Options {
...
@@ -11,6 +12,7 @@ impl Options {
highlight
:
true
,
highlight
:
true
,
autoindent
:
true
,
autoindent
:
true
,
line_marker
:
true
,
line_marker
:
true
,
debug
:
true
,
// TODO: Let this be `true` only in debug compilation cfg
}
}
}
}
...
@@ -20,6 +22,7 @@ impl Options {
...
@@ -20,6 +22,7 @@ impl Options {
"hightlight"
|
"hl"
=>
Some
(
&
mut
self
.highlight
),
"hightlight"
|
"hl"
=>
Some
(
&
mut
self
.highlight
),
"autoindent"
|
"ai"
=>
Some
(
&
mut
self
.autoindent
),
"autoindent"
|
"ai"
=>
Some
(
&
mut
self
.autoindent
),
"line_marker"
|
"linemarker"
|
"linemark"
|
"lm"
=>
Some
(
&
mut
self
.line_marker
),
"line_marker"
|
"linemarker"
|
"linemark"
|
"lm"
=>
Some
(
&
mut
self
.line_marker
),
"debug"
|
"debug_mode"
=>
Some
(
&
mut
self
.debug
),
_
=>
None
,
_
=>
None
,
}
}
}
}
...
@@ -30,6 +33,7 @@ impl Options {
...
@@ -30,6 +33,7 @@ impl Options {
"hightlight"
|
"hl"
=>
Some
(
self
.highlight
),
"hightlight"
|
"hl"
=>
Some
(
self
.highlight
),
"autoindent"
|
"ai"
=>
Some
(
self
.autoindent
),
"autoindent"
|
"ai"
=>
Some
(
self
.autoindent
),
"line_marker"
|
"linemarker"
|
"linemark"
|
"lm"
=>
Some
(
self
.line_marker
),
"line_marker"
|
"linemarker"
|
"linemark"
|
"lm"
=>
Some
(
self
.line_marker
),
"debug"
|
"debug_mode"
=>
Some
(
self
.debug
),
_
=>
None
,
_
=>
None
,
}
}
}
}
...
...
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