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
4ce38339
Commit
4ce38339
authored
Apr 18, 2019
by
AdminXVII
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
On prompt, exit to normal buffer and reenable cursor keys
parent
367de8bc
Pipeline
#4335
passed with stage
in 1 minute and 57 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
23 deletions
+11
-23
src/editor.rs
src/editor.rs
+8
-17
src/util.rs
src/util.rs
+3
-6
No files found.
src/editor.rs
View file @
4ce38339
...
...
@@ -922,16 +922,12 @@ impl<'a, W: Write> Editor<'a, W> {
};
// Width of the current buffer lines (including autosuggestion) from the start to the cursor
let
buf_widths_to_cursor
=
match
self
.autosuggestion
{
Some
(
ref
suggestion
)
=>
Some
(
ref
suggestion
)
if
self
.cursor
<
suggestion
.num_chars
()
=>
// Cursor might overrun autosuggestion with history search.
{
if
self
.cursor
<
suggestion
.num_chars
()
{
suggestion
.range_width
(
0
,
self
.cursor
)
}
else
{
buf
.range_width
(
0
,
self
.cursor
)
}
suggestion
.range_width
(
0
,
self
.cursor
)
}
None
=>
buf
.range_width
(
0
,
self
.cursor
),
_
=>
buf
.range_width
(
0
,
self
.cursor
),
};
// Total number of terminal spaces taken up by prompt and buffer
...
...
@@ -944,6 +940,8 @@ impl<'a, W: Write> Editor<'a, W> {
let
new_num_lines
=
(
new_total_width
+
terminal_width
)
/
terminal_width
;
output_buf
.append
(
b
"
\x1B
[?1049l
\x1B
[?1000l
\x1B
[?1l"
);
// Move the term cursor to the same line as the prompt.
if
self
.term_cursor_line
>
1
{
output_buf
.append
(
...
...
@@ -955,9 +953,6 @@ impl<'a, W: Write> Editor<'a, W> {
if
!
self
.no_newline
{
output_buf
.append
(
"⏎"
.as_bytes
());
for
_
in
0
..
(
terminal_width
-
1
)
{
output_buf
.push
(
b
' '
);
}
}
output_buf
.push
(
b
'\r'
);
...
...
@@ -986,13 +981,9 @@ impl<'a, W: Write> Editor<'a, W> {
// We get the number of bytes in the buffer (but NOT the autosuggestion).
// Then, we loop and subtract from that number until it's 0, in which case we are printing
// the autosuggestion from here on (in a different color).
let
lines
=
if
show_autosuggest
{
match
self
.autosuggestion
{
Some
(
ref
suggestion
)
=>
suggestion
.lines
(),
None
=>
buf
.lines
(),
}
}
else
{
buf
.lines
()
let
lines
=
match
self
.autosuggestion
{
Some
(
ref
suggestion
)
if
show_autosuggest
=>
suggestion
.lines
(),
_
=>
buf
.lines
(),
};
let
mut
buf_num_remaining_bytes
=
buf
.num_bytes
();
...
...
src/util.rs
View file @
4ce38339
use
std
::{
borrow
::
Cow
,
io
};
use
std
::{
borrow
::
Cow
,
io
};
use
unicode_width
::
*
;
pub
fn
last_prompt_line_width
<
S
:
AsRef
<
str
>>
(
s
:
S
)
->
usize
{
...
...
@@ -70,13 +67,13 @@ pub fn remove_codes(input: &str) -> Cow<str> {
_
=>
s
=
AnsiState
::
Norm
,
},
AnsiState
::
Csi
=>
match
c
{
'A'
...
'Z'
|
'a'
...
'z'
=>
s
=
AnsiState
::
Norm
,
'A'
...
'Z'
|
'a'
...
'z'
=>
s
=
AnsiState
::
Norm
,
_
=>
(),
},
AnsiState
::
Osc
=>
match
c
{
'\x07'
=>
s
=
AnsiState
::
Norm
,
_
=>
(),
}
}
,
}
}
...
...
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