1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

readline: move get_prompt_offset back to _linux.c.v (#7714)

This commit is contained in:
Larpon 2020-12-30 17:09:07 +01:00 committed by GitHub
parent 7872b8d911
commit c943c8a16e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 14 deletions

View File

@ -41,17 +41,3 @@ mut:
search_index int
is_tty bool
}
// get_prompt_offset computes the length of the `prompt` `string` argument.
fn get_prompt_offset(prompt string) int {
mut len := 0
for i := 0; i < prompt.len; i++ {
if prompt[i] == `\e` {
for ; i < prompt.len && prompt[i] != `m`; i++ {
}
} else {
len = len + 1
}
}
return prompt.len - len
}

View File

@ -333,6 +333,20 @@ fn calculate_screen_position(x_in int, y_in int, screen_columns int, char_count
return out
}
// get_prompt_offset computes the length of the `prompt` `string` argument.
fn get_prompt_offset(prompt string) int {
mut len := 0
for i := 0; i < prompt.len; i++ {
if prompt[i] == `\e` {
for ; i < prompt.len && prompt[i] != `m`; i++ {
}
} else {
len = len + 1
}
}
return prompt.len - len
}
// refresh_line redraws the current line, including the prompt.
fn (mut r Readline) refresh_line() {
mut end_of_input := [0, 0]