Class: Rex::Ui::Text::Shell::HistoryManager
- Inherits:
-
Object
- Object
- Rex::Ui::Text::Shell::HistoryManager
- Defined in:
- lib/rex/ui/text/shell/history_manager.rb
Constant Summary collapse
- MAX_HISTORY =
2000
- @@contexts =
[]
- @@write_mutex =
Mutex.new
- @@write_queue =
{}
Class Method Summary collapse
- .context_stack ⇒ Object
- .flush ⇒ Object
- .inspect ⇒ Object
- .pop_context ⇒ Object
- .push_context(history_file: nil, name: nil) ⇒ Object
- .with_context(**kwargs, &block) ⇒ Object
Class Method Details
.context_stack ⇒ Object
21 22 23 |
# File 'lib/rex/ui/text/shell/history_manager.rb', line 21 def self.context_stack @@contexts end |
.flush ⇒ Object
55 56 57 |
# File 'lib/rex/ui/text/shell/history_manager.rb', line 55 def self.flush sleep 0.1 until @@write_queue.empty? end |
.inspect ⇒ Object
17 18 19 |
# File 'lib/rex/ui/text/shell/history_manager.rb', line 17 def self.inspect "#<HistoryManager stack size: #{@@contexts.length}>" end |
.pop_context ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/rex/ui/text/shell/history_manager.rb', line 33 def self.pop_context if @@contexts.empty? elog("HistoryManager.pop_context called even when the stack was already empty!") return end old_context = @@contexts.pop switch_context(@@contexts.last, old_context) dlog("HistoryManager.pop_context name: #{old_context&.fetch(:name, nil).inspect}") end |
.push_context(history_file: nil, name: nil) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/rex/ui/text/shell/history_manager.rb', line 25 def self.push_context(history_file: nil, name: nil) dlog("HistoryManager.push_context name: #{name.inspect}") new_context = { history_file: history_file, name: name } switch_context(new_context, @@contexts.last) @@contexts.push(new_context) end |
.with_context(**kwargs, &block) ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/rex/ui/text/shell/history_manager.rb', line 45 def self.with_context(**kwargs, &block) push_context(**kwargs) begin block.call ensure pop_context end end |