<s> """<STR_LIT>""" <EOL> from . import helpers <EOL> from . line import Line <EOL> from . cursor import Cursor <EOL> from . viewer import Viewer <EOL> class State : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , editor = None ) : <EOL> self . cursors = [ Cursor ( ) ] <EOL> self . lines = [ Line ( ) ] <EOL> self . y_scroll = <NUM_LIT:0> <EOL> self . x_scroll = <NUM_LIT:0> <EOL> self . last_find = "<STR_LIT>" <EOL> if editor is not None : <EOL> self . store ( editor ) <EOL> def store ( self , editor ) : <EOL> """<STR_LIT>""" <EOL> self . cursors = [ cursor . tuple ( ) for cursor in editor . cursors ] <EOL> self . lines = [ line . data for line in editor . lines ] <EOL> self . y_scroll = editor . y_scroll <EOL> self . x_scroll = editor . x_scroll <EOL> self . last_find = editor . last_find <EOL> def restore ( self , editor ) : <EOL> """<STR_LIT>""" <EOL> editor . cursors = [ Cursor ( cursor ) for cursor in self . cursors ] <EOL> editor . lines = [ Line ( line ) for line in self . lines ] <EOL> editor . y_scroll = self . y_scroll <EOL> editor . x_scroll = self . x_scroll <EOL> editor . last_find = self . last_find <EOL> class Editor ( Viewer ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , app , window ) : <EOL> """<STR_LIT>""" <EOL> Viewer . __init__ ( self , app , window ) <EOL> self . history = [ State ( ) ] <EOL> self . current_state = <NUM_LIT:0> <EOL> self . last_action = None <EOL> def init ( self ) : <EOL> Viewer . init ( self ) <EOL> operations = { <EOL> "<STR_LIT>" : self . backspace , <EOL> "<STR_LIT>" : self . delete , <EOL> "<STR_LIT>" : self . insert , <EOL> "<STR_LIT>" : self . enter , <EOL> "<STR_LIT>" : self . tab , <EOL> "<STR_LIT>" : self . untab , <EOL> "<STR_LIT>" : self . escape , <EOL> "<STR_LIT>" : self . new_cursor_up , <EOL> "<STR_LIT>" : self . new_cursor_down , <EOL> "<STR_LIT>" : self . new_cursor_left , <EOL> "<STR_LIT>" : self . new_cursor_right , <EOL> "<STR_LIT>" : self . page_up , <EOL> "<STR_LIT>" : self . page_down , <EOL> "<STR_LIT>" : self . push_up , <EOL> "<STR_LIT>" : self . push_down , <EOL> "<STR_LIT>" : self . undo , <EOL> "<STR_LIT>" : self . redo , <EOL> "<STR_LIT>" : self . toggle_line_nums , <EOL> "<STR_LIT>" : self . toggle_line_ends , <EOL> "<STR_LIT>" : self . toggle_highlight , <EOL> "<STR_LIT>" : self . copy , <EOL> "<STR_LIT>" : self . cut , <EOL> "<STR_LIT>" : self . duplicate_line , <EOL> } <EOL> for key in operations . keys ( ) : <EOL> self . operations [ key ] = operations [ key ] <EOL> def set_buffer ( self , buffer ) : <EOL> """<STR_LIT>""" <EOL> if self . app . config [ "<STR_LIT>" ] [ "<STR_LIT>" ] : <EOL> self . app . global_buffer = buffer <EOL> else : <EOL> self . buffer = buffer <EOL> def set_data ( self , data ) : <EOL> """<STR_LIT>""" <EOL> Viewer . set_data ( self , data ) <EOL> buffer = self . get_buffer ( ) <EOL> if len ( buffer ) > <NUM_LIT:1> : <EOL> self . store_state ( ) <EOL> else : <EOL> state = State ( ) <EOL> state . store ( self ) <EOL> self . history [ <NUM_LIT:0> ] = state <EOL> def store_action_state ( self , action , state = None ) : <EOL> """<STR_LIT>""" <EOL> if self . last_action != action : <EOL> self . last_action = action <EOL> self . store_state ( state ) <EOL> else : <EOL> if self . current_state < len ( self . history ) - <NUM_LIT:1> : <EOL> self . history [ self . current_state ] . store ( self ) <EOL> def store_state ( self , state = None , action = None ) : <EOL> """<STR_LIT>""" <EOL> if state is None : <EOL> state = State ( ) <EOL> state . store ( self ) <EOL> if len ( self . history ) > <NUM_LIT:1> : <EOL> if self . current_state < len ( self . history ) - <NUM_LIT:1> : <EOL> self . history = self . history [ : self . current_state ] <EOL> self . history . append ( state ) <EOL> self . current_state = len ( self . history ) - <NUM_LIT:1> <EOL> if len ( self . history ) > self . config [ "<STR_LIT>" ] : <EOL> self . history . pop ( <NUM_LIT:0> ) <EOL> def restore_state ( self , index = None ) : <EOL> """<STR_LIT>""" <EOL> if len ( self . history ) <= <NUM_LIT:1> : <EOL> return False <EOL> if index is None : <EOL> index = self . current_state - <NUM_LIT:1> <EOL> if index < <NUM_LIT:0> or index >= len ( self . history ) : <EOL> return False <EOL> state = self . history [ index ] <EOL> state . restore ( self ) <EOL> self . current_state = index <EOL> def handle_input ( self , event ) : <EOL> done = Viewer . handle_input ( self , event ) <EOL> if not done : <EOL> key = event . key_code <EOL> name = event . key_name <EOL> if isinstance ( key , str ) : <EOL> self . type ( key ) <EOL> return True <EOL> elif name and not name . startswith ( "<STR_LIT>" ) : <EOL> self . type ( name ) <EOL> return True <EOL> return False <EOL> def undo ( self ) : <EOL> """<STR_LIT>""" <EOL> self . last_action = "<STR_LIT>" <EOL> self . restore_state ( ) <EOL> def redo ( self ) : <EOL> """<STR_LIT>""" <EOL> self . last_action = "<STR_LIT>" <EOL> if self . current_state == len ( self . history ) - <NUM_LIT:1> : <EOL> return False <EOL> index = self . current_state + <NUM_LIT:1> <EOL> self . restore_state ( index ) <EOL> def new_cursor_up ( self ) : <EOL> """<STR_LIT>""" <EOL> x = self . get_cursor ( ) . x <EOL> cursor = self . get_first_cursor ( ) <EOL> if cursor . y == <NUM_LIT:0> : <EOL> return <EOL> new = Cursor ( x , cursor . y - <NUM_LIT:1> ) <EOL> self . cursors . append ( new ) <EOL> self . move_cursors ( ) <EOL> self . scroll_up ( ) <EOL> def new_cursor_down ( self ) : <EOL> """<STR_LIT>""" <EOL> x = self . get_cursor ( ) . x <EOL> cursor = self . get_last_cursor ( ) <EOL> if cursor . y == len ( self . lines ) - <NUM_LIT:1> : <EOL> return <EOL> new = Cursor ( x , cursor . y + <NUM_LIT:1> ) <EOL> self . cursors . append ( new ) <EOL> self . move_cursors ( ) <EOL> self . scroll_down ( ) <EOL> def new_cursor_left ( self ) : <EOL> """<STR_LIT>""" <EOL> new = [ ] <EOL> for cursor in self . cursors : <EOL> if cursor . x == <NUM_LIT:0> : <EOL> continue <EOL> new . append ( Cursor ( cursor . x - <NUM_LIT:1> , cursor . y ) ) <EOL> for c in new : <EOL> self . cursors . append ( c ) <EOL> self . move_cursors ( ) <EOL> self . scroll_up ( ) <EOL> def new_cursor_right ( self ) : <EOL> """<STR_LIT>""" <EOL> new = [ ] <EOL> for cursor in self . cursors : <EOL> if cursor . x + <NUM_LIT:1> > len ( self . lines [ cursor . y ] ) : <EOL> continue <EOL> new . append ( Cursor ( cursor . x + <NUM_LIT:1> , cursor . y ) ) <EOL> for c in new : <EOL> self . cursors . append ( c ) <EOL> self . move_cursors ( ) <EOL> self . scroll_down ( ) <EOL> def escape ( self ) : <EOL> """<STR_LIT>""" <EOL> self . last_find = "<STR_LIT>" <EOL> self . cursors = [ self . cursors [ <NUM_LIT:0> ] ] <EOL> self . move_cursors ( ) <EOL> self . render ( ) <EOL> def replace_all ( self , what , replacement ) : <EOL> """<STR_LIT>""" <EOL> for line in self . lines : <EOL> data = line . get_data ( ) <EOL> new = data . replace ( what , replacement ) <EOL> line . set_data ( new ) <EOL> self . move_cursors ( ) <EOL> def delete ( self ) : <EOL> """<STR_LIT>""" <EOL> for cursor in self . cursors : <EOL> if len ( self . lines ) - <NUM_LIT:1> < cursor . y : <EOL> break <EOL> line = self . lines [ cursor . y ] <EOL> if len ( self . lines ) > <NUM_LIT:1> and cursor . x == len ( line ) and cursor . y != len ( self . lines ) - <NUM_LIT:1> : <EOL> data = self . lines [ cursor . y ] . get_data ( ) <EOL> self . lines . pop ( cursor . y ) <EOL> self . lines [ cursor . y ] . set_data ( data + self . lines [ cursor . y ] ) <EOL> line_cursors = self . get_cursors_on_line ( cursor . y + <NUM_LIT:1> ) <EOL> for c in line_cursors : <EOL> c . move_right ( len ( data ) ) <EOL> c . move_up ( ) <EOL> self . move_y_cursors ( cursor . y , - <NUM_LIT:1> ) <EOL> else : <EOL> start = line [ : cursor . x ] <EOL> end = line [ cursor . x + <NUM_LIT:1> : ] <EOL> self . lines [ cursor . y ] . set_data ( start + end ) <EOL> self . move_x_cursors ( cursor . y , cursor . x , - <NUM_LIT:1> ) <EOL> self . move_cursors ( ) <EOL> self . store_action_state ( "<STR_LIT>" ) <EOL> def backspace ( self ) : <EOL> """<STR_LIT>""" <EOL> curs = reversed ( sorted ( self . cursors , key = lambda c : ( c [ <NUM_LIT:1> ] , c [ <NUM_LIT:0> ] ) ) ) <EOL> for cursor in curs : <EOL> line_no = cursor . y <EOL> if cursor . x == <NUM_LIT:0> and cursor . y == <NUM_LIT:0> : <EOL> continue <EOL> if cursor . x == <NUM_LIT:0> and cursor . y != <NUM_LIT:0> : <EOL> curr_line = self . lines . pop ( line_no ) <EOL> prev_line = self . lines [ line_no - <NUM_LIT:1> ] <EOL> length = len ( prev_line ) <EOL> new_data = self . lines [ cursor . y - <NUM_LIT:1> ] + curr_line <EOL> self . lines [ cursor . y - <NUM_LIT:1> ] . set_data ( new_data ) <EOL> line_cursors = self . get_cursors_on_line ( line_no ) <EOL> for line_cursor in line_cursors : <EOL> line_cursor . move_up ( ) <EOL> line_cursor . move_right ( length ) <EOL> self . move_y_cursors ( cursor . y , - <NUM_LIT:1> ) <EOL> else : <EOL> curr_line = self . lines [ line_no ] <EOL> del_n_chars = <NUM_LIT:1> <EOL> if self . config [ "<STR_LIT>" ] : <EOL> indent = self . config [ "<STR_LIT>" ] <EOL> if cursor . x >= indent : <EOL> if curr_line [ cursor . x - indent : cursor . x ] == indent * "<STR_LIT:U+0020>" : <EOL> del_n_chars = indent <EOL> start = curr_line [ : cursor . x - del_n_chars ] <EOL> end = curr_line [ cursor . x : ] <EOL> self . lines [ line_no ] . set_data ( start + end ) <EOL> cursor . move_left ( del_n_chars ) <EOL> self . move_x_cursors ( line_no , cursor . x , - <NUM_LIT:1> * del_n_chars ) <EOL> self . move_cursors ( ) <EOL> self . scroll_up ( ) <EOL> self . store_action_state ( "<STR_LIT>" ) <EOL> def enter ( self ) : <EOL> """<STR_LIT>""" <EOL> curs = sorted ( self . cursors , key = lambda c : ( c [ <NUM_LIT:1> ] , c [ <NUM_LIT:0> ] ) ) <EOL> curs = reversed ( curs ) <EOL> for cursor in curs : <EOL> line = self . lines [ cursor . y ] <EOL> start = line [ : cursor . x ] <EOL> end = line [ cursor . x : ] <EOL> self . lines [ cursor . y ] . set_data ( start ) <EOL> wspace = "<STR_LIT>" <EOL> if self . config [ "<STR_LIT>" ] : <EOL> wspace = helpers . whitespace ( self . lines [ cursor . y ] ) * "<STR_LIT:U+0020>" <EOL> self . lines . insert ( cursor . y + <NUM_LIT:1> , Line ( wspace + end ) ) <EOL> self . move_y_cursors ( cursor . y , <NUM_LIT:1> ) <EOL> cursor . set_x ( len ( wspace ) ) <EOL> cursor . move_down ( ) <EOL> self . move_cursors ( ) <EOL> self . scroll_down ( ) <EOL> self . store_action_state ( "<STR_LIT>" ) <EOL> def insert ( self ) : <EOL> """<STR_LIT>""" <EOL> cur = self . get_cursor ( ) <EOL> buffer = list ( self . get_buffer ( ) ) <EOL> if len ( self . cursors ) > <NUM_LIT:1> or len ( buffer ) == <NUM_LIT:1> : <EOL> while len ( buffer ) < len ( self . cursors ) : <EOL> buffer . extend ( buffer ) <EOL> curs = sorted ( self . cursors , key = lambda c : ( c [ <NUM_LIT:1> ] , c [ <NUM_LIT:0> ] ) ) <EOL> for cursor in curs : <EOL> line = self . lines [ cursor . y ] <EOL> buf = buffer [ <NUM_LIT:0> ] <EOL> line = line [ : cursor . x ] + buf + line [ cursor . x : ] <EOL> self . lines [ cursor . y ] . set_data ( line ) <EOL> buffer . pop ( <NUM_LIT:0> ) <EOL> self . move_x_cursors ( cursor . y , cursor . x - <NUM_LIT:1> , len ( buf ) ) <EOL> else : <EOL> for buf in buffer : <EOL> y = cur [ <NUM_LIT:1> ] <EOL> if y < <NUM_LIT:0> : <EOL> y = <NUM_LIT:0> <EOL> self . lines . insert ( y , Line ( buf ) ) <EOL> self . move_y_cursors ( cur [ <NUM_LIT:1> ] - <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> self . move_cursors ( ) <EOL> self . scroll_down ( ) <EOL> self . store_action_state ( "<STR_LIT>" ) <EOL> def insert_lines_at ( self , lines , at ) : <EOL> rev_lines = reversed ( lines ) <EOL> for line in rev_lines : <EOL> self . lines . insert ( at , Line ( line ) ) <EOL> self . move_y_cursors ( at , len ( lines ) ) <EOL> def push_up ( self ) : <EOL> """<STR_LIT>""" <EOL> used_y = [ ] <EOL> curs = sorted ( self . cursors , key = lambda c : ( c [ <NUM_LIT:1> ] , c [ <NUM_LIT:0> ] ) ) <EOL> for cursor in curs : <EOL> if cursor . y in used_y : <EOL> continue <EOL> used_y . append ( cursor . y ) <EOL> if cursor . y == <NUM_LIT:0> : <EOL> break <EOL> old = self . lines [ cursor . y - <NUM_LIT:1> ] <EOL> self . lines [ cursor . y - <NUM_LIT:1> ] = self . lines [ cursor . y ] <EOL> self . lines [ cursor . y ] = old <EOL> self . move_cursors ( ( <NUM_LIT:0> , - <NUM_LIT:1> ) ) <EOL> self . scroll_up ( ) <EOL> self . store_action_state ( "<STR_LIT>" ) <EOL> def push_down ( self ) : <EOL> """<STR_LIT>""" <EOL> used_y = [ ] <EOL> curs = reversed ( sorted ( self . cursors , key = lambda c : ( c [ <NUM_LIT:1> ] , c [ <NUM_LIT:0> ] ) ) ) <EOL> for cursor in curs : <EOL> if cursor . y in used_y : <EOL> continue <EOL> if cursor . y >= len ( self . lines ) - <NUM_LIT:1> : <EOL> break <EOL> used_y . append ( cursor . y ) <EOL> old = self . lines [ cursor . y + <NUM_LIT:1> ] <EOL> self . lines [ cursor . y + <NUM_LIT:1> ] = self . lines [ cursor . y ] <EOL> self . lines [ cursor . y ] = old <EOL> self . move_cursors ( ( <NUM_LIT:0> , <NUM_LIT:1> ) ) <EOL> self . scroll_down ( ) <EOL> self . store_action_state ( "<STR_LIT>" ) <EOL> def tab ( self ) : <EOL> """<STR_LIT>""" <EOL> self . store_action_state ( "<STR_LIT>" ) <EOL> self . type ( "<STR_LIT:U+0020>" * self . config [ "<STR_LIT>" ] ) <EOL> def untab ( self ) : <EOL> """<STR_LIT>""" <EOL> linenums = [ ] <EOL> tab = "<STR_LIT:U+0020>" * self . config [ "<STR_LIT>" ] <EOL> for cursor in self . cursors : <EOL> line = self . lines [ cursor . y ] <EOL> if cursor . y in linenums : <EOL> cursor . x = helpers . whitespace ( line ) <EOL> continue <EOL> elif line [ : self . config [ "<STR_LIT>" ] ] == tab : <EOL> line = Line ( line [ self . config [ "<STR_LIT>" ] : ] ) <EOL> self . lines [ cursor . y ] = line <EOL> cursor . x = helpers . whitespace ( line ) <EOL> linenums . append ( cursor . y ) <EOL> self . store_action_state ( "<STR_LIT>" ) <EOL> def copy ( self ) : <EOL> """<STR_LIT>""" <EOL> copy_buffer = [ ] <EOL> line_nums = self . get_lines_with_cursors ( ) <EOL> i = <NUM_LIT:0> <EOL> while i < len ( line_nums ) : <EOL> line = self . lines [ line_nums [ i ] ] <EOL> copy_buffer . append ( line . get_data ( ) ) <EOL> i += <NUM_LIT:1> <EOL> self . set_buffer ( copy_buffer ) <EOL> self . store_action_state ( "<STR_LIT>" ) <EOL> def cut ( self ) : <EOL> """<STR_LIT>""" <EOL> cut_buffer = [ ] <EOL> line_nums = self . get_lines_with_cursors ( ) <EOL> line_nums = line_nums [ : : - <NUM_LIT:1> ] <EOL> i = <NUM_LIT:0> <EOL> while i < len ( line_nums ) : <EOL> if len ( self . lines ) == <NUM_LIT:1> : <EOL> cut_buffer . append ( self . lines [ <NUM_LIT:0> ] ) <EOL> self . lines [ <NUM_LIT:0> ] = Line ( ) <EOL> break <EOL> line_no = line_nums [ i ] <EOL> line = self . lines . pop ( line_no ) <EOL> cut_buffer . append ( line ) <EOL> self . move_y_cursors ( line_no , - <NUM_LIT:1> ) <EOL> i += <NUM_LIT:1> <EOL> self . move_cursors ( ) <EOL> self . set_buffer ( cut_buffer [ : : - <NUM_LIT:1> ] ) <EOL> self . store_action_state ( "<STR_LIT>" ) <EOL> def type ( self , data ) : <EOL> """<STR_LIT>""" <EOL> for cursor in self . cursors : <EOL> self . type_at_cursor ( cursor , data ) <EOL> self . move_cursors ( ) <EOL> self . store_action_state ( "<STR_LIT:type>" ) <EOL> def type_at_cursor ( self , cursor , data ) : <EOL> """<STR_LIT>""" <EOL> line = self . lines [ cursor . y ] <EOL> start = line [ : cursor . x ] <EOL> end = line [ cursor . x : ] <EOL> self . lines [ cursor . y ] . set_data ( start + data + end ) <EOL> self . move_x_cursors ( cursor . y , cursor . x , len ( data ) ) <EOL> cursor . move_right ( len ( data ) ) <EOL> def go_to_pos ( self , line_no , col = <NUM_LIT:0> ) : <EOL> """<STR_LIT>""" <EOL> if line_no < <NUM_LIT:0> : <EOL> line_no = len ( self . lines ) - <NUM_LIT:1> <EOL> else : <EOL> line_no = line_no - <NUM_LIT:1> <EOL> self . store_state ( ) <EOL> cur = self . get_cursor ( ) <EOL> if col is not None : <EOL> cur . x = col <EOL> cur . y = line_no <EOL> if cur . y >= len ( self . lines ) : <EOL> cur . y = len ( self . lines ) - <NUM_LIT:1> <EOL> self . scroll_to_line ( cur . y ) <EOL> self . move_cursors ( ) <EOL> def duplicate_line ( self ) : <EOL> """<STR_LIT>""" <EOL> curs = sorted ( self . cursors , key = lambda c : ( c . y , c . x ) ) <EOL> for cursor in curs : <EOL> line = Line ( self . lines [ cursor . y ] ) <EOL> self . lines . insert ( cursor . y + <NUM_LIT:1> , line ) <EOL> self . move_y_cursors ( cursor . y , <NUM_LIT:1> ) <EOL> self . move_cursors ( ) <EOL> self . store_action_state ( "<STR_LIT>" ) <EOL> class PromptEditor ( Editor ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , app , window ) : <EOL> Editor . __init__ ( self , app , window ) <EOL> self . ready = <NUM_LIT:0> <EOL> self . canceled = <NUM_LIT:0> <EOL> self . input_func = lambda : False <EOL> self . caption = "<STR_LIT>" <EOL> def init ( self ) : <EOL> Editor . init ( self ) <EOL> del self . operations [ "<STR_LIT>" ] <EOL> def set_config ( self , config ) : <EOL> """<STR_LIT>""" <EOL> config [ "<STR_LIT>" ] = False <EOL> Editor . set_config ( self , config ) <EOL> def set_input_source ( self , input_func ) : <EOL> self . input_func = input_func <EOL> def on_ready ( self ) : <EOL> """<STR_LIT>""" <EOL> self . ready = <NUM_LIT:1> <EOL> return <EOL> def on_cancel ( self ) : <EOL> """<STR_LIT>""" <EOL> self . set_data ( "<STR_LIT>" ) <EOL> self . ready = <NUM_LIT:1> <EOL> self . canceled = <NUM_LIT:1> <EOL> return <EOL> def line_offset ( self ) : <EOL> """<STR_LIT>""" <EOL> return len ( self . caption ) + <NUM_LIT:1> <EOL> def render_line_contents ( self , line , pos , x_offset , max_len ) : <EOL> """<STR_LIT>""" <EOL> x_offset = self . line_offset ( ) <EOL> self . window . addstr ( pos [ <NUM_LIT:1> ] , <NUM_LIT:0> , self . caption ) <EOL> self . render_line_normal ( line , pos , x_offset , max_len ) <EOL> def handle_input ( self , event ) : <EOL> """<STR_LIT>""" <EOL> name = event . key_name <EOL> if name in [ "<STR_LIT>" , "<STR_LIT>" ] : <EOL> self . on_cancel ( ) <EOL> return False <EOL> if name == "<STR_LIT>" : <EOL> self . on_ready ( ) <EOL> return False <EOL> return Editor . handle_input ( self , event ) <EOL> def get_input ( self , caption = "<STR_LIT>" , initial = "<STR_LIT>" ) : <EOL> """<STR_LIT>""" <EOL> self . caption = caption <EOL> self . set_data ( initial ) <EOL> self . end ( ) <EOL> self . refresh ( ) <EOL> success = self . input_loop ( ) <EOL> if success : <EOL> return self . get_data ( ) <EOL> return False <EOL> def input_loop ( self ) : <EOL> while not self . ready : <EOL> event = self . input_func ( True ) <EOL> if event : <EOL> self . handle_input ( event ) <EOL> self . refresh ( ) <EOL> if not self . canceled : <EOL> return True <EOL> class PromptEditorBool ( PromptEditor ) : <EOL> """<STR_LIT>""" <EOL> def set_value ( self , val ) : <EOL> self . value = val <EOL> def handle_input ( self , event ) : <EOL> """<STR_LIT>""" <EOL> name = event . key_name <EOL> if name . lower ( ) == "<STR_LIT:y>" : <EOL> self . set_value ( True ) <EOL> self . on_ready ( ) <EOL> return False <EOL> if name . lower ( ) == "<STR_LIT:n>" : <EOL> self . set_value ( False ) <EOL> self . on_ready ( ) <EOL> return False <EOL> PromptEditor . handle_input ( self , event ) <EOL> def get_input ( self , caption = "<STR_LIT>" , initial = False ) : <EOL> """<STR_LIT>""" <EOL> indicator = "<STR_LIT>" <EOL> if initial : <EOL> indicator = "<STR_LIT>" <EOL> self . caption = caption + "<STR_LIT:U+0020>" + indicator <EOL> self . set_value ( initial ) <EOL> self . end ( ) <EOL> self . refresh ( ) <EOL> success = self . input_loop ( ) <EOL> if success : <EOL> return self . value <EOL> return False </s>
