Exemple #1
0
            (130, '', '-', wx.ITEM_SEPARATOR, None, ''),
            (140, 'IDM_DOCUMENT_SYNTAX_HIGHLIGHT', tr('Syntax Highlight...'), wx.ITEM_NORMAL, 'OnDocumentSyntaxHighlight', tr('Specifies the syntax highlight to current document.')),
        ]),
    ])
Mixin.setPlugin('mainframe', 'add_menu', add_mainframe_menu)

def OnDocumentSyntaxHighlight(win, event):
#    items = [lexer.name for lexer in win.lexers.lexobjs]
    items = win.lexers.getLexerNames()
    dlg = wx.SingleChoiceDialog(win, tr('Select a syntax highlight:'), tr('Syntax Highlight'), items, wx.CHOICEDLG_STYLE)
    if dlg.ShowModal() == wx.ID_OK:
        lexer = win.lexers.lexobjs[dlg.GetSelection()]
        lexer.colourize(win.document)
        win.editctrl.switch(win.document)
    dlg.Destroy()
Mixin.setMixin('mainframe', 'OnDocumentSyntaxHighlight', OnDocumentSyntaxHighlight)

def add_pref(preflist):
    preflist.extend([
        (tr('General'), 130, 'choice', 'default_lexer', tr('Default syntax highlight:'), LexerFactory.lexnames),
        (tr('Document'), 120, 'check', 'caret_line_visible', tr('Show caret line'), None),
    ])
Mixin.setPlugin('preference', 'add_pref', add_pref)

def pref_init(pref):
    pref.default_lexer = 'text'
    pref.caret_line_visible = True
Mixin.setPlugin('preference', 'init', pref_init)

def savepreference(mainframe, pref):
    mainframe.document.SetCaretLineVisible(pref.caret_line_visible)
Exemple #2
0
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
#   $Id$

from modules import common
from modules import Mixin

project_names = ['mako']
Mixin.setMixin('dirbrowser', 'project_names', project_names)


def set_project(ini, projectnames):
    if 'mako' in projectnames:
        common.set_acp_highlight(ini, '.mko', ['html.acp', 'makohtml.acp'],
                                 'makotmp')


Mixin.setPlugin('dirbrowser', 'set_project', set_project)


def remove_project(ini, projectnames):
    if 'mako' in projectnames:
        common.remove_acp_highlight(ini, '.mko', ['html.acp', 'makohtml.acp'],
                                    'makotmp')
Exemple #3
0
    popmenulist.extend([ (None,
        [
            (150, 'IDPM_FTPWINDOW', tr('FTP Window'), wx.ITEM_CHECK, 'OnFtpWindow', tr('Shows the FTP pane.')),
        ]),
    ])
Mixin.setPlugin('notebook', 'add_menu', add_editor_menu)

def createFtpWindow(win, side='bottom'):
    page = win.panel.getPage('FTP')
    if not page:
        from FtpClass import Ftp

        page = Ftp(win.panel.createNotebook(side), win)
        win.panel.addPage(side, page, 'FTP')
    win.ftp = page
Mixin.setMixin('mainframe', 'createFtpWindow', createFtpWindow)

def OnWindowFtp(win, event):
    if not win.panel.getPage('FTP'):
        win.createFtpWindow()
        win.panel.showPage('FTP')
    else:
        win.panel.closePage('FTP')
Mixin.setMixin('mainframe', 'OnWindowFtp', OnWindowFtp)

def OnFtpWindow(win, event):
    if not win.panel.getPage('FTP'):
        win.mainframe.createFtpWindow('bottom')
        win.panel.showPage('FTP')
    else:
        win.panel.closePage('FTP')
Exemple #4
0
    ])
Mixin.setPlugin('pythonfiletype', 'add_menu', add_mainframe_menu)

def editor_init(win):
    win.class_browser = False
    win.init_class_browser = False #if the class view has shown
Mixin.setPlugin('editor', 'init', editor_init)

def OnPythonClassBrowser(win, event):
    win.document.class_browser = not win.document.class_browser
    win.document.panel.showWindow(win.pref.python_classbrowser_show_side, win.document.class_browser)
    if win.document.panel.visible(win.pref.python_classbrowser_show_side):
        if win.document.init_class_browser == False:
            win.document.init_class_browser = True
            win.document.outlinebrowser.show()
Mixin.setMixin('mainframe', 'OnPythonClassBrowser', OnPythonClassBrowser)

def aftersavefile(win, filename):
    if (win.edittype == 'edit'
        and win.languagename == 'python'
        and win.pref.python_classbrowser_refresh_as_save
        and win.init_class_browser):
        wx.CallAfter(win.outlinebrowser.show)
Mixin.setPlugin('editor', 'aftersavefile', aftersavefile)

def OnPythonClassBrowserRefresh(win, event):
    win.document.outlinebrowser.show()
Mixin.setMixin('mainframe', 'OnPythonClassBrowserRefresh', OnPythonClassBrowserRefresh)

def OnPythonUpdateUI(win, event):
    eid = event.GetId()
Exemple #5
0
        ]),
    ])
Mixin.setPlugin('mainframe', 'add_menu', add_mainframe_menu)

def add_editor_menu(popmenulist):
    popmenulist.extend([
        ('IDPM_FORMAT',
        [
            (126, 'IDPM_FORMAT_WRAP', tr('Wrap Text...')+'\tE=Ctrl+Shift+T', wx.ITEM_NORMAL, 'OnFormatWrap', tr('Wraps selected text.')),
        ]),
    ])
Mixin.setPlugin('editor', 'add_menu', add_editor_menu)

def OnEditFormatWrap(win, event):
    OnFormatWrap(win.document, event)
Mixin.setMixin('mainframe', 'OnEditFormatWrap', OnEditFormatWrap)

def pref_init(pref):
    pref.wrap_width = 75
    pref.wrap_indent = ''
    pref.wrap_firstindent = ''
    pref.wrap_skipchar = ''
    pref.wrap_remove_tailingchar = ''
    pref.wrap_add_tailingchar = ''
Mixin.setPlugin('preference', 'init', pref_init)

def OnFormatWrap(win, event):
    pref = Globals.pref
    v = {'width':pref.wrap_width, 'indent':pref.wrap_indent,
        'firstindent':pref.wrap_firstindent, 'skipchar':pref.wrap_skipchar,
        'remove_tailingchar':pref.wrap_remove_tailingchar,
Exemple #6
0
_codesnippet_page_name = tr('Code Snippets')

def createCodeSnippetWindow(win):
    try:
        import xml.etree.ElementTree
    except:
        import elementtree.ElementTree

    page = win.panel.getPage(_codesnippet_page_name)
    if not page:
        from CodeSnippet import CodeSnippetWindow

        page = CodeSnippetWindow(win.panel.createNotebook('left'), win)
        win.panel.addPage('left', page, _codesnippet_page_name)
    return page
Mixin.setMixin('mainframe', 'createCodeSnippetWindow', createCodeSnippetWindow)

def afterinit(win):
    wx.EVT_UPDATE_UI(win, win.IDM_WINDOW_CODESNIPPET, win.OnUpdateUI)
Mixin.setPlugin('mainframe', 'afterinit', afterinit)

def on_mainframe_updateui(win, event):
    eid = event.GetId()
    if eid == win.IDM_WINDOW_CODESNIPPET:
        page = win.panel.getPage(_codesnippet_page_name)
        event.Check(bool(page) and win.panel.LeftIsVisible)
Mixin.setPlugin('mainframe', 'on_update_ui', on_mainframe_updateui)

def on_notebook_updateui(win, event):
    eid = event.GetId()
    if eid == win.IDPM_CODESNIPPETWINDOW:
Exemple #7
0
            win.dosprompt.process.Redirect()
            if guiflag:
                win.dosprompt.pid = wx.Execute(command, wx.EXEC_ASYNC|wx.EXEC_NOHIDE, win.dosprompt.process)
            else:
                win.dosprompt.pid = wx.Execute(command, wx.EXEC_ASYNC, win.dosprompt.process)
            win.dosprompt.inputstream = win.dosprompt.process.GetInputStream()
            win.dosprompt.errorstream = win.dosprompt.process.GetErrorStream()
            win.dosprompt.outputstream = win.dosprompt.process.GetOutputStream()
        except:
            win.dosprompt.process = None
            dlg = wx.MessageDialog(win, tr("There are some problems when running the program!\nPlease run it in shell.") ,
                    "Stop running", wx.OK | wx.ICON_INFORMATION)
            dlg.ShowModal()
    else:
        wx.Execute(command)
Mixin.setMixin('mainframe', 'RunDosCommand', RunDosCommand)

def OnIdle(win, event):
    if win.process is not None:
        if win.inputstream:
            if win.inputstream.CanRead():
                text = win.inputstream.read()
                if win.commandlen > 0:
                    if len(text) >= win.commandlen:
                        text = text[win.commandlen:]
                        win.commandlen = 0
                    else:
                        text = ''
                        win.commandlen -= len(text)
                appendtext(win, text)
                print repr(text)
Exemple #8
0

def setEOLMode(win, mode, convert=True):
    win.lineendingsaremixed = False
    win.eolmode = mode
    if convert:
        win.ConvertEOLs(win.eols[mode])
    win.SetEOLMode(win.eols[mode])
    common.set_line_ending(win.eolstr[mode])


def OnDocumentEolConvertWin(win, event):
    setEOLMode(win.document, 1)


Mixin.setMixin('mainframe', 'OnDocumentEolConvertWin', OnDocumentEolConvertWin)


def OnDocumentEolConvertUnix(win, event):
    setEOLMode(win.document, 0)


Mixin.setMixin('mainframe', 'OnDocumentEolConvertUnix',
               OnDocumentEolConvertUnix)


def OnDocumentEolConvertMac(win, event):
    setEOLMode(win.document, 2)


Mixin.setMixin('mainframe', 'OnDocumentEolConvertMac', OnDocumentEolConvertMac)
Exemple #9
0
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
#   $Id$

import wx
import os.path
from modules import Mixin

menulist = [ ('IDM_HELP', #parent menu id
    [
        (103, 'IDM_HELP_SHOWERROR', tr('Show error.log'), wx.ITEM_NORMAL, 'OnHelpShowError', tr('Show error.log file content.')),
        (104, 'IDM_HELP_SHOWDEBUG', tr('Show debug.log'), wx.ITEM_NORMAL, 'OnHelpShowDebug', tr('Show debug.log file content.')),
    ]),
]
Mixin.setMixin('mainframe', 'menulist', menulist)

#def add_editctrl_menu(popmenulist):
#    popmenulist.extend([ (None,
#        [
#            (610, 'IDPM_SHOWERROR', tr('Show error.log'), wx.ITEM_NORMAL, 'OnEditCtrlHelpShowError', tr('Saves an opened document using the same filename')),
#            (620, 'IDPM_SHOWDEBUG', tr('Show debug.log'), wx.ITEM_NORMAL, 'OnEditCtrlHelpShowDebug', tr('Show debug.log file content.')),
#        ]),
#    ])
#Mixin.setPlugin('editctrl', 'add_menu', add_editctrl_menu)
#
def OnHelpShowError(win, event):
    win.editctrl.new(os.path.join(win.userpath, 'error.txt'))
Mixin.setMixin('mainframe', 'OnHelpShowError', OnHelpShowError)

def OnHelpShowDebug(win, event):
Exemple #10
0
        menus.extend([(None, #parent menu id
            [
                (30, 'IDPM_DJANGO_PROJECT', tr('&Django'), wx.ITEM_NORMAL, '', ''),
                (40, '', '-', wx.ITEM_SEPARATOR, None, ''),
            ]),
            ('IDPM_DJANGO_PROJECT',
            [
                (100, 'IDPM_DJANGO_PROJECT_NEW_MODEL', tr('&New Model'), wx.ITEM_NORMAL, 'OnDjangoProjectFunc', tr('Create a new model.')),
                (110, '', '-', wx.ITEM_SEPARATOR, None, ''),
            ]),
        ])
Mixin.setPlugin('editor', 'other_popup_menu', other_popup_menu)

def OnDjangoProjectFunc(win, event):
    _id = event.GetId()
    try:
        if _id == win.IDPM_DJANGO_PROJECT_NEW_MODEL:
            OnDjangoProjectNewModel(win)
    except:
        error.traceback()
        common.showerror(win, tr("There is some wrong as executing the menu."))
Mixin.setMixin('editor', 'OnDjangoProjectFunc', OnDjangoProjectFunc)

def OnDjangoProjectNewModel(win):
    import maketext
    text = maketext.maketext(maketext.getmodel(win))
    if text:
        win.GotoPos(win.GetTextLength() - 1)
        win.EnsureCaretVisible()
        win.AddText(text)
Exemple #11
0
            ('IDPM_DOCBOOK_PROJECT',
            [
                (100, 'IDPM_DOCBOOK_PROJECT_ENCLOSE', tr('Add/Enclose With DocBook Element...'), wx.ITEM_NORMAL, 'OnDocbookProjectFunc', tr('Add or enclose selected text with docbook element.')),
            ]),
        ])
Mixin.setPlugin('editor', 'other_popup_menu', other_popup_menu)

def OnDocbookProjectFunc(win, event):
    _id = event.GetId()
    try:
        if _id == win.IDPM_DOCBOOK_PROJECT_ENCLOSE:
            OnDocbookEnclose(win)
    except:
        error.traceback()
        common.showerror(win, tr("There is some wrong as executing the menu."))
Mixin.setMixin('editor', 'OnDocbookProjectFunc', OnDocbookProjectFunc)

def OnDocbookEnclose(editor):
    #find the docbook.acp file
    docbookini = common.getConfigPathFile('docbook_xml.ini')
    from modules import dict4ini
    x = dict4ini.DictIni(docbookini)
    taglist = x.default.taglist
    taglist.sort()
    #popup a selection win
    if taglist:
        from modules.EasyGuider import EasyDialog
        dialog = [
            ('single', 'tagname', taglist[0], tr('Select a tag:'), taglist),
        ]
        dlg = EasyDialog.EasyDialog(editor, tr('Select a DocBook Element Name'), dialog)
Exemple #12
0
            d, f, m = s[0]
            win.editctrl.new(f)
            flag = jump_to_file(win, d, f, m)
        elif len(s) > 1:
            text = []
            _mlist = {}
            for i, v in enumerate(s):
                d, f, m = v
                key = str(i+1)+'|'+d+'|'+os.path.basename(f)
                text.append(key)
                _mlist[key] = (d, f, m)
            win.document.UserListShow(2, " ".join(text))
            flag = True
    if not flag:
        win.document.callplugin('on_jump_definition', win.document, word)
Mixin.setMixin('mainframe', 'OnSearchJumpDef', OnSearchJumpDef)

def on_user_list_selction(win, list_type, text):
    t = list_type
    if t == 2:  #1 is used by input assistant
        if _mlist:
            v = _mlist.get(text, None)
            if v:
                d, f, m = v
                jump_to_file(win, d, f, m)
Mixin.setPlugin('editor', 'on_user_list_selction', on_user_list_selction)

def OnJumpDef(win, event):
    win.mainframe.OnSearchJumpDef(event)
Mixin.setMixin('editor', 'OnJumpDef', OnJumpDef)
Exemple #13
0
        (None, 
        [
            (800, 'IDM_CONFIG', tr('Config'), wx.ITEM_NORMAL, '', ''),
        ]),
        ('IDM_CONFIG',
        [
            (100, 'IDM_CONFIG_INPUTASSISTANT', tr('Input Assistant Enabled')+'\tAlt+A', wx.ITEM_CHECK, 'OnConfigInputAssistant', tr('Enable input assistant.')),
        ]),
        
    ])
Mixin.setPlugin('mainframe', 'add_menu', add_mainframe_menu)

def OnDocumentApplyAcp(win, event):
    if hasattr(win, 'document') and win.document.edittype == 'edit':
       get_acp_files(win.document)
Mixin.setMixin('mainframe', 'OnDocumentApplyAcp', OnDocumentApplyAcp)

def add_editor_menu(popmenulist):
    popmenulist.extend([
        (None,
        [
            (270, 'IDPM_APPLYACP', tr('Apply Autocompleted Files'), wx.ITEM_NORMAL, 'OnApplyAcp', tr('Apply autocompleted files to current document.')),
        ]),
    ])
Mixin.setPlugin('editor', 'add_menu', add_editor_menu)

def OnApplyAcp(win, event):
    win.mainframe.OnDocumentApplyAcp(event)
Mixin.setMixin('editor', 'OnApplyAcp', OnApplyAcp)

###########################################################################
Exemple #14
0
Mixin.setPlugin('changefiletype', 'add_filetypes', add_filetypes)

def add_rest_menu(menulist):
    menulist.extend([('IDM_MARKDOWN', #parent menu id
            [
                (100, 'IDM_MD_VIEW_IN_LEFT', tr('View HTML Result In Left Pane'), wx.ITEM_NORMAL, 'OnMDViewHtmlInLeft', tr('Views HTML result in left pane.')),
                (110, 'IDM_MD_VIEW_IN_BOTTOM', tr('View HTML Result In Bottom Pane'), wx.ITEM_NORMAL, 'OnMDViewHtmlInBottom', tr('Views HTML result in bottom pane.')),
            ]),
    ])
Mixin.setPlugin('mdfiletype', 'add_menu', add_rest_menu)

def OnMDViewHtmlInLeft(win, event):
    dispname = win.createMDHtmlViewWindow('left', Globals.mainframe.editctrl.getCurDoc())
    if dispname:
        win.panel.showPage(dispname)
Mixin.setMixin('mainframe', 'OnMDViewHtmlInLeft', OnMDViewHtmlInLeft)

def OnMDViewHtmlInBottom(win, event):
    dispname = win.createMDHtmlViewWindow('bottom', Globals.mainframe.editctrl.getCurDoc())
    if dispname:
        win.panel.showPage(dispname)
Mixin.setMixin('mainframe', 'OnMDViewHtmlInBottom', OnMDViewHtmlInBottom)

def closefile(win, document, filename):
    for pagename, panelname, notebook, page in Globals.mainframe.panel.getPages():
        if is_mdhtmlview(page, document):
            Globals.mainframe.panel.closePage(page)
Mixin.setPlugin('mainframe', 'closefile', closefile)

def setfilename(document, filename):
    for pagename, panelname, notebook, page in Globals.mainframe.panel.getPages():
Exemple #15
0
            concurrent.cmdrecorder.remove_document(s_id)
Mixin.setPlugin('mainframe', 'closefile', closefile)

def add_mainframe_menu(menulist):
    menulist.extend([ ('IDM_TOOL',
        [
            (510, 'IDM_TOOL_CONCURRENT', tr('Collaborative Programming'), wx.ITEM_NORMAL, 'OnToolConcurrent', tr('Collaborative programming.')),
        ]),
    ])
Mixin.setPlugin('mainframe', 'add_menu', add_mainframe_menu)

def OnToolConcurrent(win, event):
    page = win.createConcurrentWindow()
    if page:
        win.panel.showPage(page)
Mixin.setMixin('mainframe', 'OnToolConcurrent', OnToolConcurrent)

pagename = tr('Collaborative')
def createConcurrentWindow(win):
    page = win.panel.getPage(pagename)
    if not page:
        import Concurrent

        page = Concurrent.ConcurrentWindow(win.panel.createNotebook('bottom'))
        win.panel.addPage('bottom', page, pagename)
        win.concurrent = page
    return page
Mixin.setMixin('mainframe', 'createConcurrentWindow', createConcurrentWindow)

def pref_init(pref):
    pref.pairprog_host = '127.0.0.1'
Exemple #16
0
def OnOpenRecentFiles(win, event=None):
    menu = wx.Menu()
    pref = win.pref
    for index, filename in enumerate(pref.recent_files):

        def OnFunc(event, index=index):
            open_recent_files(win, index)

        _id = wx.NewId()
        item = wx.MenuItem(menu, _id, filename, filename)
        wx.EVT_MENU(win, _id, OnFunc)
        menu.AppendItem(item)
    win.PopupMenu(menu)


Mixin.setMixin('mainframe', 'OnOpenRecentFiles', OnOpenRecentFiles)


def add_pref(preflist):
    preflist.extend([(tr('Document'), 200, 'num', 'recent_files_num',
                      tr('Maximum number of recent files:'), None)])


Mixin.setPlugin('preference', 'add_pref', add_pref)

#def OnOpenRecentPaths(win, event=None):
#    menu = wx.Menu()
#    pref = win.pref
#    for index, filename in enumerate(pref.recent_paths):
#        def OnFunc(event, index=index):
#            open_recent_paths(win, index)
        [
            (190, '', '-', wx.ITEM_SEPARATOR, None, ''),
            (200, 'IDPM_GOTO', tr('Goto error line'), wx.ITEM_NORMAL, 'OnGoto', tr('Goto the line that occurs the error.')),
        ]),
    ])
Mixin.setPlugin('messagewindow', 'other_popup_menu', other_popup_menu)

r = re.compile('File\s+"(.*?)",\s+line\s+(\d+)')
def OnGoto(win, event):
    line = win.GetCurLine()[0]
    b = r.search(common.encode_string(line, common.defaultfilesystemencoding))
    if b:
        filename, lineno = b.groups()
        Globals.mainframe.editctrl.new(filename)
        wx.CallAfter(Globals.mainframe.document.goto, int(lineno))
Mixin.setMixin('messagewindow', 'OnGoto', OnGoto)

def messagewindow_init(win):
    wx.EVT_LEFT_DCLICK(win, win.OnGoto)
Mixin.setPlugin('messagewindow', 'init', messagewindow_init)

def pref_init(pref):
    pref.clear_message = True
    pref.message_wrap = False
    pref.message_setfocus_back = False
Mixin.setPlugin('preference', 'init', pref_init)

def add_pref(preflist):
    preflist.extend([
        (tr('General'), 170, 'check', 'clear_message', tr('Autoclear messages window content at program run'), None),
        (tr('General'), 180, 'check', 'message_setfocus_back', tr('Set focus back to document window after program run'), None),
Exemple #18
0
from modules import Mixin
from mixins import FiletypeBase

class FortranFiletype(FiletypeBase.FiletypeBase):

    __mixinname__ = 'fortranfiletype'
    menulist = [ (None,
        [
            (890, 'IDM_FORTRAN', 'Fortran', wx.ITEM_NORMAL, None, ''),
        ]),
    ]
    toollist = []               #your should not use supperclass's var
    toolbaritems= {}

def add_filetypes(filetypes):
    filetypes.extend([('fortran', FortranFiletype)])
Mixin.setPlugin('changefiletype', 'add_filetypes', add_filetypes)

def add_html_menu(menulist):
    menulist.extend([('IDM_FORTRAN', #parent menu id
            [
                (100, 'IDM_FORTRAN_TEST', tr('This is a test menu'), wx.ITEM_NORMAL, 'OnFortranTest', tr('This is a test.')),
            ]),
    ])
Mixin.setPlugin('fortranfiletype', 'add_menu', add_html_menu)

def OnFortranTest(win, event):
    print 'fortran menu test'
Mixin.setMixin('mainframe', 'OnFortranTest', OnFortranTest)

Exemple #19
0
def add_editor_menu_image_list(imagelist):
    imagelist.update({
        'IDPM_FORMAT_INDENT': 'images/indent.gif',
        'IDPM_FORMAT_UNINDENT': 'images/unindent.gif',
    })


Mixin.setPlugin('editor', 'add_menu_image_list', add_editor_menu_image_list)


def OnEditFormatIndent(win, event):
    OnFormatIndent(win.document, event)


Mixin.setMixin('mainframe', 'OnEditFormatIndent', OnEditFormatIndent)


def OnEditFormatUnindent(win, event):
    OnFormatUnindent(win.document, event)


Mixin.setMixin('mainframe', 'OnEditFormatUnindent', OnEditFormatUnindent)


def OnFormatIndent(win, event):
    win.CmdKeyExecute(wx.stc.STC_CMD_TAB)


Mixin.setMixin('editor', 'OnFormatIndent', OnFormatIndent)
Exemple #20
0
def OnPopupEdit(win, event):
    eid = event.GetId()
    if eid == win.IDPM_UNDO:
        win.Undo()
    elif eid == win.IDPM_REDO:
        win.Redo()
    elif eid == win.IDPM_CUT:
        win.Cut()
    elif eid == win.IDPM_COPY:
        win.Copy()
    elif eid == win.IDPM_PASTE:
        win.Paste()
    elif eid == win.IDPM_SELECTION_SELECTALL:
        win.SelectAll()
Mixin.setMixin('editor', 'OnPopupEdit', OnPopupEdit)

def add_mainframe_menu(menulist):
    menulist.extend([ (None, #parent menu id
        [
            (200, 'IDM_EDIT', tr('Edit'), wx.ITEM_NORMAL, None, ''),
        ]),
        ('IDM_EDIT', #parent menu id
        [
            (201, 'IDM_EDIT_UNDO', tr('Undo') +'\tE=Ctrl+Z', wx.ITEM_NORMAL, 'DoSTCBuildIn', tr('Reverses previous editing operation.')),
            (202, 'IDM_EDIT_REDO', tr('Redo') +'\tE=Ctrl+Y', wx.ITEM_NORMAL, 'DoSTCBuildIn', tr('Reverses previous undo operation.')),
            (203, '', '-', wx.ITEM_SEPARATOR, None, ''),
            (204, 'IDM_EDIT_CUT', tr('Cut') + '\tE=Ctrl+X', wx.ITEM_NORMAL, 'DoSTCBuildIn', tr('Deletes text from the document and moves it to the clipboard.')),
            (205, 'IDM_EDIT_COPY', tr('Copy') + '\tE=Ctrl+C', wx.ITEM_NORMAL, 'DoSTCBuildIn', tr('Copies text from the document to the clipboard.')),
            (206, 'IDM_EDIT_PASTE', tr('Paste') + '\tE=Ctrl+V', wx.ITEM_NORMAL, 'DoSTCBuildIn', tr('Pastes text from the clipboard into the document.')),
            (210, '', '-', wx.ITEM_SEPARATOR, None, ''),
            page = Editor.TextEditor(win.panel.createNotebook(side),
                                     None,
                                     filename,
                                     document.documenttype,
                                     multiview=True)
            page.SetDocPointer(document.GetDocPointer())
            page.document = document  #save document object
            document.lexer.colourize(page, True)
            win.panel.addPage(side, page, dispname)
            win.panel.setImageIndex(page, 'document')
            return page
    else:
        return obj


Mixin.setMixin('mainframe', 'createMultiViewWindow', createMultiViewWindow)


def OnMultiViewWindow(win, event):
    side = win.getSide()
    dispname = win.mainframe.createMultiViewWindow(
        side, Globals.mainframe.editctrl.getCurDoc())
    if dispname:
        win.panel.showPage(dispname)


Mixin.setMixin('notebook', 'OnMultiViewWindow', OnMultiViewWindow)


def closefile(win, document, filename):
    for pagename, panelname, notebook, page in Globals.mainframe.panel.getPages(

def OnDocumentSyntaxHighlight(win, event):
    #    items = [lexer.name for lexer in win.lexers.lexobjs]
    items = win.lexers.getLexerNames()
    dlg = wx.SingleChoiceDialog(win, tr('Select a syntax highlight:'),
                                tr('Syntax Highlight'), items,
                                wx.CHOICEDLG_STYLE)
    if dlg.ShowModal() == wx.ID_OK:
        lexer = win.lexers.lexobjs[dlg.GetSelection()]
        lexer.colourize(win.document)
        win.editctrl.switch(win.document)
    dlg.Destroy()


Mixin.setMixin('mainframe', 'OnDocumentSyntaxHighlight',
               OnDocumentSyntaxHighlight)


def add_pref(preflist):
    preflist.extend([
        (tr('General'), 130, 'choice', 'default_lexer',
         tr('Default syntax highlight:'), LexerFactory.lexnames),
        (tr('Document'), 120, 'check', 'caret_line_visible',
         tr('Show caret line'), None),
    ])


Mixin.setPlugin('preference', 'add_pref', add_pref)


def pref_init(pref):
Exemple #23
0
            (300, 'IDM_DOCUMENT_EOL_CONVERT_MAX', tr('Convert To Mac Format'), wx.ITEM_NORMAL, 'OnDocumentEolConvertMac', tr('Converts line ending to Mac format.')),
        ]),
    ])
Mixin.setPlugin('mainframe', 'add_menu', add_mainframe_menu)

def setEOLMode(win, mode, convert=True):
    win.lineendingsaremixed = False
    win.eolmode = mode
    if convert:
        win.ConvertEOLs(win.eols[mode])
    win.SetEOLMode(win.eols[mode])
    common.set_line_ending(win.eolstr[mode])

def OnDocumentEolConvertWin(win, event):
    setEOLMode(win.document, 1)
Mixin.setMixin('mainframe', 'OnDocumentEolConvertWin', OnDocumentEolConvertWin)

def OnDocumentEolConvertUnix(win, event):
    setEOLMode(win.document, 0)
Mixin.setMixin('mainframe', 'OnDocumentEolConvertUnix', OnDocumentEolConvertUnix)

def OnDocumentEolConvertMac(win, event):
    setEOLMode(win.document, 2)
Mixin.setMixin('mainframe', 'OnDocumentEolConvertMac', OnDocumentEolConvertMac)

def check_mixed(text):
    lineendingsaremixed = False

    eollist = "".join(map(getEndOfLineCharacter, text))

    len_win = eollist.count('\r\n')
Exemple #24
0

Mixin.setPlugin('mainframe', 'add_menu', add_mainframe_menu)


def OnHelpIndex(win, event):
    lang = 'en'
    if Globals.app.i18n.lang:
        lang = Globals.app.i18n.lang
    filename = common.get_app_filename(win, 'doc/%s/index.htm' % lang)
    if not os.path.exists(filename):
        filename = common.get_app_filename(win, 'doc/%s/index.htm' % 'en')
    common.webopen(filename)


Mixin.setMixin('mainframe', 'OnHelpIndex', OnHelpIndex)


def OnHelpAbout(win, event):
    AboutDialog(win).ShowModal()


Mixin.setMixin('mainframe', 'OnHelpAbout', OnHelpAbout)


def OnHelpProject(win, event):
    common.webopen(homepage)


Mixin.setMixin('mainframe', 'OnHelpProject', OnHelpProject)
Exemple #25
0
#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
#   $Id$

from modules import Mixin
import wx
import images
from modules import Globals
import os

popmenulist = [ ('IDPM_ADD',
    [
        (100, 'IDPM_ADD_RSSREADER', tr('RSS Reader'), wx.ITEM_NORMAL, 'OnAddRssReader', ''),
    ]),
]
Mixin.setMixin('sharewin', 'popmenulist', popmenulist)

def add_process_class(type, win, proc_dict):
    if type == 'rss':
        from RssReader import RssReader
        proc_dict['rss'] = RssReader(win)
Mixin.setPlugin('sharewin', 'add_process_class', add_process_class)

def add_images(images):
    s = [
        ('RSS_ROOT_IMAGE', 'rss.gif'),
        ('RSS_CATEGORY_IMAGE', 'category.gif'),
        ('RSS_FEED_IMAGE', 'feed.gif'),
        ('RSS_RUN1', 'run1.gif'),
        ('RSS_RUN2', 'run2.gif'),
        ('RSS_RUN3', 'run3.gif'),
Exemple #26
0
#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
#   $Id$

import wx
from modules import Mixin

menulist = [
    (
        'IDM_PYTHON',  #parent menu id
        [
            (170, 'IDM_PYTHON_CHECK', tr('Check Syntax'), wx.ITEM_NORMAL,
             'OnPythonCheck', tr('Check python source code syntax.')),
        ]),
]
Mixin.setMixin('pythonfiletype', 'menulist', menulist)


def add_tool_list(toollist, toolbaritems):
    toollist.extend([
        (2140, 'check'),
    ])

    #order, IDname, imagefile, short text, long text, func
    toolbaritems.update({
        'check': (wx.ITEM_NORMAL, 'IDM_PYTHON_CHECK', 'images/spellcheck.gif',
                  tr('Check Syntax'), tr('Check python source code syntax.'),
                  'OnPythonCheck'),
    })

Exemple #27
0
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
#       $Id$

import wx
from modules import Mixin
from mixins import FiletypeBase

class RubyFiletype(FiletypeBase.FiletypeBase):

    __mixinname__ = 'rubyfiletype'
    menulist = [ (None,
            [
                    (890, 'IDM_RUBY', 'Ruby', wx.ITEM_NORMAL, None, ''),
            ]),
    ]
    toollist = []           #your should not use supperclass's var
    toolbaritems= {}

filetype = [('ruby', RubyFiletype)]
Mixin.setMixin('changefiletype', 'filetypes', filetype)
Exemple #28
0
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
#   $Id$

from modules import Mixin
import wx
import os
from modules import common

menulist = [('IDM_PYTHON', #parent menu id
                [
                        (160, 'IDM_PYTHON_DEBUG', tr('Debug In WinPdb'), wx.ITEM_NORMAL, 'OnPythonDebug', tr('Debug the current program in WinPdb.')),
                ]),
]
Mixin.setMixin('pythonfiletype', 'menulist', menulist)

toollist = [
        (2130, 'debug'),
]
Mixin.setMixin('pythonfiletype', 'toollist', toollist)

#order, IDname, imagefile, short text, long text, func
toolbaritems = {
        'debug':(wx.ITEM_NORMAL, 'IDM_PYTHON_DEBUG', 'images/debug.png', tr('Debug'), tr('Debug the current program in WinPdb.'), 'OnPythonDebug'),
}
Mixin.setMixin('pythonfiletype', 'toolbaritems', toolbaritems)

def OnPythonDebug(win, event):
    interpreters = dict(win.pref.python_interpreter)
    interpreter = interpreters.get(win.pref.default_interpreter, '')
Exemple #29
0
Mixin.setPlugin('changefiletype', 'add_filetypes', add_filetypes)

def add_rest_menu(menulist):
    menulist.extend([('IDM_REST', #parent menu id
            [
                (100, 'IDM_REST_VIEW_IN_LEFT', tr('View HTML Result In Left Pane'), wx.ITEM_NORMAL, 'OnRestViewHtmlInLeft', tr('Views HTML result in left pane.')),
                (110, 'IDM_REST_VIEW_IN_BOTTOM', tr('View HTML Result In Bottom Pane'), wx.ITEM_NORMAL, 'OnRestViewHtmlInBottom', tr('Views HTML result in bottom pane.')),
            ]),
    ])
Mixin.setPlugin('restfiletype', 'add_menu', add_rest_menu)

def OnRestViewHtmlInLeft(win, event):
    dispname = win.createRestHtmlViewWindow('left', Globals.mainframe.editctrl.getCurDoc())
    if dispname:
        win.panel.showPage(dispname)
Mixin.setMixin('mainframe', 'OnRestViewHtmlInLeft', OnRestViewHtmlInLeft)

def OnRestViewHtmlInBottom(win, event):
    dispname = win.createRestHtmlViewWindow('bottom', Globals.mainframe.editctrl.getCurDoc())
    if dispname:
        win.panel.showPage(dispname)
Mixin.setMixin('mainframe', 'OnRestViewHtmlInBottom', OnRestViewHtmlInBottom)

def closefile(win, document, filename):
    for pagename, panelname, notebook, page in Globals.mainframe.panel.getPages():
        if is_resthtmlview(page, document):
            Globals.mainframe.panel.closePage(page)
Mixin.setPlugin('mainframe', 'closefile', closefile)

def setfilename(document, filename):
    for pagename, panelname, notebook, page in Globals.mainframe.panel.getPages():
Exemple #30
0
            win.dosprompt.inputstream = win.dosprompt.process.GetInputStream()
            win.dosprompt.errorstream = win.dosprompt.process.GetErrorStream()
            win.dosprompt.outputstream = win.dosprompt.process.GetOutputStream(
            )
        except:
            win.dosprompt.process = None
            dlg = wx.MessageDialog(
                win,
                tr("There are some problems when running the program!\nPlease run it in shell."
                   ), "Stop running", wx.OK | wx.ICON_INFORMATION)
            dlg.ShowModal()
    else:
        wx.Execute(command)


Mixin.setMixin('mainframe', 'RunDosCommand', RunDosCommand)


def OnIdle(win, event):
    if win.process is not None:
        if win.inputstream:
            if win.inputstream.CanRead():
                text = win.inputstream.read()
                if win.commandlen > 0:
                    if len(text) >= win.commandlen:
                        text = text[win.commandlen:]
                        win.commandlen = 0
                    else:
                        text = ''
                        win.commandlen -= len(text)
                appendtext(win, text)
Exemple #31
0

Mixin.setPlugin('editor', 'init', editor_init)


def OnPythonClassBrowser(win, event):
    win.document.class_browser = not win.document.class_browser
    win.document.panel.showWindow(win.pref.python_classbrowser_show_side,
                                  win.document.class_browser)
    if win.document.panel.visible(win.pref.python_classbrowser_show_side):
        if win.document.init_class_browser == False:
            win.document.init_class_browser = True
            win.document.outlinebrowser.show()


Mixin.setMixin('mainframe', 'OnPythonClassBrowser', OnPythonClassBrowser)


def aftersavefile(win, filename):
    if (win.edittype == 'edit' and win.languagename == 'python'
            and win.pref.python_classbrowser_refresh_as_save
            and win.init_class_browser):
        wx.CallAfter(win.outlinebrowser.show)


Mixin.setPlugin('editor', 'aftersavefile', aftersavefile)


def OnPythonClassBrowserRefresh(win, event):
    win.document.outlinebrowser.show()
Exemple #32
0
                 tr('Views html content in bottom pane.')),
            ]),
    ])


Mixin.setPlugin('htmlfiletype', 'add_menu', add_html_menu)


def OnHtmlBrowserInLeft(win, event):
    dispname = win.createHtmlViewWindow('left',
                                        Globals.mainframe.editctrl.getCurDoc())
    if dispname:
        win.panel.showPage(dispname)


Mixin.setMixin('mainframe', 'OnHtmlBrowserInLeft', OnHtmlBrowserInLeft)


def OnHtmlBrowserInBottom(win, event):
    dispname = win.createHtmlViewWindow('bottom',
                                        Globals.mainframe.editctrl.getCurDoc())
    if dispname:
        win.panel.showPage(dispname)


Mixin.setMixin('mainframe', 'OnHtmlBrowserInBottom', OnHtmlBrowserInBottom)


def createHtmlViewWindow(win, side, document):
    dispname = document.getShortFilename()
    obj = None
Exemple #33
0
    import Preference
    from modules import Globals

    win.pref = Preference.Preference()
    win.pref.load()
    win.pref.printValues()
    Globals.pref = win.pref


Mixin.setPlugin('app', 'beforegui', beforegui, Mixin.HIGH)


def OnOptionPreference(win, event):
    import PrefDialog

    dlg = PrefDialog.PrefDialog(win)
    dlg.ShowModal()


Mixin.setMixin('mainframe', 'OnOptionPreference', OnOptionPreference)


def add_pref_page(pages_order):
    pages_order.update({
        tr('General'): 100,
        tr('Document'): 110,
    })


Mixin.setPlugin('preference', 'add_pref_page', add_pref_page)
Exemple #34
0
    ])


Mixin.setPlugin('mainframe', 'add_menu', add_mainframe_menu)


def OnWindowLeft(win, event):
    flag = not win.panel.LeftIsVisible

    #    if flag:
    #        win.createSnippetWindow()
    #
    win.panel.showWindow('left', flag)


Mixin.setMixin('mainframe', 'OnWindowLeft', OnWindowLeft)


def OnWindowBottom(win, event):
    flag = not win.panel.BottomIsVisible
    #    if flag:
    #        if not win.panel.bottombook or win.panel.bottombook.GetPageCount() == 0:
    #            win.createShellWindow()

    win.panel.showWindow('bottom', flag)
    if flag:
        if not win.panel.bottombook or win.panel.bottombook.GetPageCount(
        ) == 0:
            win.panel.showPage(_shell_page_name)

Exemple #35
0
            win.EnsureCaretVisible()
            return True


Mixin.setPlugin('editor', 'on_key_down', OnKeyDown, Mixin.LOW)


def OnDocumentWordWrap(win, event):
    mode = win.document.GetWrapMode()
    if mode == wx.stc.STC_WRAP_NONE:
        win.document.SetWrapMode(wx.stc.STC_WRAP_WORD)
    else:
        win.document.SetWrapMode(wx.stc.STC_WRAP_NONE)


Mixin.setMixin('mainframe', 'OnDocumentWordWrap', OnDocumentWordWrap)


def OnDocumentAutoIndent(win, event):
    win.pref.autoindent = not win.pref.autoindent
    win.pref.save()


Mixin.setMixin('mainframe', 'OnDocumentAutoIndent', OnDocumentAutoIndent)


def afterinit(win):
    wx.EVT_UPDATE_UI(win, win.IDM_DOCUMENT_WORDWRAP, win.OnUpdateUI)
    wx.EVT_UPDATE_UI(win, win.IDM_DOCUMENT_AUTOINDENT, win.OnUpdateUI)
    wx.EVT_UPDATE_UI(win, win.IDM_DOCUMENT_TABINDENT, win.OnUpdateUI)
Exemple #36
0
Mixin.setPlugin('mainframe', 'on_update_ui', on_update_ui)


def afterinit(win):
    wx.EVT_UPDATE_UI(win, win.IDM_VIEW_RULER, win.OnUpdateUI)


Mixin.setPlugin('mainframe', 'afterinit', afterinit)


def OnViewRuler(win, event):
    if hasattr(win, 'document') and hasattr(win.document, 'ruler'):
        win.document.ruler_show = not win.document.ruler_show
        if hasattr(win.document, 'lexer'):
            win.document.ruler.setfont(win.document.lexer.font)
            a = win.document.lexer.getSyntaxItems()['linenumber']
            win.document.ruler.setbgcolor(a.style.back)
        win.document.ruler.show(win.document.ruler_show)
        win.document.ruler.position(cal_column(win.document))


Mixin.setMixin('mainframe', 'OnViewRuler', OnViewRuler)

#def on_zoom(win, event):
#    factor = win.GetZoom()
#    if hasattr(win, 'lexer'):
#        font = win.lexer.font
#        newfont = wx.Font(font.GetPointSize()+factor, wx.TELETYPE, wx.NORMAL, wx.NORMAL, True)
#        win.ruler.setfont(newfont)
#Mixin.setPlugin('editor', 'on_zoom', on_zoom)
Exemple #37
0
            ])
Mixin.setPlugin('editor', 'other_popup_menu', other_popup_menu)

def OnWeb2pyProjectFunc(win, event):
    _id = event.GetId()
    
    try:
        if _id == win.IDPM_WEB2PY_PROJECT_CONTROLLERS_VIEW:
            OnWeb2pyProjectControllersView(win)
        elif  _id == win.IDPM_WEB2PY_PROJECT_CONTROLLERS_WEB:
            
            OnWeb2pyProjectControllersWeb(win)
    except:
        error.traceback()
        common.showerror(win, tr("There is some wrong as executing the menu."))
Mixin.setMixin('editor', 'OnWeb2pyProjectFunc', OnWeb2pyProjectFunc)

def OnWeb2pyProjectControllersView(win):
    global controller_name
    view = get_view_from_controller(win)
    if view:
        if os.path.exists(view):
            win.mainframe.editctrl.new(view)
            return
        else:
            open(view, 'w').close()
            win.mainframe.editctrl.new(view).SetText("{{extend 'layout.html'}}\n")
            return
    controller = get_controller_from_view(win)
    if  controller:
        doc = win.mainframe.editctrl.new(controller)
Exemple #38
0
            flag = jump_to_file(win, d, f, m)
        elif len(s) > 1:
            text = []
            _mlist = {}
            for i, v in enumerate(s):
                d, f, m = v
                key = str(i + 1) + '|' + d + '|' + os.path.basename(f)
                text.append(key)
                _mlist[key] = (d, f, m)
            win.document.UserListShow(2, " ".join(text))
            flag = True
    if not flag:
        win.document.callplugin('on_jump_definition', win.document, word)


Mixin.setMixin('mainframe', 'OnSearchJumpDef', OnSearchJumpDef)


def on_user_list_selction(win, list_type, text):
    t = list_type
    if t == 2:  #1 is used by input assistant
        if _mlist:
            v = _mlist.get(text, None)
            if v:
                d, f, m = v
                jump_to_file(win, d, f, m)


Mixin.setPlugin('editor', 'on_user_list_selction', on_user_list_selction)

Exemple #39
0
import wx
from modules import Mixin

regex_pagename = tr("Regex")


def createRegexWindow(win):
    if not win.panel.getPage(regex_pagename):
        from mixins import RegexWindow

        page = RegexWindow.RegexWindow(win.panel.createNotebook('bottom'))
        win.panel.addPage('bottom', page, regex_pagename)
    return regex_pagename


Mixin.setMixin('mainframe', 'createRegexWindow', createRegexWindow)


def add_mainframe_menu(menulist):
    menulist.extend([
        (
            'IDM_TOOL',  #parent menu id
            [
                (170, 'IDM_TOOL_REGEX', tr('Live Regular Expression'),
                 wx.ITEM_NORMAL, 'OnToolRegex',
                 tr('Live regular expression searching.')),
            ]),
    ])


Mixin.setPlugin('mainframe', 'add_menu', add_mainframe_menu)
Exemple #40
0
#   UliPad is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
#   $Id: mFormat.py 1457 2006-08-23 02:12:12Z limodou $

import wx.stc
from modules import Mixin

def editor_init(win):
    wx.stc.EVT_STC_STYLENEEDED(win, win.GetId(), win.OnStyleNeeded)
#    wx.EVT_PAINT(win, win.OnStyleNeeded)
Mixin.setPlugin('editor', 'init', editor_init)

def OnStyleNeeded(win, event):
    lexer = getattr(win, 'lexer', None)
    if lexer:
        if lexer.syntaxtype == wx.stc.STC_LEX_CONTAINER:
            lexer.styleneeded(win, event.GetPosition())
Mixin.setMixin('editor', 'OnStyleNeeded', OnStyleNeeded)
Exemple #41
0
    item = dirwin.tree.GetSelection()
    if not item.IsOk(): return
    if 'web2py' in projectname:
        dir = common.getCurrentDir(dirwin.get_node_filename(item))
        basedir = os.path.basename(os.path.dirname(dir))
        if os.path.isdir(dir) and basedir == 'applications':
            menus.extend([ (None,
            [
                (500, '', '-', wx.ITEM_SEPARATOR, None, ''),
                (520, 'IDPM_WEB2PY_SHELL', tr('Start web2py Shell'), wx.ITEM_NORMAL, 'OnWeb2pyShell', ''),
            ]),
        ])
Mixin.setPlugin('dirbrowser', 'other_popup_menu', other_popup_menu)

project_names = ['web2py']
Mixin.setMixin('dirbrowser', 'project_names', project_names)

def set_project(ini, projectnames):
    if 'web2py' in projectnames:
        common.set_acp_highlight(ini, '.html', ['html.acp', 'web2py_html.acp'], 'web2pyview')
        common.set_acp_highlight(ini, '.py', ['web2py_py.acp'], 'python')
Mixin.setPlugin('dirbrowser', 'set_project', set_project)

def remove_project(ini, projectnames):
    if 'web2py' in projectnames:
        common.remove_acp_highlight(ini, '.html', ['html.acp', 'web2py_html.acp'], 'web2pyview')
        common.remove_acp_highlight(ini, '.py', ['web2py_py.acp'], 'python')
Mixin.setPlugin('dirbrowser', 'remove_project', remove_project)

def OnWeb2pyShell(dirwin, event):
    item = dirwin.tree.GetSelection()
Exemple #42
0
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
#   $Id: mSnippets.py,v 1.8 2004/11/27 15:52:08 limodou Exp $

from modules import Mixin
import wx
import images

menulist = [
    ('IDM_WINDOW',
    [
        (190, 'IDM_WINDOW_WIZARD', tr('Wizard Window'), wx.ITEM_CHECK, 'OnWindowWizard', tr('Opens wizard window.'))
    ]),
]
Mixin.setMixin('mainframe', 'menulist', menulist)

popmenulist = [ (None,
    [
        (140, 'IDPM_WIZARDWINDOW', tr('Wizard Window'), wx.ITEM_CHECK, 'OnWizardWindow', tr('Opens wizard window.')),
    ]),
]
Mixin.setMixin('notebook', 'popmenulist', popmenulist)

toollist = [
        (550, 'wizard'),
]
Mixin.setMixin('mainframe', 'toollist', toollist)

_wizard_pagename = tr('Wizard')
        else:
            DDE.run(port=port)


Mixin.setPlugin('app', 'dde', app_init, Mixin.HIGH, 0)


def afterclosewindow(win):
    if win.app.ddeflag:
        DDE.stop()


Mixin.setPlugin('mainframe', 'afterclosewindow', afterclosewindow)


def openfiles(win, files):
    if files:
        doc = None
        firstdoc = None
        for filename in files:
            doc = win.editctrl.new(filename, delay=True)
            if not firstdoc:
                firstdoc = doc
        win.Show()
        win.Raise()
        if firstdoc:
            win.editctrl.switch(firstdoc)


Mixin.setMixin('mainframe', 'openfiles', openfiles)
Exemple #44
0
            win.messagewindow.outputstream = win.messagewindow.process.GetOutputStream(
            )
            win.messagewindow.errorstream = win.messagewindow.process.GetErrorStream(
            )
        except:
            win.messagewindow.process = None
            dlg = wx.MessageDialog(
                win,
                tr("There are some issues with running the program.\nPlease run it in the shell."
                   ), "Error", wx.OK | wx.ICON_EXCLAMATION)
            dlg.ShowModal()
    else:
        wx.Execute(command, wx.EXEC_ASYNC)


Mixin.setMixin('mainframe', 'RunCommand', RunCommand)


def StopCommand(win):
    if win.messagewindow.process:
        wx.Process_Kill(win.messagewindow.pid, wx.SIGKILL)
        win.messagewindow.SetReadOnly(1)
        win.messagewindow.pid = -1
        win.messagewindow.process = None
    if Globals.pref.message_setfocus_back:
        wx.CallAfter(win.document.SetFocus)


Mixin.setMixin('mainframe', 'StopCommand', StopCommand)

Exemple #45
0
                    win.messagewindow.pid = wx.Execute(command, wx.EXEC_ASYNC, win.messagewindow.process)
            else:
                win.messagewindow.pid = wx.Execute(command, wx.EXEC_ASYNC|wx.EXEC_MAKE_GROUP_LEADER, win.messagewindow.process)
            if hasattr(win.messagewindow, 'inputstream') and win.messagewindow.inputstream:
                win.messagewindow.inputstream.close()
            win.messagewindow.inputstream = win.messagewindow.process.GetInputStream()
            win.messagewindow.outputstream = win.messagewindow.process.GetOutputStream()
            win.messagewindow.errorstream = win.messagewindow.process.GetErrorStream()
        except:
            win.messagewindow.process = None
            dlg = wx.MessageDialog(win, tr("There are some issues with running the program.\nPlease run it in the shell.") ,
                "Error", wx.OK | wx.ICON_EXCLAMATION)
            dlg.ShowModal()
    else:
        wx.Execute(command, wx.EXEC_ASYNC)
Mixin.setMixin('mainframe', 'RunCommand', RunCommand)

def StopCommand(win):
    if win.messagewindow.process:
        wx.Process_Kill(win.messagewindow.pid, wx.SIGKILL)
        win.messagewindow.SetReadOnly(1)
        win.messagewindow.pid = -1
        win.messagewindow.process = None
    if Globals.pref.message_setfocus_back:
        wx.CallAfter(win.document.SetFocus)
Mixin.setMixin('mainframe', 'StopCommand', StopCommand)


def OnIdle(win, event):
    if win.process is not None:
        if win.inputstream:
Exemple #46
0
            event.Enable(True)
        else:
            event.Enable(False)
Mixin.setPlugin('mainframe', 'on_update_ui', on_mainframe_updateui)


def OnToolReloadName(win, event):
    reload(ReloadMixins)
    from ReloadMixins import MixinDialog

    dlg = MixinDialog(win)
    answer = dlg.ShowModal()
    dlg.Destroy()


Mixin.setMixin('mainframe', 'OnToolReloadName', OnToolReloadName)


def OnToolreload_mixins(win, event):
    if  win.pref.mixin_reload_mixins_mode:
        mode = "normal mode"
    else:
        mode = "auto reload Mixin plugins mode"
    dlg = wx.MessageDialog(win, 'Are you want to switch to %s?\n this operation will'
            ' take effect after restarting this program!\n'
            'so doing this will close this program!\n'
            'the patch was made by ygao,you can contact me at [email protected]' % mode,
            "reload Mixins", wx.OK | wx.CANCEL | wx.ICON_QUESTION)
    try: res = dlg.ShowModal()
    finally: dlg.Destroy()
    if res == wx.ID_YES:
Exemple #47
0
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
#       $Id$

import wx
from modules import Mixin
from mixins import FiletypeBase


class LuaFiletype(FiletypeBase.FiletypeBase):

    __mixinname__ = 'luafiletype'
    menulist = [
        (None, [
            (890, 'IDM_LUA', 'Lua', wx.ITEM_NORMAL, None, ''),
        ]),
    ]
    toollist = []  #your should not use supperclass's var
    toolbaritems = {}


filetype = [('lua', LuaFiletype)]
Mixin.setMixin('changefiletype', 'filetypes', filetype)
Exemple #48
0
        if hasattr(win, 'document'):
            if hasattr(win.document, 'ruler') and not win.document.multiview:
                event.Enable(True)
                event.Check(win.document.ruler_show)
                return
        event.Enable(False)
Mixin.setPlugin('mainframe', 'on_update_ui', on_update_ui)

def afterinit(win):
    wx.EVT_UPDATE_UI(win, win.IDM_VIEW_RULER, win.OnUpdateUI)
Mixin.setPlugin('mainframe', 'afterinit', afterinit)

def OnViewRuler(win, event):
    if hasattr(win, 'document') and hasattr(win.document, 'ruler'):
        win.document.ruler_show = not win.document.ruler_show
        if hasattr(win.document, 'lexer'):
            win.document.ruler.setfont(win.document.lexer.font)
            a = win.document.lexer.getSyntaxItems()['linenumber']
            win.document.ruler.setbgcolor(a.style.back)
        win.document.ruler.show(win.document.ruler_show)
        win.document.ruler.position(cal_column(win.document))
Mixin.setMixin('mainframe', 'OnViewRuler', OnViewRuler)

#def on_zoom(win, event):
#    factor = win.GetZoom()
#    if hasattr(win, 'lexer'):
#        font = win.lexer.font
#        newfont = wx.Font(font.GetPointSize()+factor, wx.TELETYPE, wx.NORMAL, wx.NORMAL, True)
#        win.ruler.setfont(newfont)
#Mixin.setPlugin('editor', 'on_zoom', on_zoom)

def init(pref):
    pref.lua_classbrowser_show = False
    pref.lua_classbrowser_refresh_as_save = True


Mixin.setPlugin('preference', 'init', init)

preflist = [
    ('Lua', 100, 'check', 'lua_classbrowser_show',
     tr('Show class browser window as open lua source file'), None),
    ('Lua', 105, 'check', 'lua_classbrowser_show',
     tr('Refresh class browser window as saved lua source file'), None),
]
Mixin.setMixin('preference', 'preflist', preflist)

menulist = [
    (
        'IDM_LUA',  #parent menu id
        [
            (100, 'IDM_LUA_CLASSBROWSER', tr('Class Browser'), wx.ITEM_CHECK,
             'OnLuaClassBrowser', tr('Show lua class browser window')),
            (110, 'IDM_LUA_CLASSBROWSER_REFRESH', tr('Class Browser Refresh'),
             wx.ITEM_NORMAL, 'OnLuaClassBrowserRefresh',
             tr('Refresh lua class browser window')),
        ]),
]
Mixin.setMixin('luafiletype', 'menulist', menulist)

    pref.lua_show_args = False
    pref.lua_save_before_run = False
    pref.lua_default_paramters = {}
    for i in s:
        pref.lua_default_paramters[i[0]] = '-e "io.stdout:setvbuf \'no\'"'


Mixin.setPlugin('preference', 'init', pref_init)


def OnSetLuaInterpreter(win, event):
    dlg = LuaInterpreterDialog(win, win.pref)
    dlg.ShowModal()


Mixin.setMixin('prefdialog', 'OnSetLuaInterpreter', OnSetLuaInterpreter)


def add_pref(preflist):
    preflist.extend([
        ('Lua', 150, 'button', 'lua_interpreter',
         tr('Setup Lua interpreter...'), 'OnSetLuaInterpreter'),
        ('Lua', 155, 'check', 'lua_show_args',
         tr('Show the Select Arguments dialog at Lua program run'), None),
        ('Lua', 156, 'check', 'lua_save_before_run',
         tr('Save the modified document at Lua program run'), None),
    ])


Mixin.setPlugin('preference', 'add_pref', add_pref)
Exemple #51
0
menulist = [
    (None, [
        (850, 'IDM_MUSIC', tr('Music'), wx.ITEM_NORMAL, None, ''),
    ]),
    ('IDM_MUSIC', [
        (210, 'IDM_MUSIC_PLAY', tr('Music Play'), wx.ITEM_NORMAL,
         'OnMusicPlay', tr('Music Open Window.')),
        (211, 'IDM_MUSIC_STOP', tr('Music Stop'), wx.ITEM_NORMAL,
         'OnMusicStop', tr('Music Stop.')),
        (212, 'IDM_MUSIC_PAUSE', tr('Music Pause'), wx.ITEM_NORMAL,
         'OnMusicPause', tr('Music Pause.')),
        (212, 'IDM_MUSIC_VOLUME', tr('Music Volume'), wx.ITEM_NORMAL,
         'OnMusicVolume', tr('Music Volume.')),
    ]),
]
Mixin.setMixin('mainframe', 'menulist', menulist)

toollist = [
    (2201, 'musicplay'),
    (2202, 'musicstop'),
    (2203, 'musicpause'),
    (2204, 'musicvolume'),
    (2300, '|'),
]
Mixin.setMixin('mainframe', 'toollist', toollist)

toolbaritems = {
    'musicplay':
    (wx.ITEM_NORMAL, 'IDM_MUSIC_PLAY', images.getMusicplayBitmap(),
     tr('Music Play'), tr('Music Open Window.'), 'OnMusicPlay'),
    'musicstop':
Exemple #52
0
            (150, 'IDM_TOOL_MEMO', tr('Easy Memo') + u'\tF12', wx.ITEM_CHECK, 'OnToolMemo', tr('Shows the window Easy Memo for writing notes.')),
        ]),
    ])
Mixin.setPlugin('mainframe', 'add_menu', add_mainframe_menu)

def OnToolMemo(win, event):
    if win.memo_win:
        win.memo_win.Close()
        win.memo_win = None
    else:
        import Pad
        from modules import Globals
        pad = Pad.PAD(win, os.path.join(Globals.userpath, common.get_config_file_obj().default.get('memo', 'memo.txt')), tr('Easy Memo'))
        pad.Show()
        win.memo_win = pad
Mixin.setMixin('mainframe', 'OnToolMemo', OnToolMemo)

def add_tool_list(toollist, toolbaritems):
    toollist.extend([
        (600, 'memo'),
    ])

    #order, IDname, imagefile, short text, long text, func
    toolbaritems.update({
        'memo':(wx.ITEM_CHECK, 'IDM_TOOL_MEMO', 'images/memo.gif', tr('Open Easy Memo Window'), tr('Show Easy Memo windows, and you can write down everything what you want.'), 'OnToolMemo'),
    })
Mixin.setPlugin('mainframe', 'add_tool_list', add_tool_list)

def afterinit(win):
    wx.EVT_UPDATE_UI(win, win.IDM_TOOL_MEMO, win.OnUpdateUI)
Mixin.setPlugin('mainframe', 'afterinit', afterinit)
Exemple #53
0
                (260, 'IDPM_CHANGE_ENCODING', tr('Change Encoding...'),
                 wx.ITEM_NORMAL, 'OnEditorDocumentChangeEncoding',
                 tr("Changes the current encoding of the document.")),
            ]),
    ])


Mixin.setPlugin('editor', 'add_menu', add_editor_menu)


def OnDocumentChangeEncoding(win, event):
    ret = _getencoding()
    if ret:
        win.document.locale = ret
        common.set_encoding(win.document.locale)
        win.document.modified = True
        wx.CallAfter(win.editctrl.showTitle, win.document)
        wx.CallAfter(win.editctrl.showPageTitle, win.document)


Mixin.setMixin('mainframe', 'OnDocumentChangeEncoding',
               OnDocumentChangeEncoding)


def OnEditorDocumentChangeEncoding(win, event):
    win.mainframe.OnDocumentChangeEncoding(None)


Mixin.setMixin('editor', 'OnEditorDocumentChangeEncoding',
               OnEditorDocumentChangeEncoding)
Exemple #54
0
#
#       $Id: BlogEdit.py 42 2005-09-28 05:19:21Z limodou $

from modules import Mixin
import os.path
import wx
import images
from modules.Debug import error
from modules import common

menulist = [ ('IDM_WINDOW',
        [
                (170, 'IDM_WINDOW_BLOG', tr('Open Blog Window'), wx.ITEM_NORMAL, 'OnWindowBlog', tr('Opens blog window.'))
        ]),
]
Mixin.setMixin('mainframe', 'menulist', menulist)

popmenulist = [ (None,
        [
                (150, 'IDPM_BLOGWINDOW', tr('Open Blog Window'), wx.ITEM_NORMAL, 'OnBlogWindow', tr('Opens blog window.')),
        ]),
]
Mixin.setMixin('notebook', 'popmenulist', popmenulist)

def createBlogWindow(win):
    page = win.panel.getPage('Blog')
    if not page:
        from BlogManageWindow import BlogManageWindow

        page = BlogManageWindow(win.panel.createNotebook('bottom'), win)
        win.panel.addPage('bottom', page, 'Blog')
Exemple #55
0
def add_editor_menu(popmenulist):
    popmenulist.extend([ (None, #parent menu id
        [
            (245, 'IDPM_COLUMN_MODE', tr('Column Mode') +'\tAlt+C', wx.ITEM_CHECK, 'OnColumnMode', tr('Marks Column Mode region.')),
        ]),
    ])
Mixin.setPlugin('editor', 'add_menu', add_editor_menu)

def OnColumnMode(win, event):
    if win.column_mode:
        win.ClearColumnModeRegion()
        win.column_mode = False
    else:
        win.column_mode = True
        auto_column_mode(win)
Mixin.setMixin('editor', 'OnColumnMode', OnColumnMode)

def define_column_mode_region(win, startline, endline):
    win.columnmode_lines = startline, endline
    i = startline
    while i <= endline:
        win.MarkerAdd(i, win.marker_columnmode)
        i += 1
    pos = win.GetCurrentPos()
    win.SetSelection(pos, pos)

def selectmultiline(win):
    start, end = win.GetSelection()
    startline = win.LineFromPosition(start)
    endline = win.LineFromPosition(end)
    return start != end