def __onTextEditorCaretMove(self, page, params): if self._enableOnTextEditorCaretMove: text = params.editor.GetText() print(params.startSelection, params.endSelection) if (params.startSelection == params.endSelection and positionInside(text, params.startSelection, '{$', '$}')): print('Equation!')
def test_positionInside_09(): text = '[=[==][==]=]' position = 8 left = '[=' right = '=]' result = positionInside(text, position, left, right) assert result
def test_positionInside_06(): text = '[==][==]' position = 4 left = '[=' right = '=]' result = positionInside(text, position, left, right) assert not result
def test_positionInside_empty(): text = '' position = 0 left = '[=' right = '=]' result = positionInside(text, position, left, right) assert not result
def test_positionInside_02(): text = '[=бла-бла-бла=]' position = 5 left = '[=' right = '=]' result = positionInside(text, position, left, right) assert result
def test_positionInside_11(): text = 'блабла[=...=]блабла' position = 6 left = '[=' right = '=]' result = positionInside(text, position, left, right) assert not result
def __onTextEditorCaretMove(self, page: 'outwiker.core.tree.WikiPage', params: 'outwiker.core.events.TextEditorCaretMoveParams') -> None: if params.startSelection != params.endSelection: return editor = params.editor position = params.startSelection text = editor.GetText() insideEquation = positionInside(text, position, '{$', '$}') if insideEquation: # May be the window was closed by user if not self._prevPositionInsideEquation: self._showToolsWindow() self._updateEquation(text, position) else: self._hideToolsWindow() self._prevPositionInsideEquation = insideEquation
def __onTextEditorCaretMove( self, page: 'outwiker.core.tree.WikiPage', params: 'outwiker.core.events.TextEditorCaretMoveParams') -> None: if params.startSelection != params.endSelection: return editor = params.editor position = params.startSelection text = editor.GetText() insideEquation = positionInside(text, position, '{$', '$}') if insideEquation: # May be the window was closed by user if not self._prevPositionInsideEquation: self._showToolsWindow() self._updateEquation(text, position) else: self._hideToolsWindow() self._prevPositionInsideEquation = insideEquation