def draw_command_bar(self, status=EDITING): # draw separator echo_at_cell(self.command_bar_separator_cursor, DOUBLE_HORIZONTAL * self.term.width) # write status bar self.set_status(status) if status == WAITING_FOR_CMD: self.input_bar_text = self.term.bold_white(u"cmd: ") self.input_bar_cursor = csr.home(self.input_bar_cursor) echo_at_cell(self.input_bar_cursor, self.input_bar_text) echo_at_cell(self.status_bar_cursor, self.status_bar_text + self.status_descriptor) echo_at_cell(self.input_bar_cursor, self.input_bar_text)
def set_status(self, status): echo_at_cell(csr.home(self.status_bar_cursor, logger=self.logger), self.term.clear_eol) if status == EDITING: fscreen = self.focus_screen min_row, min_col = fscreen.origin max_row, max_col = fscreen.origin + fscreen.display_size - 1 offset_row, offset_col = fscreen.offset fcursor = self.focus_cursor self.status_descriptor = "{} | ({}:{}:{}, {}:{}:{}) + ({}, {})".format( self.focus_screen_index, min_row, fcursor.r, max_row, min_col, fcursor.c, max_col, offset_row, offset_col, ) elif status == WAITING_FOR_CMD: self.status_descriptor = "~"
def read_command(self): self.reading_command = True self.draw_command_bar(status=WAITING_FOR_CMD) if self.logger != None: self.logger.add_tag("read_command") self.draw_command_bar(status=WAITING_FOR_CMD) self.input_bar_cursor = csr.right_of(self.input_bar_cursor, 5) inp, exit_dict = readline(self.input_bar_cursor, max_input=self.term.width - 5) if exit_dict["enter"]: self.command = [substr for substr in inp.split(" ") if substr not in ["", None]] self.set_status(EDITING) self.input_bar_text = u"" self.input_bar_cursor = csr.home(self.input_bar_cursor) echo_at_cell(self.input_bar_cursor, self.term.clear_eol) self.reading_command = False if self.logger != None: self.logger.remove_tag()