def __init__( self, parent ):
        self.__maxLength = None

        TextEditor.__init__( self, parent, None )
        self.__revisionTooltipShown = False
        self.__initAlterRevisionMarker()
        self._updateDwellingTime()
        return
Exemple #2
0
    def __init__(self, parent):
        self.__maxLength = None

        TextEditor.__init__(self, parent, None)
        self.__revisionTooltipShown = False
        self.__initAlterRevisionMarker()
        self._updateDwellingTime()
        return
Exemple #3
0
    def _onDwellStart(self, position, x, y):
        " Triggered when mouse started to dwell "
        if not self.underMouse():
            return

        marginNumber = self._marginNumber(x)
        if marginNumber == self.TIMESTAMP_MARGIN:
            self.__showTimestampTooltip(position, x, y)
            return

        TextEditor._onDwellStart(self, position, x, y)
        return
    def _onDwellStart( self, position, x, y ):
        " Triggered when mouse started to dwell "
        if not self.underMouse():
            return

        marginNumber = self._marginNumber( x )
        if marginNumber == self.REVISION_MARGIN:
            self.__showRevisionTooltip( position, x, y )
            return

        TextEditor._onDwellStart( self, position, x, y )
        return
Exemple #5
0
    def _onDwellStart(self, position, x, y):
        " Triggered when mouse started to dwell "
        if not self.underMouse():
            return

        marginNumber = self._marginNumber(x)
        if marginNumber == self.REVISION_MARGIN:
            self.__showRevisionTooltip(position, x, y)
            return

        TextEditor._onDwellStart(self, position, x, y)
        return
    def _onDwellStart( self, position, x, y ):
        " Triggered when mouse started to dwell "
        if not self.underMouse():
            return

        marginNumber = self._marginNumber( x )
        if marginNumber == self.TIMESTAMP_MARGIN:
            self.__showTimestampTooltip( position, x, y )
            return

        TextEditor._onDwellStart( self, position, x, y )
        return
Exemple #7
0
    def __init__(self, parent):
        TextEditor.__init__(self, parent, None)
        self.zoomTo(Settings().zoom)

        # line number -> [ timestamps ]
        self.__marginTooltip = {}
        self.mode = self.MODE_OUTPUT
        self.lastOutputPos = None
        self.inputEcho = True
        self.inputBuffer = ""
        self.__messages = IOConsoleMessages()

        self.__initGeneralSettings()
        self.__initMargins()

        self.__timestampTooltipShown = False
        self.__initMessageMarkers()
        self._updateDwellingTime()

        self.installEventFilter(self)
        return
    def __init__( self, parent ):
        TextEditor.__init__( self, parent, None )
        self.zoomTo( Settings().zoom )

        # line number -> [ timestamps ]
        self.__marginTooltip = {}
        self.mode = self.MODE_OUTPUT
        self.lastOutputPos = None
        self.inputEcho = True
        self.inputBuffer = ""
        self.__messages = IOConsoleMessages()

        self.__initGeneralSettings()
        self.__initMargins()

        self.__timestampTooltipShown = False
        self.__initMessageMarkers()
        self._updateDwellingTime()

        self.installEventFilter( self )
        return
Exemple #9
0
    def insertText(self):
        " Triggered when insert is requested "
        if self.isReadOnly():
            return True

        # Check what is in the buffer
        text = QApplication.clipboard().text()
        if '\n' in text or '\r' in text:
            return True

        if not self.inputEcho:
            self.inputBuffer += text
            return True

        startPos = self.currentPosition()
        TextEditor.paste(self)
        endPos = self.currentPosition()

        self.SendScintilla(self.SCI_STARTSTYLING, startPos, 31)
        self.SendScintilla(self.SCI_SETSTYLING, endPos - startPos,
                           self.stdinStyle)
        return True
    def insertText( self ):
        " Triggered when insert is requested "
        if self.isReadOnly():
            return True

        # Check what is in the buffer
        text = QApplication.clipboard().text()
        if '\n' in text or '\r' in text:
            return True

        if not self.inputEcho:
            self.inputBuffer += text
            return True

        startPos = self.currentPosition()
        TextEditor.paste( self )
        endPos = self.currentPosition()

        self.SendScintilla( self.SCI_STARTSTYLING, startPos, 31 )
        self.SendScintilla( self.SCI_SETSTYLING,
                            endPos - startPos, self.stdinStyle )
        return True
 def setLineNumMarginWidth( self ):
     TextEditor.setLineNumMarginWidth( self )
     self.setRevisionMarginWidth()
     return
Exemple #12
0
'''
Author: Elijah Sawyers
Date: 11/11/2019
Overview: Creates the main window, adds the TextEditor widget to the window,
and starts the event loop.
'''

import tkinter as tk

from texteditor import TextEditor

if __name__ == '__main__':
    root = tk.Tk()
    root.title('escode')
    root.columnconfigure(0, weight=1)
    root.rowconfigure(0, weight=1)
    root.option_add('*tearOff', tk.FALSE)
    text_editor = TextEditor(root).grid(column=0, row=0, sticky='NSEW')
    root.mainloop()
Exemple #13
0
 def setLineNumMarginWidth(self):
     TextEditor.setLineNumMarginWidth(self)
     self.setRevisionMarginWidth()
     return
Exemple #14
0
def get_instance(args):
    return TextEditor(args)
Exemple #15
0
def main():
    import sys
    import argparse
    import colorama
    from config_store import ConfigStore, ConfigLoadError
    from mininote import Mininote
    from texteditor import TextEditor, TextEditorError

    class NotLoggedInError(Exception):
        """Error for user not logged in."""

    def get_mn(config_store):
        """
        :param ConfigStore config_store: User configuration
        :returns: Mininote instance
        """
        try:
            auth_token = config_store.auth_token
        except ConfigLoadError:
            raise NotLoggedInError()

        try:
            notebook_guid = config_store.notebook_guid
        except ConfigLoadError:
            notebook_guid = None

        login_time0 = time.time()
        mn = Mininote(auth_token, notebook_guid)
        logger.debug('Login time: {}'.format(time.time() - login_time0))
        return mn

    colorama.init()

    root_logger = logging.getLogger()
    root_logger.setLevel('WARNING')
    root_logger.addHandler(logging.StreamHandler())

    config_store = ConfigStore()
    parser = argparse.ArgumentParser()
    parser.add_argument('-v',
                        '--verbose',
                        default=False,
                        action='store_true',
                        help=argparse.SUPPRESS)

    if len(sys.argv) > 1:
        subparsers = parser.add_subparsers()

        addnote = subparsers.add_parser('add')
        addnote.add_argument('note', help='Note text')
        addnote.set_defaults(handler=add_note, authorized=True)

        searchnote = subparsers.add_parser('search')
        searchnote.add_argument('note', help='Note search filter')
        searchnote.set_defaults(handler=query_notes, authorized=True)

        loginopt = subparsers.add_parser('login')
        loginopt.set_defaults(handler=login, authorized=False)

        editnote = subparsers.add_parser('edit')
        editnote.add_argument('note', help='Note search filter')
        editnote.set_defaults(handler=edit_notes,
                              authorized=True,
                              text_editor=TextEditor(config_store.text_editor))

        editor = subparsers.add_parser('set-editor')
        editor.add_argument('text_editor', help='Name of text editor')
        editor.set_defaults(handler=set_editor, authorized=False)
    else:
        # default is add note
        parser.set_defaults(handler=add_note, authorized=True, note=None)

    args = parser.parse_args()

    if args.verbose:
        root_logger.setLevel('DEBUG')

    try:
        mn = get_mn(config_store) if args.authorized else None
        args.handler(mn, config_store, args)
    except NotLoggedInError:
        logger.error('Please login using \'mn login\'')
    except TextEditorError:
        logger.error(
            'Error opening text editor\n' +
            'Please specify an editor with \'mn set-editor "<path-to-editor>"\''
        )
    except KeyboardInterrupt:
        pass