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
L
liner
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
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
AdminXVII
liner
Commits
615ea3b7
Commit
615ea3b7
authored
May 29, 2019
by
AdminXVII
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move the generic typing from the Completer type to the on_event method
parent
367de8bc
Pipeline
#4333
passed with stage
in 2 minutes and 2 seconds
Changes
8
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
21 additions
and
25 deletions
+21
-25
examples/comments.rs
examples/comments.rs
+3
-3
examples/nocomments.rs
examples/nocomments.rs
+3
-3
src/complete.rs
src/complete.rs
+4
-4
src/context.rs
src/context.rs
+6
-10
src/editor.rs
src/editor.rs
+1
-1
src/keymap/emacs.rs
src/keymap/emacs.rs
+1
-1
src/keymap/mod.rs
src/keymap/mod.rs
+2
-2
src/keymap/vi.rs
src/keymap/vi.rs
+1
-1
No files found.
examples/comments.rs
View file @
615ea3b7
...
...
@@ -21,16 +21,16 @@ struct CommentCompleter {
inner
:
Option
<
FilenameCompleter
>
,
}
impl
<
W
:
io
::
Write
>
Completer
<
W
>
for
CommentCompleter
{
impl
Completer
for
CommentCompleter
{
fn
completions
(
&
mut
self
,
start
:
&
str
)
->
Vec
<
String
>
{
if
let
Some
(
inner
)
=
&
mut
self
.inner
{
Completer
::
<
W
>
::
completions
(
inner
,
start
)
inner
.completions
(
start
)
}
else
{
Vec
::
new
()
}
}
fn
on_event
(
&
mut
self
,
event
:
Event
<
W
>
)
{
fn
on_event
<
W
:
std
::
io
::
Write
>
(
&
mut
self
,
event
:
Event
<
W
>
)
{
if
let
EventKind
::
BeforeComplete
=
event
.kind
{
let
(
_
,
pos
)
=
event
.editor
.get_words_and_cursor_position
();
...
...
examples/nocomments.rs
View file @
615ea3b7
...
...
@@ -20,16 +20,16 @@ struct NoCommentCompleter {
inner
:
Option
<
FilenameCompleter
>
,
}
impl
<
W
:
io
::
Write
>
Completer
<
W
>
for
NoCommentCompleter
{
impl
Completer
for
NoCommentCompleter
{
fn
completions
(
&
mut
self
,
start
:
&
str
)
->
Vec
<
String
>
{
if
let
Some
(
inner
)
=
&
mut
self
.inner
{
Completer
::
<
W
>
::
completions
(
inner
,
start
)
inner
.completions
(
start
)
}
else
{
Vec
::
new
()
}
}
fn
on_event
(
&
mut
self
,
event
:
Event
<
W
>
)
{
fn
on_event
<
W
:
std
::
io
::
Write
>
(
&
mut
self
,
event
:
Event
<
W
>
)
{
if
let
EventKind
::
BeforeComplete
=
event
.kind
{
let
(
_
,
pos
)
=
event
.editor
.get_words_and_cursor_position
();
...
...
src/complete.rs
View file @
615ea3b7
...
...
@@ -2,9 +2,9 @@ use super::event::Event;
use
std
::
io
::
Write
;
use
std
::
path
::
PathBuf
;
pub
trait
Completer
<
W
:
Write
>
{
pub
trait
Completer
{
fn
completions
(
&
mut
self
,
start
:
&
str
)
->
Vec
<
String
>
;
fn
on_event
(
&
mut
self
,
_
event
:
Event
<
W
>
)
{}
fn
on_event
<
W
:
Write
>
(
&
mut
self
,
_
event
:
Event
<
W
>
)
{}
}
pub
struct
BasicCompleter
{
...
...
@@ -19,7 +19,7 @@ impl BasicCompleter {
}
}
impl
<
T
:
Write
>
Completer
<
T
>
for
BasicCompleter
{
impl
Completer
for
BasicCompleter
{
fn
completions
(
&
mut
self
,
start
:
&
str
)
->
Vec
<
String
>
{
self
.prefixes
.iter
()
...
...
@@ -41,7 +41,7 @@ impl FilenameCompleter {
}
}
impl
<
T
:
Write
>
Completer
<
T
>
for
FilenameCompleter
{
impl
Completer
for
FilenameCompleter
{
fn
completions
(
&
mut
self
,
mut
start
:
&
str
)
->
Vec
<
String
>
{
// XXX: this function is really bad, TODO rewrite
...
...
src/context.rs
View file @
615ea3b7
use
std
::
io
::{
self
,
stdin
,
stdout
,
Stdout
,
Write
};
use
std
::
io
::{
self
,
stdin
,
stdout
,
Write
};
use
termion
::
input
::
TermRead
;
use
termion
::
raw
::
{
IntoRawMode
,
RawTerminal
}
;
use
termion
::
raw
::
IntoRawMode
;
use
super
::
*
;
use
keymap
;
...
...
@@ -65,7 +65,7 @@ impl Context {
/// The output is stdout.
/// The returned line has the newline removed.
/// Before returning, will revert all changes to the history buffers.
pub
fn
read_line
<
P
:
Into
<
String
>
,
C
:
Completer
<
RawTerminal
<
Stdout
>>
>
(
pub
fn
read_line
<
P
:
Into
<
String
>
,
C
:
Completer
>
(
&
mut
self
,
prompt
:
P
,
f
:
Option
<
ColorClosure
>
,
...
...
@@ -81,7 +81,7 @@ impl Context {
///
/// struct EmptyCompleter;
///
/// impl
<W: std::io::Write> Completer<W>
for EmptyCompleter {
/// impl
Completer
for EmptyCompleter {
/// fn completions(&mut self, _start: &str) -> Vec<String> {
/// Vec::new()
/// }
...
...
@@ -94,11 +94,7 @@ impl Context {
/// Some(Box::new(|s| String::from(s))),
/// "some initial buffer");
/// ```
pub
fn
read_line_with_init_buffer
<
P
:
Into
<
String
>
,
B
:
Into
<
Buffer
>
,
C
:
Completer
<
RawTerminal
<
Stdout
>>
,
>
(
pub
fn
read_line_with_init_buffer
<
P
:
Into
<
String
>
,
B
:
Into
<
Buffer
>
,
C
:
Completer
>
(
&
mut
self
,
prompt
:
P
,
handler
:
&
mut
C
,
...
...
@@ -118,7 +114,7 @@ impl Context {
res
}
fn
handle_keys
<
'a
,
W
:
Write
,
M
:
KeyMap
,
C
:
Completer
<
W
>
>
(
fn
handle_keys
<
'a
,
W
:
Write
,
M
:
KeyMap
,
C
:
Completer
>
(
mut
keymap
:
M
,
mut
ed
:
Editor
<
'a
,
W
>
,
handler
:
&
mut
C
,
...
...
src/editor.rs
View file @
615ea3b7
...
...
@@ -427,7 +427,7 @@ impl<'a, W: Write> Editor<'a, W> {
self
.show_completions_hint
=
None
;
}
pub
fn
complete
<
T
:
Completer
<
W
>
>
(
&
mut
self
,
handler
:
&
mut
T
)
->
io
::
Result
<
()
>
{
pub
fn
complete
<
T
:
Completer
>
(
&
mut
self
,
handler
:
&
mut
T
)
->
io
::
Result
<
()
>
{
handler
.on_event
(
Event
::
new
(
self
,
EventKind
::
BeforeComplete
));
if
let
Some
((
completions
,
i
))
=
self
.show_completions_hint
.take
()
{
...
...
src/keymap/emacs.rs
View file @
615ea3b7
...
...
@@ -197,7 +197,7 @@ mod tests {
struct
EmptyCompleter
;
impl
<
W
:
Write
>
Completer
<
W
>
for
EmptyCompleter
{
impl
Completer
for
EmptyCompleter
{
fn
completions
(
&
mut
self
,
_
start
:
&
str
)
->
Vec
<
String
>
{
Vec
::
default
()
}
...
...
src/keymap/mod.rs
View file @
615ea3b7
...
...
@@ -13,7 +13,7 @@ pub trait KeyMap: Default {
fn
init
<
'a
,
W
:
Write
>
(
&
mut
self
,
_
editor
:
&
mut
Editor
<
'a
,
W
>
)
{}
fn
handle_key
<
'a
,
W
:
Write
,
C
:
Completer
<
W
>
>
(
fn
handle_key
<
'a
,
W
:
Write
,
C
:
Completer
>
(
&
mut
self
,
mut
key
:
Key
,
editor
:
&
mut
Editor
<
'a
,
W
>
,
...
...
@@ -101,7 +101,7 @@ mod tests {
struct
EmptyCompleter
;
impl
<
W
:
Write
>
Completer
<
W
>
for
EmptyCompleter
{
impl
Completer
for
EmptyCompleter
{
fn
completions
(
&
mut
self
,
_
start
:
&
str
)
->
Vec
<
String
>
{
Vec
::
default
()
}
...
...
src/keymap/vi.rs
View file @
615ea3b7
...
...
@@ -1090,7 +1090,7 @@ mod tests {
struct
EmptyCompleter
;
impl
<
W
:
Write
>
Completer
<
W
>
for
EmptyCompleter
{
impl
Completer
for
EmptyCompleter
{
fn
completions
(
&
mut
self
,
_
start
:
&
str
)
->
Vec
<
String
>
{
Vec
::
default
()
}
...
...
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