Commits

Henning Schröder committed 86978db

different whitespace colors

Comments (0)

Files changed (8)

codeaide/ide/api.py

         pass
 
 
+
+    
+    
+class Project(Interface):
+    
+    root_path = property()
+    python_path = property()

codeaide/ide/simple/commands.py

-#! -*- coding: utf-8 -*-
+# -*- coding: utf-8 -*-
+import os
+
 from PyQt4.QtCore import SIGNAL, Qt
 from PyQt4.QtGui import QInputDialog
 
 from codeaide.interface import implements
 from codeaide.ide import api
 from codeaide.ide.base import i18n, CommandBase, CheckCommandBase, DocumentCommandBase
-from codeaide.ide.simple.utils import open_filename, save_filename
+from codeaide.ide.simple.utils import open_filename, save_filename, confirm_close
 
 
 def app():
 
 
     def execute(self):
-        filename = doc().filename()
+        filename = doc().filename
+        print "saving", repr(filename)
         if not os.path.exists(filename):
             filename = save_filename()
             if not filename:
                 return False
             filename = unicode(filename)
-            doc.renameDoc(doc.filename(), filename)
+            self.doc.filename = filename
         else:
             backup = filename + "~"
-
+            if os.path.exists(backup):
+                os.remove(backup)
+            os.rename(filename, backup)
+        self.doc.save
 
 
 class FileSaveAsCommand(DocumentCommandBase):
     menu = i18n("&File")
     icon = "document-save-as"
 
+    
+    def execute(self):
+        filename = save_filename()
+        if filename:
+            if not filename:
+                return False
+            filename = unicode(filename)
+            self.doc.renameDoc(self.doc.filename, filename)
+
 
 
 class FileCloseCommand(DocumentCommandBase):

codeaide/ide/simple/python.py

 
     def __init__(self, parent):
         QTreeView.__init__(self, parent)
+        #self.fs_model = QDirModel(self)
+        #self.fs_model.setLazyChildCount(True)
+        #self.fs_model.setNameFilters(["*.py"])
+        self.fs_model = QFileSystemModel()
+        #self.fs_model.setNameFilters(["*.py"])
+        self.fs_model.setFilter(QDir.AllEntries)
         self.setFrameStyle(QFrame.NoFrame)
         self.fs_model = QFileSystemModel()
         self.fs_model.setNameFilters(["*.py"])
 
         self.setModel(self.fs_model)
         #self.setCurrentIndex(self.fs_model.index(QDir.currentPath()))
+        #self.setCurrentIndex(self.fs_model.index(QDir.currentPath()))
         self.setRootIndex(self.fs_model.index(QDir.currentPath()))
         self.setColumnHidden(1, True)
         self.setColumnHidden(2, True)

codeaide/ide/simple/utils.py

 
 
 
-def confirm(doc):
+def confirm_close(doc):
     if doc.isModified():
         ret = QMessageBox.warning(
             self.parent.widget, i18n("Closing file"),
 
 class Configurable(object):
     
-    
+
     def __init__(self):
         self.connect(self, SIGNAL("settings_changed()"), self.on_reconfigure)
 
       occurrence_background="yellow",
       paren_color="red",
       paren_background="#b4eeb4",
-      whitespace_color="lightgrey",
+      space_color="lightgrey",
+      tab_color="lightblue",
+      all_space_color="darkred",
       status_new="darkgreen",
       status_modified="red",
       syntax_keyword="#808000", # darkYellow

codeaide/modes/visualhelper.py

     def init(self):
         self.pattern = "[\t ]"
         self.textedit.CharData.add_char(self.pattern)
-        self.pen = QPen(QColor(self.textedit.settings.scheme.whitespace_color))
+        self.all_space_pen = QPen(QColor(self.textedit.settings.scheme.all_space_color))
+        self.space_pen = QPen(QColor(self.textedit.settings.scheme.space_color))
+        self.tab_pen = QPen(QColor(self.textedit.settings.scheme.tab_color))
 
 
     def paint_hook_after(self, event, painter, viewport):
                 
         # XXX draw newline if self.show_newline == True
         # XXX draw tab
-        painter.setPen(self.pen)
-        rect = event.rect()
+        rect_intersects = event.rect().intersects
         get_user_data = self.textedit.user_data
+        painter_set_pen = painter.setPen
+        painter_draw_rect = painter.drawRect
         w = self.char_width
         dx = (w/2) + 0
         for vb in self.textedit.visible_blocks:
-            if not rect.intersects(vb.rect):
+            if not rect_intersects(vb.rect):
                 continue
             y = vb.top + vb.height / 2 - 1
             positions = get_user_data(vb.block).get("char_map", {}).get(" ", [])
+            if len(positions) == vb.block.text().length():
+                painter_set_pen(self.all_space_pen)
+            else:
+                painter_set_pen(self.space_pen)
             for pos, end in positions:
                 # XXX: better use drawPixmap?
-                painter.drawRect(dx+pos * w, y, 1,1)
+                painter_draw_rect(dx+pos * w, y, 1,1)
+            positions = get_user_data(vb.block).get("char_map", {}).get("\t", [])
+            if positions:
+                painter_set_pen(self.tab_pen)
+                for pos, end in positions:
+                    painter_draw_rect(dx+pos * w, y, 1,1)
 
-
  * snippets: loader for gedit and textmate, integrate with completer
  * search with occurrences mode
  * instant rename based on snippets and occurrences
-
+ * selecting text and pressing " oder ( will surround selection with
+   "" or ()
 
 documentation:
  * list with all shortcuts
  * lazy load help browser, add start page and navigation
  * macro recorder
  * real-fullscreen-mode which also hides panels, menus etc
+ * quick-access (searches in actions)
+
 
 cool text editing features:
  * http://blogs.jetbrains.com/pycharm/

icons/splash.png

Old
Old image
New
New image