Class: CapistranoMulticonfigParallel::Cursor

Inherits:
Object
  • Object
show all
Extended by:
ApplicationHelper
Defined in:
lib/capistrano_multiconfig_parallel/classes/cursor.rb

Overview

class used to fetch cursor position before displaying terminal table

Class Method Summary collapse

Methods included from ApplicationHelper

action_confirmed?, check_hash_set, check_numeric, fetch_parsed_string, fetch_remaining_arguments, find_loaded_gem, find_remaining_args, get_question_details, msg_for_stdin?, msg_for_task?, multi_fetch_argv, parse_task_string, percent_of, regex_last_match, setup_command_line_standard, strip_characters_from_string, value_is_array?, verify_array_of_strings, verify_empty_options, warn_array_without_strings, wrap_string

Methods included from CoreHelper

app_debug_enabled?, ask_confirm, ask_stdout_confirmation, check_terminal_tty, debug_websocket?, error_filtered?, execute_with_rescue, find_worker_log, force_confirmation, format_error, log_error, log_output_error, log_to_file, print_to_log_file, rescue_error, rescue_interrupt, setup_filename_logger, setup_logger_formatter, show_warning, websocket_config, websocket_server_config

Methods included from InternalHelper

check_file, config_file, create_log_file, custom_commands, default_internal_config, default_internal_configuration_params, detect_root, enable_main_log_file, fail_capfile_not_found, fetch_default_internal_config, find_config_type, find_env_multi_cap_root, find_file_in_directory, internal_config_directory, internal_config_file, log_directory, main_log_file, multi_level_prop, pathname_is_root?, pwd_directory, pwd_parent_dir, root, setup_default_configuration_types, sliced_default_config, try_detect_capfile

Class Method Details

.display_on_screen(string, options = {}) ⇒ Object



28
29
30
31
32
33
# File 'lib/capistrano_multiconfig_parallel/classes/cursor.rb', line 28

def display_on_screen(string, options = {})
  options = options.is_a?(Hash) ? options.stringify_keys : {}
  position = options.fetch('position', nil)
  clear_scren =  options.fetch('clear_screen', false)
  handle_string_display(position, clear_scren, string)
end

.fetch_positionObject



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/capistrano_multiconfig_parallel/classes/cursor.rb', line 14

def fetch_position
  res = ''
  $stdin.raw do |stdin|
    $stdout << "\e[6n"
    $stdout.flush
    while (line = stdin.getc) != 'R'
      res << line if line
    end
  end
  position = res.match(/(?<row>\d+);(?<column>\d+)/)
  { row: position[:row].to_i, column: position[:column].to_i }
end

.fetch_terminal_sizeObject



8
9
10
11
12
# File 'lib/capistrano_multiconfig_parallel/classes/cursor.rb', line 8

def fetch_terminal_size
  size = (dynamic_size_stty || dynamic_size_tput || `echo $LINES $COLUMNS`)
  size = strip_characters_from_string(size).split(' ')
  { rows: size[0].to_i, columns: size[1].to_i }
end

.move_to_home!(row = 2, column = 1) ⇒ Object



35
36
37
38
# File 'lib/capistrano_multiconfig_parallel/classes/cursor.rb', line 35

def move_to_home!(row = 2, column = 1)
  position_cursor(row, column)
  erase_from_current_line_to_bottom
end