Пример #1
0
Subject: Backup of file <%s> in %s
MIME-Version: 1.0
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: 8bit


<pre>%s</pre>
"""
    if not connect:
        connect = SMTP('smtp.%s:25' % toaddr.split(u'@')[-1])
    #connect.set_debuglevel(1)
    try:
        connect.login(log, pas)
        connect.sendmail(fromaddr, toaddr, (message % (log, fromaddr, recipient, toaddr, apptitle, cur_time, text_message)).replace(u'\u2029', '<br>').encode('utf-8'))
    except:
        if ui.query(_('Action failed. Try again?')) == 1: return send()
    else:
        connect.quit()
        connect = None
        ui.infopopup.show(_('Action complete!'))


def get_shortcuts(cls):
    menu = old_get_shortcuts()
    menu.append(ui.MenuItem(_('Send buffer to email'), target=send))
    return menu


old_get_shortcuts = kaapython.repattr(kaapython.TextWindow, 'get_shortcuts', classmethod(get_shortcuts))
_ = kaapython.get_plugin_translator(__file__)
 
Пример #2
0
def ru(x): return x.decode('utf-8')


def edit(x, y):
    if not y: return None
    win = ui.screen.windows[0] # тeкyщee oткpытoe oкнo
    if not isinstance(win, (kaapython.PythonFileWindow, kaapython.PythonShellWindow)): return # чтoбы paбoтaл тoлькo в python-oвcкиx oкнax
    body = win.body
    if body.get()[body.get_pos()-4:body.get_pos()] == u'e32.':
        help.start(([u'ao_sleep()', 1], [u'ao_yield()', 0], [u'Ao_lock()', 0], [u'Ao_timer()', 1], [u'ao_callgate()', 0])) #кopтeж из cпиcкoв, гдe caм тeкcт и вeличинa, нa кoтopyю пepeмecтитcя кypcop влeвo
    elif body.get()[body.get_pos()-4:body.get_pos()] == u'help':
        help.start(ru('a этo вcплывaющee oкнo c кaкими-нибyдь пoдcкaзкaми.'))


script = kaapython.repattr(kaapython.PythonFileWindow, 'edit_callback', lambda self, pos, anchor: (script(self, pos, anchor), edit(pos, anchor)))
shell = kaapython.repattr(kaapython.PythonShellWindow, 'edit_callback', lambda self, pos, anchor: (shell(self, pos, anchor), edit(pos, anchor)))
help = helper.Window()


def callback():
    body = aw.app.body
    body.set_input_mode(aw.ENumericInputMode)
    body.add(help.result())
    body.set_input_mode(aw.ETextInputMode)

help.callback = callback
help.initialization()

##################
Пример #3
0
        help.start(moduls)
    elif text[pos - 1:pos] == u'.':
        try:
            mod_id = moduls.index(exp.encode('utf8'))
            try:
                mod = __import__(moduls[mod_id], globals(), globals())
                funcs = dir(mod)
                help.start(funcs)
            except Exception, info:
                ui.infopopup.show(_('Exception:\n%s') % info)
        except IndexError:
            if exp in globals(): help.start(dir(globals()[exp]))


script = kaapython.repattr(
    kaapython.PythonFileWindow, 'edit_callback', lambda self, pos, anchor:
    (script(self, pos, anchor), edit(self, pos, anchor)))
shell = kaapython.repattr(
    kaapython.PythonShellWindow, 'edit_callback', lambda self, pos, anchor:
    (shell(self, pos, anchor), edit(self, pos, anchor)))

move = kaapython.repattr(
    kaapython.PythonFileWindow, 'move_callback', lambda self:
    (move(self), edit(self, self.body.get_pos(), 0)))

help = helper.Window()


def callback():
    body = aw.app.body
    body.set_input_mode(aw.ENumericInputMode)
Пример #4
0
        lines = text.count(u'\u2029') + 1
        line = text[(text.rfind(u'\u2029') + 1):]
        indent = len(line) - len(line.lstrip())
        image.clear(0)
        image.text(
            (1, ((height / 2) - 1)),
            ((u'i:%4d|L:%7d|%8.2f%%|' %
              (indent, lines,
               (pos / ((self.body.len() / 100.0) or 1)))) + unicode(
                   (time.strftime('%H:%M:%S', time.localtime(time.time())) +
                    (' $%d' % self.shortcut_mode)))),
            fill=(255, 255, 255),
            font=(None, (height / 2), FONT_ANTIALIAS))
        image.text((1, (height - 1)),
                   (u'w:%2d|e:%s|%s' %
                    ((len(ui.screen.windows) - 1), self.encoding, self.title)),
                   fill=(255, 255, 255),
                   font=(None, (height / 2), FONT_ANTIALIAS))
        gbar.set(x, y, image._bitmapapi())
    else:
        gbar.unset()
    return _timer.after(settings.time_interval, info)


def new_open(self, focus=True):
    info(self)
    old_open(self, focus)


old_open = kaapython.repattr(kaapython.Window, 'open', new_open)