Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/lib/rex/ui/text/input.rb
Views: 11655
# -*- coding: binary -*-12module Rex3module Ui4module Text56###7#8# This class acts as a base for all input mediums. It defines9# the interface that will be used by anything that wants to10# interact with a derived class.11#12###13class Input1415require 'rex/text/color'1617include Rex::Text::Color1819def initialize20self.eof = false21@config = {22:readline => true, # true, false23:color => :auto, # true, false, :auto24}25super26end2728#29# Whether or not the input medium supports readline.30#31def supports_readline32return true if not @config3334config[:readline] == true35end3637#38# Stub for tab completion reset39#40def reset_tab_completion41end4243#44# Calls the underlying system read.45#46def sysread(len)47raise NotImplementedError48end4950#51# Gets a line of input52#53def gets54raise NotImplementedError55end5657#58# Has the input medium reached end-of-file?59#60def eof?61return eof62end6364#65# Returns a pollable file descriptor that is associated with this66# input medium.67#68def fd69raise NotImplementedError70end7172#73# Indicates whether or not this input medium is intrinsicly a74# shell provider. This would indicate whether or not it75# already expects to have a prompt.76#77def intrinsic_shell?78false79end8081def update_prompt(new_prompt = '', new_prompt_char = '')82self.prompt = new_prompt + new_prompt_char83end8485attr_reader :config8687def disable_readline88return if not @config89@config[:readline] = false90end9192def enable_readline93return if not @config94@config[:readline] = true95end9697def disable_color98return if not @config99@config[:color] = false100end101102def enable_color103return if not @config104@config[:color] = true105end106107def auto_color108return if not @config109@config[:color] = :auto110end111112def update_prompt(prompt)113substitute_colors(prompt, true)114end115116def reset_color117end118119attr_accessor :eof, :prompt, :prompt_char, :config120121end122123end124end125end126127128