class CryPrompt::AutoComplete

Defined in:

autocomplete.cr

Constant Summary

ANSI_ESCAPE = /\e\[[0-?]*[ -\/]*[@-~]/
TIOCGWINSZ = 21523_u32

Constructors

Instance Method Summary

Constructor Detail

def self.new(completion : JSON::Any | YAML::Any | Nil) #

[View source]
def self.new #

[View source]

Instance Method Detail

def box_color : Colorize::Color #

[View source]
def box_color=(box_color : Colorize::Color) #

[View source]
def box_text_background_color : Colorize::Color #

[View source]
def box_text_background_color=(box_text_background_color : Colorize::Color) #

[View source]
def box_text_foreground_color : Colorize::Color #

[View source]
def box_text_foreground_color=(box_text_foreground_color : Colorize::Color) #

[View source]
def case_sensitive : Bool #

[View source]
def case_sensitive=(case_sensitive : Bool) #

[View source]
def chose_from_render #

[View source]
def clear_line_below(current_line_index) #

dont use this just use print Keys::ClearScreenBelow


[View source]
def clear_x_below(number_of_lines, current_line_index) #

[View source]
def completion : JSON::Any | YAML::Any | Nil #

load a yaml or json hash to parse from you still need to call update_suggestions to parse it


[View source]
def completion=(completion : JSON::Any | YAML::Any | Nil) #

load a yaml or json hash to parse from you still need to call update_suggestions to parse it


[View source]
def completion_suffix(candidate : String, prefix : String) : String #

Returns only the untyped suffix of a matching candidate.


[View source]
def current_word(line : String) : String #

The token currently being completed. An empty string means the cursor follows whitespace and the next command word is being selected.


[View source]
def display_width(value : String) : Int32 #

Approximate wcwidth for the ranges commonly encountered in prompts.


[View source]
def get_terminal_size #

[View source]
def print_suggestions(opts : Array(String), word : String = "", current_line_index : Int32 = 0) #

bash style single line tab suggest


[View source]
def render(opts : Array(CryPromptTrie), current_line_index : Int32, word : String, tabc : Int32 = -1, prompt_size : Int32 = 2, line_size : Int32 = 0, io : IO = STDOUT, terminal_width : Int32 | Nil = nil, more : Bool | Nil = nil) : String #

Renders at most five suggestions below the current word. Widths are terminal-cell widths, and oversized values are truncated instead of suppressing the entire menu.


[View source]
def render_box(opts : Array(String), selected_index : Int32 = -1, max_suggested : Int32 = 5, min_width_size : Int32 = 4) #

NOT WORKING (probably due to scos/rc) draws the box with the suggestions in it. selected_index is the index in opts that will be selected to be highlighted max_size is the width of the box max_suggested is how many items will be suggested at the maximum


[View source]
def sanitize(value : String) : String #

Removes control sequences that could break the menu's rows.


[View source]
def suggestion_nodes(line : String, trie = @sugtrie) : Array(CryPromptTrie) #

returns an array of words from the sugtrie that fall in line with the given line


[View source]
def suggestions(line : String, trie = @sugtrie) : Array(String) #

returns an array of words from the sugtrie that fall in line with the given line


[View source]
def sugtrie : CryPromptTrie #

[View source]
def sugtrie=(sugtrie : CryPromptTrie) #

[View source]
def truncate_to_width(value : String, maximum : Int32) : String #

[View source]
def update_suggestions(completion : JSON::Any | YAML::Any | Nil = @completion, trie : CryPromptTrie = @sugtrie) #

recursive function to generate the suggestion trie from a json or yaml structure


[View source]