wip
This commit is contained in:
parent
f2c3b57f38
commit
1a475f98f6
|
@ -17,6 +17,7 @@ module Fingers
|
|||
property selected_hint_format : String
|
||||
property highlight_format : String
|
||||
property selected_highlight_format : String
|
||||
property backdrop_format : String
|
||||
|
||||
FORMAT_PRINTER = TmuxFormatPrinter.new
|
||||
|
||||
|
@ -33,7 +34,8 @@ module Fingers
|
|||
@hint_format = FORMAT_PRINTER.print("fg=yellow,bold"),
|
||||
@selected_hint_format = FORMAT_PRINTER.print("fg=green,bold"),
|
||||
@selected_highlight_format = FORMAT_PRINTER.print("fg=green,nobold,dim"),
|
||||
@highlight_format = FORMAT_PRINTER.print("fg=yellow,nobold,dim")
|
||||
@highlight_format = FORMAT_PRINTER.print("fg=yellow,nobold,dim"),
|
||||
@backdrop_format = FORMAT_PRINTER.print("bg=black,fg=color250")
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -73,7 +73,9 @@ module Fingers
|
|||
|
||||
def process_line(line, ending)
|
||||
result = line.gsub(pattern) { |_m| replace($~) }
|
||||
output.print(result + ending)
|
||||
result = Fingers.config.backdrop_format + result
|
||||
width_diff = result.size - line.size
|
||||
output.print(result.ljust(width + width_diff, ' ') + ending)
|
||||
end
|
||||
|
||||
def pattern : Regex
|
||||
|
|
|
@ -8,24 +8,27 @@ module Fingers
|
|||
highlight_format : String = Fingers.config.highlight_format,
|
||||
selected_hint_format : String = Fingers.config.selected_hint_format,
|
||||
selected_highlight_format : String = Fingers.config.selected_highlight_format,
|
||||
backdrop_format : String = Fingers.config.backdrop_format,
|
||||
hint_position : String = Fingers.config.hint_position,
|
||||
# TODO #perf remove this shell call
|
||||
reset_sequence : String = `tput sgr0`.chomp
|
||||
)
|
||||
@hint_format = hint_format
|
||||
@highlight_format = highlight_format
|
||||
@selected_hint_format = selected_hint_format
|
||||
@selected_highlight_format = selected_highlight_format
|
||||
@backdrop_format = backdrop_format
|
||||
@hint_position = hint_position
|
||||
@reset_sequence = reset_sequence
|
||||
end
|
||||
|
||||
def format(hint : String, highlight : String, selected : Bool, offset : Tuple(Int32, Int32) | Nil)
|
||||
before_offset(offset, highlight) +
|
||||
reset_sequence + before_offset(offset, highlight) +
|
||||
format_offset(selected, hint, within_offset(offset, highlight)) +
|
||||
after_offset(offset, highlight)
|
||||
after_offset(offset, highlight) + backdrop_format
|
||||
end
|
||||
|
||||
private getter :hint_format, :highlight_format, :selected_hint_format, :selected_highlight_format, :hint_position, :reset_sequence
|
||||
private getter :hint_format, :highlight_format, :selected_hint_format, :selected_highlight_format, :hint_position, :reset_sequence, :backdrop_format
|
||||
|
||||
private def before_offset(offset, highlight)
|
||||
return "" if offset.nil?
|
||||
|
|
Loading…
Reference in New Issue