MCPcopy Create free account
hub / github.com/baldurk/renderdoc / CommentView

Method CommentView

qrenderdoc/Windows/CommentView.cpp:36–122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34static const sptr_t link_style = 100;
35
36CommentView::CommentView(ICaptureContext &ctx, QWidget *parent)
37 : QFrame(parent), ui(new Ui::CommentView), m_Ctx(ctx)
38{
39 ui->setupUi(this);
40
41 m_commentsEditor = new ScintillaEdit(this);
42
43 m_commentsEditor->styleSetFont(STYLE_DEFAULT, Formatter::FixedFont().family().toUtf8().data());
44 m_commentsEditor->setTabWidth(4);
45
46 m_commentsEditor->setWrapMode(SC_WRAP_WORD);
47 m_commentsEditor->setWrapVisualFlags(SC_WRAPVISUALFLAG_MARGIN);
48
49 m_commentsEditor->setMarginWidthN(0, 30.0);
50
51 ConfigureSyntax(m_commentsEditor, SCLEX_NULL);
52
53 QObject::connect(
54 m_commentsEditor, &ScintillaEdit::modified,
55 [this](int type, int position, int length, int, const QByteArray &, int, int, int) {
56 // if there has been a change, restyle the region around the modification. We can't use just
57 // word boundaries so search back to the last whitespace character - this means we will
58 // restyle at most a line, likely much less.
59 if(type & (SC_MOD_INSERTTEXT | SC_MOD_DELETETEXT))
60 {
61 int start = m_commentsEditor->wordStartPosition(position, false);
62 while(!isspace(m_commentsEditor->charAt(start)) && start > 0)
63 start--;
64 int end = m_commentsEditor->wordEndPosition(position + length, false);
65 while(!isspace(m_commentsEditor->charAt(end)) && end < m_commentsEditor->length())
66 end++;
67
68 if(start < 0)
69 start = 0;
70 if(end < 0 || end > m_commentsEditor->length())
71 end = m_commentsEditor->length();
72
73 Restyle(start, end);
74 }
75
76 if(m_ignoreModifications)
77 return;
78
79 if(type & (SC_MOD_INSERTTEXT | SC_MOD_DELETETEXT | SC_MOD_BEFOREINSERT | SC_MOD_BEFOREDELETE))
80 {
81 QString text =
82 QString::fromUtf8(m_commentsEditor->getText(m_commentsEditor->textLength() + 1));
83 text.remove(QLatin1Char('\r'));
84 m_ignoreModifications = true;
85 m_Ctx.SetNotes(lit("comments"), text);
86 m_ignoreModifications = false;
87 }
88 });
89
90 m_commentsEditor->styleSetHotSpot(link_style, true);
91 QColor back = palette().base().color();
92 QColor fore = palette().link().color();
93 m_commentsEditor->styleSetBack(link_style, SCINTILLA_COLOUR(back.red(), back.green(), back.blue()));

Callers

nothing calls this directly

Calls 15

ConfigureSyntaxFunction · 0.85
connectFunction · 0.85
QLatin1CharClass · 0.85
fromLatin1Function · 0.85
styleSetFontMethod · 0.80
toUtf8Method · 0.80
setTabWidthMethod · 0.80
setWrapModeMethod · 0.80
setWrapVisualFlagsMethod · 0.80
setMarginWidthNMethod · 0.80
wordStartPositionMethod · 0.80
charAtMethod · 0.80

Tested by

no test coverage detected