Skip to content
Kward Search API index

Module: Kward::PromptInterface::ProjectBrowser

Included in:
Kward::PromptInterface
Defined in:
lib/kward/prompt_interface/project_browser.rb

Overview

Modal tree browser for project files.

Constant Summary collapse

PROJECT_BROWSER_ROOT =
"".freeze
PROJECT_BROWSER_RESULT_LIMIT =
200
PROJECT_BROWSER_STATE_VERSION =
1
PROJECT_BROWSER_FILENAME_ICONS =
{
  ".gitignore" => "",
  "Gemfile" => "",
  "Rakefile" => "",
  "README" => "",
  "README.md" => "",
  "package.json" => ""
}.freeze
PROJECT_BROWSER_EXTENSION_ICONS =
{
  "css" => "",
  "html" => "",
  "js" => "",
  "json" => "",
  "md" => "",
  "rb" => "",
  "sh" => "",
  "ts" => "",
  "yaml" => "",
  "yml" => ""
}.freeze
PROJECT_BROWSER_DIRECTORY_ICON =
""
PROJECT_BROWSER_FILE_ICON =
""

Instance Method Summary collapse

Instance Method Details

#open_project_browserObject



38
39
40
41
42
43
44
# File 'lib/kward/prompt_interface/project_browser.rb', line 38

def open_project_browser
  @mutex.synchronize do
    open_project_browser_locked
    render_prompt_locked if @started && @asking
  end
  true
end

#open_project_browser_lockedObject



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/kward/prompt_interface/project_browser.rb', line 46

def open_project_browser_locked
  paths = project_file_paths
  saved_state = saved_project_browser_state
  @project_browser_state = {
    paths: paths,
    expanded: restored_project_browser_expanded_paths(paths, saved_state),
    selection_index: 0,
    search_active: false,
    query: ""
  }
  restore_project_browser_selection(saved_state["selected_path"])
  self.composer_input = ""
  self.composer_cursor = 0
  @pending_keys.clear
  @asking = true
end