示例#1
0
 def newline_mode(self, new, old):
     undoman = self.undo_manager
     if not (undoman.isUndoing() or undoman.isRedoing()):
         replace_newlines(self.text_view, const.EOLS[new])
     self.document.props.newline_mode = new
     def undo():
         self.proxy.newline_mode = old
     register_undo_callback(undoman, undo)
示例#2
0
文件: document.py 项目: khairy/editxt
    def newline_mode(self, new, old):
        undoman = self.document.undoManager()
        if not (undoman.isUndoing() or undoman.isRedoing()):
            replace_newlines(self.text_view, const.EOLS[new])
        self.document.props.newline_mode = new

        def undo():
            self.props.newline_mode = old

        register_undo_callback(undoman, undo)
示例#3
0
 def test(c):
     m = Mocker()
     editor = m.mock()
     editor.text >> c.input
     sel = editor.selection >> m.mock(NSRange)
     if c.input != c.output:
         rng = NSMakeRange(0, len(c.input))
         editor.put(ANY, rng) >> True
         editor.selection = sel
     with m:
         mod.replace_newlines(editor, c.eol)
示例#4
0
 def test(c):
     result = []
     m = Mocker()
     tv = m.mock(NSTextView)
     tv.string() >> c.input
     sel = tv.selectedRange() >> m.mock(NSRange)
     if c.input != c.output:
         rng = NSMakeRange(0, len(c.input))
         tv.shouldChangeTextInRange_replacementString_(rng, ANY) >> True
         ts = tv.textStorage() >> m.mock(NSTextStorage)
         ts.replaceCharactersInRange_withString_(rng, c.output)
         tv.didChangeText()
         tv.setSelectedRange_(sel)
     with m:
         mod.replace_newlines(tv, c.eol)
示例#5
0
 def test(c):
     result = []
     m = Mocker()
     tv = m.mock(NSTextView)
     tv.string() >> c.input
     sel = tv.selectedRange() >> m.mock(NSRange)
     if c.input != c.output:
         rng = NSMakeRange(0, len(c.input))
         tv.shouldChangeTextInRange_replacementString_(rng, ANY) >> True
         ts = tv.textStorage() >> m.mock(NSTextStorage)
         ts.replaceCharactersInRange_withString_(rng, c.output)
         tv.didChangeText()
         tv.setSelectedRange_(sel)
     with m:
         mod.replace_newlines(tv, c.eol)