示例#1
0
    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)
示例#2
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:
         replace_newlines(tv, c.eol)