def show_help_screen(win): view = libcurses.ScreenText(win) win.clear() win.refresh() view.addInfo('[', config.attribute('information_sep')) view.addInfo('q', config.attribute('information_key')) view.addInfo(']', config.attribute('information_sep')) view.addInfo('quit', config.attribute('information_word')) view.addText(open(config.app_dir + '/HELP').read()) view.write() view.loop()
def show_help_screen(win): view = libcurses.ScreenText(win) win.clear() win.refresh() view.addInfo('[', config.attribute('information_sep')) view.addInfo('q', config.attribute('information_key')) view.addInfo(']', config.attribute('information_sep')) view.addInfo('quit', config.attribute('information_word')) view.addText( open(config.app_dir + '/HELP').read() ) view.write() view.loop()
def createDir(self): dirname = self.view.input('New directory: ') if dirname: try: self.makeDir(dirname) self.refresh() except Exception, e: self.refresh() self.view.message(str(e), config.attribute('error_message'))
def execute(self): current_dir = os.getcwd() os.chdir(self.cwd+os.sep) cmd = self.view.input('Command: ') if cmd[0] == '!': cmd = cmd[1:] if cmd: try: os.system(cmd) self.refresh() except OsError, error: self.view.message(str(error), config.attribute('error_message')) else: self.refresh()
def move(self): if self.contents: if not self.selected: self.select(self.view.y) input = self.view.input('Move to: ') if input: try: self.moveSelected(input) self.refresh() except Exception, e: self.refresh() self.view.message(str(e), config.attribute('error_message')) else: self.refresh()
def delete(self): if self.contents: if not self.selected: self.select(self.view.y) input = self.view.input('Remove [y/n]? ') if input.lower() == 'y': try: self.deleteSelected() self.refresh() except Exception, e: self.refresh() self.view.message(str(e), config.attribute('error_message')) else: self.refresh()
def next(self): if self.contents: item_under_cursor = self.contents[self.view.y] actualdir = self.cwd if item_under_cursor.type() == 'd': try: self.cwd = item_under_cursor.dir.rstrip(os.sep)+\ os.sep+item_under_cursor.name self.selected = [] self.setContents() self.showContents() except OSError, error: self.cwd = actualdir self.view.message(str(error), config.attribute('error_message'))
def goto(self): gotodir = self.view.input('Go to: ') if not gotodir: self.refresh() return None if gotodir[0] != os.sep: gotodir = self.cwd + os.sep + gotodir.rstrip(os.sep) if os.access(gotodir, os.F_OK): actualdir = self.cwd try: self.cwd = gotodir.rstrip(os.sep) self.selected = [] self.setContents() self.showContents() except OSError, error: self.cwd = actualdir self.view.message(str(error), config.attribute('error_message'))
def back(self): if self.cwd: actualdir = self.cwd try: self.cwd = os.path.dirname(self.cwd).rstrip(os.sep) self.selected = [] self.setContents() name = os.path.basename(actualdir) if name in self.file_names: i = self.file_names.index(os.path.basename(actualdir)) if i > self.view.max_y-1: self.view.Y = (self.view.max_y-1)/2 else: self.view.Y = i else: i = 0 self.view.Y = 0 self.showContents(i) except OSError, error: self.cwd = actualdir self.view.message(str(error), config.attribute('error_message'))
def key_word(key='', word=''): a = config.attribute('information_key') b = config.attribute('information_sep') c = config.attribute('information_word') return [['[', b], [key, a], [']', b], [word + ' ', c]]
def setAttributes(self): self.attr_input = config.attribute('user_input') self.attr_message = config.attribute('user_message') self.attr_line = config.attribute('cursor_position') self.attr_brktext = config.attribute('breaked_text') self.attr_empty = config.attribute('empty_dir') self.select_attr = config.attribute('select') self.file_color = { '-': 0, 'd': config.attribute('directory'), 'b': config.attribute('blockdev'), 'c': config.attribute('chardev'), 'p': config.attribute('pipe'), 's': config.attribute('socket'), 'l': config.attribute('link'), '?': config.attribute('unknown'), 'bin': config.attribute('binary') }
if gotodir[0] != os.sep: gotodir = self.cwd + os.sep + gotodir.rstrip(os.sep) if os.access(gotodir, os.F_OK): actualdir = self.cwd try: self.cwd = gotodir.rstrip(os.sep) self.selected = [] self.setContents() self.showContents() except OSError, error: self.cwd = actualdir self.view.message(str(error), config.attribute('error_message')) else: self.view.message("Not a directory: '%s'" % gotodir, config.attribute('error_message')) def loop(self): self.view.loop() def setOption(self): option = self.view.input('Option [latr]: ') if re.match('[latr]+', option) or option == '': self.option = option else: self.option = 'l' self.setContents() self.showContents(self.view.y) def setRegex(self): regex = self.view.input('regex: ')
def key_word(key='', word=''): a = config.attribute('information_key') b = config.attribute('information_sep') c = config.attribute('information_word') return [['[', b], [key, a], [']', b], [word+' ', c]]