Commits

Iñigo Serna committed e784b73

Implemented: delete history. Some other minor code cleaning.

* lfm/actions.py (general_menu): implemented: delete history

* lfm/messages.py (win): changed message colors

* lfm/messages.py (HISTORY_FILE): clean code
* lfm/messages.py (DEFAULT_HISTORY):
* lfm/lfm.py (lfm_start):
* lfm/lfm.py (Lfm.quit_program):

Comments (0)

Files changed (5)

+Mon May 16 17:15:01 2011  Iñigo Serna  <inigoserna@gmail.com>
+
+	* lfm/actions.py (general_menu): implemented: delete history
+
+Mon May 16 17:13:21 2011  Iñigo Serna  <inigoserna@gmail.com>
+
+	* lfm/messages.py (win): changed message colors
+
+Mon May 16 17:12:21 2011  Iñigo Serna  <inigoserna@gmail.com>
+
+	* lfm/messages.py (HISTORY_FILE): clean code
+	* lfm/messages.py (DEFAULT_HISTORY):
+	* lfm/lfm.py (lfm_start):
+	* lfm/lfm.py (Lfm.quit_program):
+
 Mon May 16 16:25:51 2011  Iñigo Serna  <inigoserna@gmail.com>
 
 	* lfm/actions.py (findgrep): find file->goto_file: move to correct page
 ============================================================================
-Last update:	Time-stamp: <2011-05-16 16:26:47 inigo>
+Last update:	Time-stamp: <2011-05-16 17:11:35 inigo>
 ============================================================================
 
-- Global Menu:
-  . new option: delete history, file?
-  . bug in regerate programs?
-
 
 General:
 ========
     - don't like much how recursive chmod/chown/chgrp currently works
       . split in 2 different features chmod and chown/chgrp ?
     - support for languages with wide chars
+      . look at Xin Wang's patch
       . check the real length on screen of the utf8-encoded strings.
         http://bugs.python.org/issue6755
         http://stackoverflow.com/questions/2476953/python-utf-8-howto-align-printout
     . config flag to enable/disable
 - PowerCLI: insert stored (from config) or history command => Ctrl-G
 - preferences: improve load/save handling of new options not present in ~/.lfmrc
-- fixed bugs:
+- global menu: new option: delete history
+
+- FIXED BUGS:
   . pyview:
     . last char is not shown if file size is small
     . last line and wrap: cursor_down or page_next
   . reorganized and fixed key bindings section
   . added link to public BitBucket repository
 
+
 THANKS:
 - yellowprotoss: feedback, ideas and copy/mkdir bugs report
 - Daniel Echeverry: debian mantainer
 - Martin Steigerwald: bug report
-- Xin Wang: bug report
+- Xin Wang: bug report, wide char patch
 - Jesper Vestergaard: asked about background file operations
     ord('q'): 'quit',
     ord('Q'): 'quit',
     curses.KEY_F10: 'quit',
-    0x11: 'exit'                     # Ctrl-Q
+    0x11: 'exit'                # Ctrl-Q
 }
 
 
     filename = tab.get_file()
     vfstype = compress.check_compressed_file_type(filename)
     typ = tab.files[filename][files.FT_TYPE]
-    if vfstype in ('bz2', 'gz'):
+    if vfstype in ('bz2', 'gz', 'xz'):
         vfstype = None
     if typ == files.FTYPE_DIR:
         tab.enter_dir(filename)
     tab.pane.display()
     t = Tree(tab.path, tab.pane.mode)
     ans = t.run()
-    del t
     app.act_pane, app.noact_pane = app.act_pane, app.noact_pane
     if ans != -1:
         tab.init(ans)
     tab.selections = [f for f in tab.sorted if f not in selections_old and \
                           f != os.pardir]
 
+
 # misc
 def toggle_dotfiles(tab):
-#     app.prefs.options['show_dotfiles'] = 1 if app.prefs.options['show_dotfiles'] == 0 else 0
-    if app.prefs.options['show_dotfiles'] == 0:
-        app.prefs.options['show_dotfiles'] = 1
-    else:
-        app.prefs.options['show_dotfiles'] = 0
+    app.prefs.options['show_dotfiles'] = 1 if app.prefs.options['show_dotfiles']==0 else 0
     app.regenerate()
 
 def toggle_manage_otherpane(tab):
     tab.refresh()
     app.regenerate()
 
+
 # main functions
 def __rename_backup_helper(tab):
     if tab.selections:
     #         not (os.path.isdir(os.path.dirname(destdir)) and not dest_exists):
     if dir_destdir != path and (not os.path.isdir(dir_destdir) or dest_exists):
         for f in fs:
-            src = os.path.join(path, f)
             dest = os.path.join(destdir, f)
             if not os.path.exists(dest) and not dest_exists:
                 messages.error('Cannot copy files\n' +
              'f    Show filesystems info',
              'o    Open shell',
              'c    Edit configuration',
-             'r    Regenerate programs' ]
+             'r    Regenerate programs',
+             'h    Delete history' ]
     cmd = messages.MenuWin('General Menu', menu).run()
     if cmd == -1:
         return
         app.prefs.check_progs()
         app.prefs.save()
         app.prefs.load()
-        messages.win('Regenerate programs', '          OK')
+        messages.win('Configuration', 'Regenerating programs... OK')
+    elif cmd == 'h':
+        files.delete_bulk(messages.HISTORY_FILE)
+        messages.history = messages.DEFAULT_HISTORY.copy()
 
 
 # window resize
 # -*- coding: utf-8 -*-
 
 # Copyright (C) 2001-11  Iñigo Serna
-# Time-stamp: <2011-05-16 01:52:21 inigo>
+# Time-stamp: <2011-05-16 17:03:57 inigo>
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 ######################################################################
 ##### Global variables
 LOG_FILE = os.path.join(os.getcwd(), 'lfm.log')
-HISTORY_FILE = os.path.abspath(os.path.expanduser('~/.lfm_history'))
 MAX_TAB_HISTORY = 15
 
 
         if self.prefs.options['save_conf_at_exit']:
             self.prefs.save()
         if self.prefs.options['save_history_at_exit']:
-            pickle.dump(messages.history, file(HISTORY_FILE, 'w'), -1)
+            pickle.dump(messages.history, file(messages.HISTORY_FILE, 'w'), -1)
         if icode == -1: # change directory
             return self.act_pane.act_tab.path
         else:           # exit, but don't change directory
     # history
     if prefs.options['save_history_at_exit']:
         try:
-            messages.history = pickle.load(file(HISTORY_FILE, 'r'))
+            messages.history = pickle.load(file(messages.HISTORY_FILE, 'r'))
         except:
-            messages.history = {'path': [], 'file': [], 'glob': [], 'grep': [], 'exec': [], 'cli': []}
+            messages.history = messages.DEFAULT_HISTORY.copy()
     else:
-        messages.history = {'path': [], 'file': [], 'glob': [], 'grep': [], 'exec': [], 'cli': []}
+        messages.history = messages.DEFAULT_HISTORY.copy()
 
     # logging
     if DEBUG:
 ######################################################################
 ##### module variables
 app = None
-history = {'path': [], 'file': [], 'glob': [], 'grep': [], 'exec': [], 'cli': []}
+HISTORY_FILE = os.path.abspath(os.path.expanduser('~/.lfm_history'))
+DEFAULT_HISTORY = {'path': [], 'file': [], 'glob': [], 'grep': [], 'exec': [], 'cli': []}
 MAX_HISTORY = 100
+history = DEFAULT_HISTORY.copy()
 
 
 ######################################################################
 
     CommonWindow(title, text,
                  curses.color_pair(1), curses.color_pair(1),
-                 curses.color_pair(4), curses.color_pair(4)).run()
+                 curses.color_pair(1), curses.color_pair(1)).run()
 
 
 def win_nokey(title, text, footer=''):