[ruby/reline] Separate prompt and input line in rendering

(https://github.com/ruby/reline/pull/652)

* Separate prompt and input line in rendering

Often, only one of prompt and input changes.
Split prompt+input_line to a separate rendering item will improve differential rendering performance.

* Rename method wrapped_prompt_lines to more descriptive name

16d82f1f23
This commit is contained in:
tomoya ishida 2024-04-23 23:45:18 +09:00 committed by git
parent f7d1699f67
commit 53a67efc9a
2 changed files with 19 additions and 12 deletions

View file

@ -128,10 +128,10 @@ class Reline::Unicode
end
end
def self.split_by_width(str, max_width, encoding = str.encoding)
def self.split_by_width(str, max_width, encoding = str.encoding, offset: 0)
lines = [String.new(encoding: encoding)]
height = 1
width = 0
width = offset
rest = str.encode(Encoding::UTF_8)
in_zero_width = false
seq = String.new(encoding: encoding)