本文整理汇总了Python中tweelexer.TweeLexer.initStyles方法的典型用法代码示例。如果您正苦于以下问题:Python TweeLexer.initStyles方法的具体用法?Python TweeLexer.initStyles怎么用?Python TweeLexer.initStyles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tweelexer.TweeLexer
的用法示例。
在下文中一共展示了TweeLexer.initStyles方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PassageFrame
# 需要导入模块: from tweelexer import TweeLexer [as 别名]
# 或者: from tweelexer.TweeLexer import initStyles [as 别名]
#.........这里部分代码省略.........
if len(selection) < 25:
editSelected.SetText('Create &Link Named "' + selection + '"\tCtrl-L')
else:
editSelected.SetText('Create &Link From Selected Text\tCtrl-L')
else:
if len(selection) < 25:
editSelected.SetText('&Edit Passage Named "' + self.stripCrud(selection) + '"\tCtrl-L')
else:
editSelected.SetText('&Edit Passage From Selected Text\tCtrl-L')
editSelected.Enable(True)
else:
editSelected.SetText('Create &Link From Selected Text\tCtrl-L')
editSelected.Enable(False)
def updateSubmenus (self, event = None):
"""
Updates our passage menus. This should be called sparingly, i.e. not during
a UI update event, as it is doing a bunch of removing and adding of items.
"""
# separate outgoing and broken links
outgoing = []
incoming = []
broken = []
for link in self.widget.passage.links():
found = False
for widget in self.widget.parent.widgets:
if widget.passage.title == link:
outgoing.append(link)
found = True
break
if not found: broken.append(link)
# incoming links
for widget in self.widget.parent.widgets:
if self.widget.passage.title in widget.passage.links():
incoming.append(widget.passage.title)
# repopulate the menus
def populate (menu, links):
for item in menu.GetMenuItems():
menu.DeleteItem(item)
if len(links):
for link in links:
item = menu.Append(-1, link)
self.Bind(wx.EVT_MENU, self.openOtherEditor, item)
else:
item = menu.Append(wx.ID_ANY, '(None)')
item.Enable(False)
outTitle = 'Outgoing Links'
if len(outgoing) > 0: outTitle += ' (' + str(len(outgoing)) + ')'
self.outLinksMenuTitle.SetText(outTitle)
populate(self.outLinksMenu, outgoing)
inTitle = 'Incoming Links'
if len(incoming) > 0: inTitle += ' (' + str(len(incoming)) + ')'
self.inLinksMenuTitle.SetText(inTitle)
populate(self.inLinksMenu, incoming)
brokenTitle = 'Broken Links'
if len(broken) > 0: brokenTitle += ' (' + str(len(broken)) + ')'
self.brokenLinksMenuTitle.SetText(brokenTitle)
populate(self.brokenLinksMenu, broken)
def applyPrefs (self):
"""Applies user prefs to this frame."""
bodyFont = wx.Font(self.app.config.ReadInt('windowedFontSize'), wx.MODERN, wx.NORMAL, \
wx.NORMAL, False, self.app.config.Read('windowedFontFace'))
defaultStyle = self.bodyInput.GetStyleAt(0)
self.bodyInput.StyleSetFont(defaultStyle, bodyFont)
if hasattr(self, 'lexer'): self.lexer.initStyles()
def __repr__ (self):
return "<PassageFrame '" + self.widget.passage.title + "'>"
# timing constants
PARENT_SYNC_DELAY = 0.5
# control constants
DEFAULT_SIZE = (550, 600)
TITLE_LABEL = 'Title'
TAGS_LABEL = 'Tags (separate with spaces)'
# menu constants (not defined by wx)
EDIT_FIND_NEXT = 2001
PASSAGE_FULLSCREEN = 1001
PASSAGE_EDIT_SELECTION = 1002
PASSAGE_REBUILD_STORY = 1003
示例2: PassageFrame
# 需要导入模块: from tweelexer import TweeLexer [as 别名]
# 或者: from tweelexer.TweeLexer import initStyles [as 别名]
#.........这里部分代码省略.........
body.StyleSetForeground(wx.stc.STC_CSS_PSEUDOCLASS, TweeLexer.EXTERNAL_COLOR);
body.StyleSetForeground(wx.stc.STC_CSS_UNKNOWN_PSEUDOCLASS, TweeLexer.EXTERNAL_COLOR);
body.StyleSetForeground(wx.stc.STC_CSS_DIRECTIVE, TweeLexer.PARAM_VAR_COLOR);
body.StyleSetForeground(wx.stc.STC_CSS_UNKNOWN_IDENTIFIER, TweeLexer.GOOD_LINK_COLOR);
for i in [wx.stc.STC_CSS_CLASS, wx.stc.STC_CSS_ID, wx.stc.STC_CSS_TAG,
wx.stc.STC_CSS_PSEUDOCLASS, wx.stc.STC_CSS_OPERATOR, wx.stc.STC_CSS_IMPORTANT,
wx.stc.STC_CSS_UNKNOWN_PSEUDOCLASS, wx.stc.STC_CSS_DIRECTIVE]:
body.StyleSetBold(i, True)
def setLexer(self):
"""
Sets our custom lexer for the body input so long as the passage
is part of the story.
"""
oldLexing = self.usingLexer
if self.widget.passage.isStylesheet():
if oldLexing != self.LEXER_CSS:
self.setCodeLexer(css = True)
self.usingLexer = self.LEXER_CSS
self.bodyInput.SetLexer(wx.stc.STC_LEX_CSS)
elif not self.widget.passage.isStoryText() and not self.widget.passage.isAnnotation():
if oldLexing != self.LEXER_NONE:
self.usingLexer = self.LEXER_NONE
self.setCodeLexer()
self.bodyInput.SetLexer(wx.stc.STC_LEX_NULL)
elif oldLexing != self.LEXER_NORMAL:
self.usingLexer = self.LEXER_NORMAL
self.bodyInput.SetLexer(wx.stc.STC_LEX_CONTAINER)
if oldLexing != self.usingLexer:
if self.usingLexer == self.LEXER_NORMAL:
self.lexer.initStyles()
self.bodyInput.Colourise(0, len(self.bodyInput.GetText()))
def updateUI(self, event):
"""Updates menus."""
# basic edit menus
undoItem = self.menus.FindItemById(wx.ID_UNDO)
undoItem.Enable(self.bodyInput.CanUndo())
redoItem = self.menus.FindItemById(wx.ID_REDO)
redoItem.Enable(self.bodyInput.CanRedo())
hasSelection = self.bodyInput.GetSelectedText() != ''
cutItem = self.menus.FindItemById(wx.ID_CUT)
cutItem.Enable(hasSelection)
copyItem = self.menus.FindItemById(wx.ID_COPY)
copyItem.Enable(hasSelection)
pasteItem = self.menus.FindItemById(wx.ID_PASTE)
pasteItem.Enable(self.bodyInput.CanPaste())
# find/replace
findNextItem = self.menus.FindItemById(PassageFrame.EDIT_FIND_NEXT)
findNextItem.Enable(self.lastFindRegexp != None)
# link selected text menu item
editSelected = self.menus.FindItemById(PassageFrame.PASSAGE_EDIT_SELECTION)
selection = self.bodyInput.GetSelectedText()