Class: Fatty::ISearchSession
- Defined in:
- lib/fatty/session/isearch_session.rb
Constant Summary collapse
- DEFAULT_ISEARCH_HISTORY_FILE =
File.("~/.fatty_search_history")
- DEFAULT_ISEARCH_HISTORY_MAX =
200
Instance Attribute Summary collapse
-
#direction ⇒ Object
readonly
Returns the value of attribute direction.
-
#field ⇒ Object
readonly
Returns the value of attribute field.
Attributes inherited from Session
#counter, #keymap, #terminal, #views
Instance Method Summary collapse
- #id ⇒ Object
-
#initialize(direction: :forward, last_pattern: nil, history: nil) ⇒ ISearchSession
constructor
A new instance of ISearchSession.
-
#keymap_contexts ⇒ Object
Framework and Session Hooks.
- #view(screen:, renderer:) ⇒ Object
Methods inherited from Session
#add_view, #close, #handle_resize, #init, #inspect, #persist!, #resolve_action, #tick, #update
Methods included from Actionable
Constructor Details
#initialize(direction: :forward, last_pattern: nil, history: nil) ⇒ ISearchSession
Returns a new instance of ISearchSession.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/fatty/session/isearch_session.rb', line 14 def initialize(direction: :forward, last_pattern: nil, history: nil) super(keymap: Keymaps.emacs, views: []) @direction = direction.to_sym @failed = false @last_text = nil @last_pattern = last_pattern.to_s @field = Fatty::InputField.new( prompt: Prompt.new { isearch_prompt }, history: history, history_kind: :search_string, # ? history_ctx: -> { { session: "pager_isearch" } }, ) end |
Instance Attribute Details
#direction ⇒ Object (readonly)
Returns the value of attribute direction.
7 8 9 |
# File 'lib/fatty/session/isearch_session.rb', line 7 def direction @direction end |
#field ⇒ Object (readonly)
Returns the value of attribute field.
7 8 9 |
# File 'lib/fatty/session/isearch_session.rb', line 7 def field @field end |
Instance Method Details
#id ⇒ Object
9 |
# File 'lib/fatty/session/isearch_session.rb', line 9 def id = :isearch |
#keymap_contexts ⇒ Object
Framework and Session Hooks
34 35 36 |
# File 'lib/fatty/session/isearch_session.rb', line 34 def keymap_contexts [:isearch, :text, :terminal] end |
#view(screen:, renderer:) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/fatty/session/isearch_session.rb', line 38 def view(screen:, renderer:) row = screen.output_rect.rows - 1 ::Curses.curs_set(1) renderer.render_pager_field(@field, row: row, role: :search_input) renderer.restore_output_cursor(@field, row: row) end |