From c943c8a16e9ce7d88da6a3c1b7ec95102f2ac45e Mon Sep 17 00:00:00 2001 From: Larpon Date: Wed, 30 Dec 2020 17:09:07 +0100 Subject: [PATCH] readline: move get_prompt_offset back to _linux.c.v (#7714) --- vlib/readline/readline.v | 14 -------------- vlib/readline/readline_linux.c.v | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/vlib/readline/readline.v b/vlib/readline/readline.v index 80c6387816..e611337e18 100644 --- a/vlib/readline/readline.v +++ b/vlib/readline/readline.v @@ -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 -} diff --git a/vlib/readline/readline_linux.c.v b/vlib/readline/readline_linux.c.v index eecbfc8c7c..b2624a06ca 100644 --- a/vlib/readline/readline_linux.c.v +++ b/vlib/readline/readline_linux.c.v @@ -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]