Exemplo n.º 1
0
 def openfile(cb):
     if wnd.document.fileinfo:
         filename = wnd.document.fileinfo.dirname
     else:
         filename = ''
     from kaa.ui.selectfile import selectfile
     selectfile.show_fileopen(filename, cb)
Exemplo n.º 2
0
    def file_open(self, wnd):
        def cb(filename, encoding, newline):
            doc = kaa.app.storage.openfile(filename, encoding, newline)
            kaa.app.show_doc(doc)

        from kaa.ui.selectfile import selectfile
        selectfile.show_fileopen('.', cb)
Exemplo n.º 3
0
    def file_open(self, wnd, filename=''):
        def cb(filename, encoding, newline):
            if not filename:
                return

            for frame in kaa.app.get_frames():
                for doc in frame.get_documents():
                    if doc.get_filename() == filename:
                        if doc.wnds:
                            wnd = doc.wnds[0]
                            wnd.get_label('frame').bring_top()
                            wnd.activate()

                        MAX_FILENAMEMSG_LEN = 50
                        if len(filename) > MAX_FILENAMEMSG_LEN:
                            filename = '...{}'.format(filename[MAX_FILENAMEMSG_LEN*-1:])

                        kaa.app.messagebar.set_message("`{}` is already opened.".format(filename))
                        return

            doc = kaa.app.storage.openfile(filename, encoding, newline)
            kaa.app.show_doc(doc)

        from kaa.ui.selectfile import selectfile
        selectfile.show_fileopen(filename, cb)
Exemplo n.º 4
0
def main(stdscr):
    conf = config.Config(opt)
    sys.path.insert(0, conf.KAADIR)

    kaa.log.init(conf.LOGDIR)

    _init(stdscr)
    try:
        keydef.init(conf)

        kaa.app = app.CuiApp(conf)
        kaa.app.storage = fileio.FileStorage()

        if not opt.no_init:
            fname = opt.init_script
            if not fname:
                fname = os.path.join(kaa.app.config.KAADIR, '__kaa__.py')
            run_userinit(fname)

        mainframe = frame.MainFrame(stdscr)
        kaa.app.init(mainframe)

        if not opt.file:
            # no file args. show new document.
            doc = kaa.app.storage.newfile(temporary=True)
            kaa.app.show_doc(doc)
        else:
            dirname = None
            for filename in opt.file:
                if os.path.isdir(filename):
                    if not dirname:
                        dirname = filename
                else:
                    doc = kaa.app.storage.openfile(filename)
                    kaa.app.show_doc(doc)

            if dirname:
                from kaa.ui.selectfile import selectfile

                def cb(filename, encoding, newline):
                    if filename:
                        doc = kaa.app.storage.openfile(
                            filename, encoding, newline)
                        kaa.app.show_doc(doc)
                    else:
                        if not kaa.app.mainframe.childframes:
                            doc = kaa.app.storage.newfile(temporary=True)
                            kaa.app.show_doc(doc)

                selectfile.show_fileopen(dirname, cb)

        kaa.app.run()
        mainframe.destroy()
        kaa.app.on_shutdown()

    finally:
        _restore()
Exemplo n.º 5
0
    def file_open(self, wnd, filename=''):
        def cb(filename, encoding, newline):
            if not filename:
                return

            if self._activate_file(filename):
                return

            doc = kaa.app.storage.openfile(filename, encoding, newline)
            editor = kaa.app.show_doc(doc)
            self.restore_file_loc(editor)

        from kaa.ui.selectfile import selectfile
        selectfile.show_fileopen(filename, cb)
Exemplo n.º 6
0
    def file_open(self, wnd, filename=''):
        def cb(filename, encoding, newline):
            if not filename:
                return

            if self._activate_file(filename):
                return

            doc = kaa.app.storage.openfile(filename, encoding, newline)
            editor = kaa.app.show_doc(doc)
            self.restore_file_loc(editor)

        if not filename:
            if wnd and wnd.document.fileinfo:
                filename = wnd.document.fileinfo.dirname

        from kaa.ui.selectfile import selectfile
        selectfile.show_fileopen(filename, cb)
Exemplo n.º 7
0
    def _show_selected_recentlyfile(self, cb, filename):
        if filename:
            filename = os.path.abspath(filename)

            from kaa.ui.selectfile import selectfile
            selectfile.show_fileopen(filename, cb)
Exemplo n.º 8
0
def main(stdscr):
    conf = config.Config(opt)
    sys.path.insert(0, conf.KAADIR)

    kaa.log.init(conf.LOGDIR)

    _init(stdscr)
    try:
        keydef.init(conf)

        kaa.app = app.CuiApp(conf)
        kaa.app.storage = fileio.FileStorage()

        if not opt.no_init:
            fname = opt.init_script
            if not fname:
                fname = os.path.join(kaa.app.config.KAADIR, '__kaa__.py')
            run_userinit(fname)

        from kaa.cui import frame
        mainframe = frame.MainFrame(stdscr)
        kaa.app.init(mainframe)

        if not opt.file:
            # no file args. show new document.
            doc = kaa.app.storage.newfile(temporary=True)
            kaa.app.show_doc(doc)
        else:
            dirname = None
            for filename in opt.file:
                if os.path.isdir(filename):
                    if not dirname:
                        dirname = filename
                else:
                    doc = kaa.app.storage.openfile(filename)
                    editor = kaa.app.show_doc(doc)
                    kaa.app.file_commands.restore_file_loc(editor)

            if dirname:
                from kaa.ui.selectfile import selectfile

                def cb(filename, encoding, newline):
                    if filename:
                        doc = kaa.app.storage.openfile(
                            filename, encoding, newline)
                        kaa.app.show_doc(doc)
                    else:
                        if not kaa.app.mainframe.childframes:
                            doc = kaa.app.storage.newfile(temporary=True)
                            kaa.app.show_doc(doc)

                selectfile.show_fileopen(dirname, cb)

        if opt.command:
            cmd = kaa.app.focus.document.mode.get_command(
                opt.command)
            is_available, command = cmd
            if command:
                command(kaa.app.focus)
            else:
                sys.exit('Unknown command: {}'.format(opt.command))

        kaa.app.call_later(10, _check_newversion)
        kaa.app.run()
        mainframe.destroy()
        kaa.app.on_shutdown()

    finally:
        _restore()
Exemplo n.º 9
0
 def openfile(cb):
     from kaa.ui.selectfile import selectfile
     selectfile.show_fileopen('', cb)
Exemplo n.º 10
0
def main(stdscr):
    conf = config.Config(opt)
    sys.path.insert(0, conf.KAADIR)

    kaa.log.init(conf.LOGDIR)

    _init(stdscr)
    try:
        keydef.init(conf)

        kaa.app = app.CuiApp(conf)
        kaa.app.storage = fileio.FileStorage()

        if not opt.no_init:
            fname = opt.init_script
            if not fname:
                fname = os.path.join(kaa.app.config.KAADIR, '__kaa__.py')
            run_userinit(fname)

        from kaa.cui import frame
        mainframe = frame.MainFrame(stdscr)
        kaa.app.init(mainframe)

        if not opt.file:
            # no file args. show new document.
            doc = kaa.app.storage.newfile(temporary=True)
            kaa.app.show_doc(doc)
        else:
            dirname = None
            for filename in opt.file:
                if os.path.isdir(filename):
                    if not dirname:
                        dirname = filename
                else:
                    doc = kaa.app.storage.openfile(filename)
                    editor = kaa.app.show_doc(doc)
                    kaa.app.file_commands.restore_file_loc(editor)

            if dirname:
                from kaa.ui.selectfile import selectfile

                def cb(filename, encoding, newline):
                    if filename:
                        doc = kaa.app.storage.openfile(filename, encoding,
                                                       newline)
                        kaa.app.show_doc(doc)
                    else:
                        if not kaa.app.mainframe.childframes:
                            doc = kaa.app.storage.newfile(temporary=True)
                            kaa.app.show_doc(doc)

                selectfile.show_fileopen(dirname, cb)

        if opt.command:
            cmd = kaa.app.focus.document.mode.get_command(opt.command)
            is_available, command = cmd
            if command:
                command(kaa.app.focus)
            else:
                sys.exit('Unknown command: {}'.format(opt.command))


#        kaa.app.call_later(10, _check_newversion)
        kaa.app.run()
        mainframe.destroy()
        kaa.app.on_shutdown()

    finally:
        _restore()