本文整理汇总了Python中textformats.formatData函数的典型用法代码示例。如果您正苦于以下问题:Python formatData函数的具体用法?Python formatData怎么用?Python formatData使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了formatData函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: readSettings
def readSettings(self):
data = textformats.formatData('editor')
self.searchEntry.setFont(data.font)
self.replaceEntry.setFont(data.font)
p = data.palette()
self.searchEntry.setPalette(p)
self.replaceEntry.setPalette(p)
开发者ID:WedgeLeft,项目名称:frescobaldi,代码行数:7,代码来源:search.py
示例2: show
def show(cursor, pos=None, num_lines=6):
"""Displays a tooltip showing part of the cursor's Document.
If the cursor has a selection, those blocks are displayed.
Otherwise, num_lines lines are displayed.
If pos is not given, the global mouse position is used.
"""
block = cursor.document().findBlock(cursor.selectionStart())
c2 = QTextCursor(block)
if cursor.hasSelection():
c2.setPosition(cursor.selectionEnd(), QTextCursor.KeepAnchor)
c2.movePosition(QTextCursor.EndOfBlock, QTextCursor.KeepAnchor)
else:
c2.movePosition(QTextCursor.NextBlock, QTextCursor.KeepAnchor, num_lines)
data = textformats.formatData('editor')
doc = QTextDocument()
font = QFont(data.font)
font.setPointSizeF(font.pointSizeF() * .8)
doc.setDefaultFont(font)
doc.setPlainText(c2.selection().toPlainText())
if metainfo.info(cursor.document()).highlighting:
highlighter.highlight(doc, state=tokeniter.state(block))
size = doc.size().toSize() + QSize(8, -4)
pix = QPixmap(size)
pix.fill(data.baseColors['background'])
doc.drawContents(QPainter(pix))
label = QLabel()
label.setPixmap(pix)
label.setStyleSheet("QLabel { border: 1px solid #777; }")
label.resize(size)
widgets.customtooltip.show(label, pos)
开发者ID:WedgeLeft,项目名称:frescobaldi,代码行数:35,代码来源:documenttooltip.py
示例3: pixmap
def pixmap(cursor, num_lines=6, scale=0.8):
"""Return a QPixmap displaying the selected lines of the document.
If the cursor has no selection, num_lines are drawn.
By default the text is drawn 0.8 * the normal font size. You can change
that by supplying the scale parameter.
"""
block = cursor.document().findBlock(cursor.selectionStart())
c2 = QTextCursor(block)
if cursor.hasSelection():
c2.setPosition(cursor.selectionEnd(), QTextCursor.KeepAnchor)
c2.movePosition(QTextCursor.EndOfBlock, QTextCursor.KeepAnchor)
else:
c2.movePosition(QTextCursor.NextBlock, QTextCursor.KeepAnchor, num_lines)
data = textformats.formatData('editor')
doc = QTextDocument()
font = QFont(data.font)
font.setPointSizeF(font.pointSizeF() * scale)
doc.setDefaultFont(font)
doc.setPlainText(c2.selection().toPlainText())
if metainfo.info(cursor.document()).highlighting:
highlighter.highlight(doc, state=tokeniter.state(block))
size = doc.size().toSize() + QSize(8, -4)
pix = QPixmap(size)
pix.fill(data.baseColors['background'])
doc.drawContents(QPainter(pix))
return pix
开发者ID:19joho66,项目名称:frescobaldi,代码行数:30,代码来源:documenttooltip.py
示例4: html
def html(cursor, scheme='editor', inline=False, number_lines=False, full_html=True,
wrap_tag="pre", wrap_attrib="id", wrap_attrib_name="document"):
"""Return a HTML document with the syntax-highlighted region.
The tokens are marked with <span> tags. The cursor is a
ly.document.Cursor instance. The specified text formats scheme is used
(by default 'editor'). If inline is True, the span tags have inline
style attributes. If inline is False, the span tags have class
attributes and a stylesheet is included.
Set number_lines to True to add line numbers.
"""
data = textformats.formatData(scheme) # the current highlighting scheme
w = ly.colorize.HtmlWriter()
w.set_wrapper_tag(wrap_tag)
w.set_wrapper_attribute(wrap_attrib)
w.document_id = wrap_attrib_name
w.inline_style = inline
w.number_lines = number_lines
w.full_html = full_html
w.fgcolor = data.baseColors['text'].name()
w.bgcolor = data.baseColors['background'].name()
w.css_scheme = data.css_scheme()
return w.html(cursor)
开发者ID:EdwardBetts,项目名称:frescobaldi,代码行数:25,代码来源:highlight2html.py
示例5: highlight_mapping
def highlight_mapping():
"""Return the global Mapping instance that maps token class to QTextCharFormat."""
global _highlight_mapping
try:
return _highlight_mapping
except NameError:
_highlight_mapping = mapping(textformats.formatData("editor"))
return _highlight_mapping
开发者ID:brownian,项目名称:frescobaldi,代码行数:8,代码来源:highlighter.py
示例6: __init__
def __init__(self, data=None, inline_style=False):
"""Initialize the HtmlHighlighter with a TextFormatData instance.
If none is given, the textformats.textFormat('editor') is used.
"""
self.inline_style = inline_style
self.setFormatData(data or textformats.formatData('editor'))
开发者ID:satoshi-porin,项目名称:frescobaldi,代码行数:8,代码来源:highlight2html.py
示例7: htmlCopy
def htmlCopy(document, type='editor'):
"""Returns a new QTextDocument with highlighting set as HTML textcharformats."""
data = textformats.formatData(type)
doc = QTextDocument()
doc.setDefaultFont(data.font)
doc.setPlainText(document.toPlainText())
highlight(doc, HighlightFormats(data), ly.lex.state(documentinfo.mode(document)))
return doc
开发者ID:mbsrz1972,项目名称:frescobaldi,代码行数:8,代码来源:highlighter.py
示例8: highlightFormats
def highlightFormats():
"""Return the global HighlightFormats instance."""
global _highlightFormats
try:
return _highlightFormats
except NameError:
_highlightFormats = HighlightFormats(textformats.formatData('editor'))
return _highlightFormats
开发者ID:leeavital,项目名称:frescobaldi,代码行数:8,代码来源:highlighter.py
示例9: readSettings
def readSettings(self):
"""Reads the settings from the user's preferences."""
# background and highlight colors of music view
colors = textformats.formatData('editor').baseColors
self._highlightMusicFormat.setColor(colors['musichighlight'])
color = colors['selectionbackground']
color.setAlpha(128)
self._highlightFormat.setBackground(color)
开发者ID:AlexSchr,项目名称:frescobaldi,代码行数:8,代码来源:popplerwidget.py
示例10: readSettings
def readSettings(self):
"""Read preferences and adjust to those.
Called on init and when app.settingsChanged fires.
Sets colors, font and tab width from the preferences.
"""
data = textformats.formatData('editor')
self.setFont(data.font)
self.setPalette(data.palette())
self.setTabWidth()
开发者ID:oleastre,项目名称:frescobaldi,代码行数:11,代码来源:view.py
示例11: readSettings
def readSettings(self):
s = QSettings()
s.beginGroup("documentation")
ws = self.webview.page().settings()
family = s.value("fontfamily", self.font().family(), str)
size = s.value("fontsize", 16, int)
ws.setFontFamily(QWebSettings.StandardFont, family)
ws.setFontSize(QWebSettings.DefaultFontSize, size)
fixed = textformats.formatData('editor').font
ws.setFontFamily(QWebSettings.FixedFont, fixed.family())
ws.setFontSize(QWebSettings.DefaultFixedFontSize, fixed.pointSizeF() * 96 / 72)
开发者ID:AlexSchr,项目名称:frescobaldi,代码行数:11,代码来源:browser.py
示例12: colorize
def colorize(text, state=None):
"""Converts the text to HTML using the specified or guessed state."""
if state is None:
state = ly.lex.guessState(text)
data = textformats.formatData('editor')
h = highlight2html.HtmlHighlighter(data, inline_style=True)
result = [
'<pre style="color: {0}; background: {1}; font-family: {2}">'.format(
data.baseColors['text'].name(),
data.baseColors['background'].name(),
data.font.family())]
result.extend(map(h.html_for_token, state.tokens(text)))
result.append('</pre>')
return ''.join(result)
开发者ID:satoshi-porin,项目名称:frescobaldi,代码行数:16,代码来源:colorize.py
示例13: html_copy
def html_copy(cursor, scheme="editor", number_lines=False):
"""Return a new QTextDocument with highlighting set as HTML textcharformats.
The cursor is a cursor of a document.Document instance. If the cursor
has a selection, only the selection is put in the new document.
If number_lines is True, line numbers are added.
"""
data = textformats.formatData(scheme)
doc = QTextDocument()
doc.setDefaultFont(data.font)
doc.setPlainText(cursor.document().toPlainText())
if metainfo.info(cursor.document()).highlighting:
highlight(doc, mapping(data), ly.lex.state(documentinfo.mode(cursor.document())))
if cursor.hasSelection():
# cut out not selected text
start, end = cursor.selectionStart(), cursor.selectionEnd()
cur1 = QTextCursor(doc)
cur1.setPosition(start, QTextCursor.KeepAnchor)
cur2 = QTextCursor(doc)
cur2.setPosition(end)
cur2.movePosition(QTextCursor.End, QTextCursor.KeepAnchor)
cur2.removeSelectedText()
cur1.removeSelectedText()
if number_lines:
c = QTextCursor(doc)
f = QTextCharFormat()
f.setBackground(QColor("#eeeeee"))
if cursor.hasSelection():
num = cursor.document().findBlock(cursor.selectionStart()).blockNumber() + 1
last = cursor.document().findBlock(cursor.selectionEnd())
else:
num = 1
last = cursor.document().lastBlock()
lastnum = last.blockNumber() + 1
padding = len(format(lastnum))
block = doc.firstBlock()
while block.isValid():
c.setPosition(block.position())
c.setCharFormat(f)
c.insertText("{0:>{1}d} ".format(num, padding))
block = block.next()
num += 1
return doc
开发者ID:brownian,项目名称:frescobaldi,代码行数:45,代码来源:highlighter.py
示例14: colorize
def colorize(text, state=None):
"""Converts the text to HTML using the specified or guessed state."""
if state is None:
state = ly.lex.guessState(text)
result = []
h = highlighter.highlightFormats()
d = textformats.formatData('editor')
result.append('<pre style="color: {0}; background: {1}; '
'font-family: "{2}"; font-size: {3}pt;">'.format(
d.baseColors['text'].name(), d.baseColors['background'].name(),
d.font.family(), d.font.pointSizeF()))
for t in state.tokens(text):
f = h.format(t)
if f:
s = style(f)
if s:
result.append('<span style="{0}">{1}</span>'.format(s, escape(t)))
continue
result.append(escape(t))
result.append('</pre>')
return ''.join(result)
开发者ID:aspiers,项目名称:frescobaldi,代码行数:21,代码来源:colorize.py
示例15: readSettings
def readSettings(self):
font = textformats.formatData('editor').font
self.diff.setFont(font)
diffFont = QFont("Monospace")
diffFont.setStyleHint(QFont.TypeWriter)
self.uni_diff.setFont(diffFont)
开发者ID:AlexSchr,项目名称:frescobaldi,代码行数:6,代码来源:convert_ly.py
示例16: readSettings
def readSettings(self):
"""Reads the settings from the user's preferences."""
color = textformats.formatData("editor").baseColors["selectionbackground"]
color.setAlpha(128)
self._highlightFormat.setBackground(color)
开发者ID:wbsoft,项目名称:frescobaldi,代码行数:5,代码来源:view.py
示例17: readSettings
def readSettings(self):
data = textformats.formatData('editor')
self.textbrowser.setPalette(data.palette())
self.textbrowser.setFont(data.font)
highlighter.highlight(self.textbrowser.document())
开发者ID:AlexSchr,项目名称:frescobaldi,代码行数:5,代码来源:sourceviewer.py
示例18: readSettings
def readSettings(self):
font = textformats.formatData('editor').font
self.diff.setFont(font)
开发者ID:marnen,项目名称:frescobaldi,代码行数:3,代码来源:convert_ly.py
示例19: readSettings
def readSettings(self):
self.format = QTextCharFormat()
self.format.setBackground(textformats.formatData('editor').baseColors['match'])
开发者ID:willingc,项目名称:frescobaldi,代码行数:3,代码来源:edit.py
示例20: readSettings
def readSettings(self):
self._styles = textformats.formatData('editor').defaultStyles
开发者ID:mamoch,项目名称:frescobaldi,代码行数:2,代码来源:highlight.py
注:本文中的textformats.formatData函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论