Anonymous avatar Anonymous committed 5f92374

Considering underlines as spaces when going to next/prev words

Comments (0)

Files changed (7)

+- Ignoring string and comment contents while indenting : May 29, 2006
+
+
 - Proposing templates in code-assist proposals : May 26, 2006
 
 
   ? Go toward refactoring and ... library rather than an IDE
 ? roadmap.html
 ? Migrating to sourceforge SVN before 0.3 release
-  ? SF repository; SVN or CVS? How to synchronize local SVN with SF?
+  ? SF repository; How to synchronize local SVN with SF SVN?
 ? Should workingon.txt be under version control?
 ? Functional tests
-? Separate domain and presentation everywhere
+i Separate domain and presentation everywhere
 * Logo
 * Make tests less dependant
 ? Project resource consistency; What if it is deleted after being created.

docs/workingon.txt

-*** Ignoring string and comment contents while indenting @ 1 ***
-
-- Add codeanalyze module
-- Adding LineEditor to the Editor class
-- Ignoring string contents
-- Ignoring comment contents
-
+*** Next/prev word should stop at underlines and capitals; make it configurable ***
 
 
 --- Before 0.2 Release ---
-* Next/prev word should stop at underlines and capitals; make it configurable
 * GUI testing redux; make a ropefunctest direction; ? rename ropetest to ropeunittest
 * Better editor changing dialog; use uihelpers module
 * More builtin templates
             endIndex = end._getIndex()
         self.text.delete(startIndex, endIndex)
         
-    def _get_next_word_index(self):
+    def _get_next_word_index_old(self):
         result = INSERT
         while self.text.compare(result, '!=', 'end-1c') and \
               not self.text.get(result)[0].isalnum():
             result = str(self.text.index(result + '+1c'))
         return result + ' wordend'
 
+    def _get_next_word_index(self):
+        current = str(self.text.index(INSERT))
+        while self.text.compare(current, '!=', 'end-1c') and not self.text.get(current).isalnum():
+            current = str(self.text.index(current + ' +1c'))
+        while self.text.compare(current, '!=', 'end-1c'):
+            current = str(self.text.index(current + ' +1c'))
+            if not self.text.get(current).isalnum():
+                break
+        return current
+
     def next_word(self):
         self.text.mark_set(INSERT, self._get_next_word_index())
         self.text.see(INSERT)
 
-    def _get_prev_word_index(self):
+    def _get_prev_word_index_old(self):
         result = INSERT
         while not self.text.compare(result, '==', '1.0') and \
               not self.text.get(result + '-1c')[0].isalnum():
             result = str(self.text.index(result + '-1c'))
         return result + '-1c wordstart'
 
+    def _get_prev_word_index(self):
+        current = str(self.text.index(INSERT))
+        while self.text.compare(current, '!=', '1.0') and not self.text.get(current + ' -1c').isalnum():
+            current = str(self.text.index(current + ' -1c'))
+        while self.text.compare(current, '!=', '1.0') and self.text.get(current + ' -1c').isalnum():
+            current = str(self.text.index(current + ' -1c'))
+        return current
+
     def prev_word(self):
         self.text.mark_set(INSERT, self._get_prev_word_index())
         self.text.see(INSERT)

ropetest/editortest.py

     def tearDown(self):
         unittest.TestCase.tearDown(self)
 
+    def testMoveNextWord(self):
+        self.editor.next_word()
+        self.assertEquals(' ', self.editor.get(), 'Expected <%c> but was <%c>' % (' ', self.editor.get()))
+
+    def testMoveNextWordOnSpaces(self):
+        self.editor.next_word()
+        self.editor.insert(self.editor.get_end(), ' and\n')
+        self.editor.next_word()
+        self.assertEquals(' ', self.editor.get())
+        self.editor.next_word()
+        self.assertEquals('\n', self.editor.get())
+
+    def testNextWordOnEnd(self):
+        self.editor.set_insert(self.editor.get_end())
+        self.editor.next_word()
+        self.assertEquals(self.editor.get_end(), self.editor.get_insert())
+
+    def testNextWordOnNewLine(self):
+        self.editor.set_insert(self.editor.get_relative(self.editor.get_end(), -1))
+        self.editor.insert(self.editor.get_end(), '\non a new line')
+        self.editor.next_word()
+        self.assertEquals('\n', self.editor.get())
+
+    def testNextWordOnNewLine(self):
+        self.editor.set_text('hello \n world\n')
+        self.editor.next_word()
+        self.editor.next_word()
+        self.assertEquals('\n', self.editor.get(), self.editor.get())
+
+    def testNextOneCharacterWord(self):
+        self.editor.set_text('1 2\n')
+        self.editor.next_word()
+        self.assertEquals(' ', self.editor.get())
+        self.editor.next_word()
+        self.assertEquals('\n', self.editor.get())
+
+    def testPrevWordOnTheBegining(self):
+        self.editor.prev_word()
+        self.assertEquals('s', self.editor.get())
+
+    def testPrevWord(self):
+        self.editor.set_insert(self.editor.get_end())
+        self.editor.prev_word()
+        self.assertEquals('t', self.editor.get())
+        self.editor.prev_word()
+        self.assertEquals('s', self.editor.get())
+
+    def testPrevWordOnTheMiddleOfAWord(self):
+        self.editor.set_insert(self.editor.get_relative(self.editor.get_end(), -2))
+        self.editor.prev_word()
+        self.assertEquals('t', self.editor.get())
+
+    def testPrevOneCharacterWord(self):
+        self.editor.set_text('1 2 3')
+        self.editor.set_insert(self.editor.get_end())
+        self.editor.prev_word()
+        self.assertEquals('3', self.editor.get())
+        self.editor.prev_word()
+        self.assertEquals('2', self.editor.get())
+        self.editor.prev_word()
+        self.assertEquals('1', self.editor.get())
+
+    def testDeletingNextWord(self):
+        self.editor.delete_next_word()
+        self.assertEquals(' text', self.editor.get_text())
+
+    def testDeletingNextWordInTheMiddle(self):
+        self.editor.set_insert(self.editor.get_index(2))
+        self.editor.delete_next_word()
+        self.assertEquals('sa text', self.editor.get_text())
+
+    def testDeletingPrevWord(self):
+        self.editor.set_insert(self.editor.get_end())
+        self.editor.delete_prev_word()
+        self.assertEquals('sample ', self.editor.get_text(), self.editor.get_text())
+
+    def testDeletingPrevWordInTheMiddle(self):
+        self.editor.set_insert(self.editor.get_relative(self.editor.get_end(), -2))
+        self.editor.delete_prev_word()
+        self.assertEquals('sample xt', self.editor.get_text(), self.editor.get_text())
+
+    def testDeletingPrevWordAtTheBeginning(self):
+        self.editor.set_insert(self.editor.get_index(3))
+        self.editor.delete_prev_word()
+        self.assertEquals('ple text', self.editor.get_text(), self.editor.get_text())
+
+    def test_next_word_stopping_at_underline(self):
+        self.editor.set_text('sample_text')
+        self.editor.set_insert(self.editor.get_start())
+        self.editor.next_word()
+        self.assertEquals(self.editor.get_index(6), self.editor.get_insert())
+
+    def test_next_word_stopping_at_underline_prev_word(self):
+        self.editor.set_text('sample_text')
+        self.editor.set_insert(self.editor.get_end())
+        self.editor.prev_word()
+        self.assertEquals(self.editor.get_index(7), self.editor.get_insert())
+
+    def testGoingToTheStart(self):
+        self.editor.set_insert(self.editor.get_index(3))
+        self.editor.goto_start()
+        self.assertEquals(self.editor.get_start(), self.editor.get_insert())
+
+    def testGoingToTheEnd(self):
+        self.editor.set_insert(self.editor.get_index(3))
+        self.editor.goto_end()
+        self.assertEquals(self.editor.get_end(), self.editor.get_insert())
+
     def test_undo(self):
         self.editor.undo_separator()
         self.editor.insert(self.editor.get_end(), '.')

ropetest/mockeditor.py

             endIndex = end._getIndex()
         self.content = self.content[:startIndex] + self.content[endIndex:]
 
-    def _getNextWordIndex(self):
-        current = self.insertIndex._getIndex()
-        while current < len(self.content) - 1 and not self.content[current].isalnum():
-            current += 1
-        while current < len(self.content) - 1:
-            current += 1
-            if (not self.content[current].isalnum()):
-                break
-        return current
-
-    def next_word(self):
-        self.insertIndex = MockTextIndex(self, self._getNextWordIndex())
-
-    def delete_next_word(self):
-        self.content = self.content[0 : self.insertIndex._getIndex()] + \
-                       self.content[self._getNextWordIndex() :]
-
-    def _getPrevWordIndex(self):
-        current = self.insertIndex._getIndex()
-        while current > 0 and not self.content[current - 1].isalnum():
-            current -= 1
-        while current > 0 and self.content[current - 1].isalnum():
-            current -= 1
-        return current
-
-    def prev_word(self):
-        self.insertIndex = MockTextIndex(self, self._getPrevWordIndex())
-
-    def delete_prev_word(self):
-        self.content = self.content[0 : self._getPrevWordIndex()] + \
-                       self.content[self.insertIndex._getIndex() :]
-
-    def goto_start(self):
-        self.set_insert(self.get_start())
-
-    def goto_end(self):
-        self.set_insert(self.get_end())
-
     def set_highlighting(self, highlighting):
         pass
 

ropetest/mockeditortest.py

         self.editor.delete(self.editor.get_index(11))
         self.assertEquals('sample textanother piece of text', self.editor.get_text())
 
-    def testMoveNextWord(self):
-        self.editor.next_word()
-        self.assertEquals(' ', self.editor.get(), 'Expected <%c> but was <%c>' % (' ', self.editor.get()))
-
-    def testMoveNextWordOnSpaces(self):
-        self.editor.next_word()
-        self.editor.insert(self.editor.get_end(), ' and\n')
-        self.editor.next_word()
-        self.assertEquals(' ', self.editor.get())
-        self.editor.next_word()
-        self.assertEquals('\n', self.editor.get())
-
-    def testNextWordOnEnd(self):
-        self.editor.set_insert(self.editor.get_end())
-        self.editor.next_word()
-        self.assertEquals(self.editor.get_end(), self.editor.get_insert())
-
-    def testNextWordOnNewLine(self):
-        self.editor.set_insert(self.editor.get_relative(self.editor.get_end(), -1))
-        self.editor.insert(self.editor.get_end(), '\non a new line')
-        self.editor.next_word()
-        self.assertEquals('\n', self.editor.get())
-
-    def testNextWordOnNewLine(self):
-        self.editor.set_text('hello \n world\n')
-        self.editor.next_word()
-        self.editor.next_word()
-        self.assertEquals('\n', self.editor.get(), self.editor.get())
-
-    def testNextOneCharacterWord(self):
-        self.editor.set_text('1 2\n')
-        self.editor.next_word()
-        self.assertEquals(' ', self.editor.get())
-        self.editor.next_word()
-        self.assertEquals('\n', self.editor.get())
-
-    def testPrevWordOnTheBegining(self):
-        self.editor.prev_word()
-        self.assertEquals('s', self.editor.get())
-
-    def testPrevWord(self):
-        self.editor.set_insert(self.editor.get_end())
-        self.editor.prev_word()
-        self.assertEquals('t', self.editor.get())
-        self.editor.prev_word()
-        self.assertEquals('s', self.editor.get())
-
-    def testPrevWordOnTheMiddleOfAWord(self):
-        self.editor.set_insert(self.editor.get_relative(self.editor.get_end(), -2))
-        self.editor.prev_word()
-        self.assertEquals('t', self.editor.get())
-
-    def testPrevOneCharacterWord(self):
-        self.editor.set_text('1 2 3')
-        self.editor.set_insert(self.editor.get_end())
-        self.editor.prev_word()
-        self.assertEquals('3', self.editor.get())
-        self.editor.prev_word()
-        self.assertEquals('2', self.editor.get())
-        self.editor.prev_word()
-        self.assertEquals('1', self.editor.get())
-
-    def testDeletingNextWord(self):
-        self.editor.delete_next_word()
-        self.assertEquals(' text', self.editor.get_text())
-
-    def testDeletingNextWordInTheMiddle(self):
-        self.editor.set_insert(self.editor.get_index(2))
-        self.editor.delete_next_word()
-        self.assertEquals('sa text', self.editor.get_text())
-
-    def testDeletingPrevWord(self):
-        self.editor.set_insert(self.editor.get_end())
-        self.editor.delete_prev_word()
-        self.assertEquals('sample ', self.editor.get_text(), self.editor.get_text())
-
-    def testDeletingPrevWordInTheMiddle(self):
-        self.editor.set_insert(self.editor.get_relative(self.editor.get_end(), -2))
-        self.editor.delete_prev_word()
-        self.assertEquals('sample xt', self.editor.get_text(), self.editor.get_text())
-
-    def testDeletingPrevWordAtTheBeginning(self):
-        self.editor.set_insert(self.editor.get_index(3))
-        self.editor.delete_prev_word()
-        self.assertEquals('ple text', self.editor.get_text(), self.editor.get_text())
-
-    def testGoingToTheStart(self):
-        self.editor.set_insert(self.editor.get_index(3))
-        self.editor.goto_start()
-        self.assertEquals(self.editor.get_start(), self.editor.get_insert())
-
-    def testGoingToTheStart(self):
-        self.editor.set_insert(self.editor.get_index(3))
-        self.editor.goto_end()
-        self.assertEquals(self.editor.get_end(), self.editor.get_insert())
-
     def test_searching(self):
         found = self.editor.search('s', self.editor.get_insert())
         self.assertEquals(self.editor.get_start(), found)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.