コード例 #1
0
ファイル: plugin.py プロジェクト: Jenyay/outwiker
    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!')
コード例 #2
0
ファイル: test_text.py プロジェクト: refaqtor/outwiker
def test_positionInside_09():
    text = '[=[==][==]=]'
    position = 8
    left = '[='
    right = '=]'

    result = positionInside(text, position, left, right)
    assert result
コード例 #3
0
ファイル: test_text.py プロジェクト: refaqtor/outwiker
def test_positionInside_06():
    text = '[==][==]'
    position = 4
    left = '[='
    right = '=]'

    result = positionInside(text, position, left, right)
    assert not result
コード例 #4
0
ファイル: test_text.py プロジェクト: refaqtor/outwiker
def test_positionInside_empty():
    text = ''
    position = 0
    left = '[='
    right = '=]'

    result = positionInside(text, position, left, right)
    assert not result
コード例 #5
0
ファイル: test_text.py プロジェクト: refaqtor/outwiker
def test_positionInside_02():
    text = '[=бла-бла-бла=]'
    position = 5
    left = '[='
    right = '=]'

    result = positionInside(text, position, left, right)
    assert result
コード例 #6
0
ファイル: test_text.py プロジェクト: refaqtor/outwiker
def test_positionInside_11():
    text = 'блабла[=...=]блабла'
    position = 6
    left = '[='
    right = '=]'

    result = positionInside(text, position, left, right)
    assert not result
コード例 #7
0
ファイル: plugin.py プロジェクト: Jenyay/outwiker
    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!')
コード例 #8
0
    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
コード例 #9
0
    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