fb2code.cpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #include "fb2code.h"
  2. /////////////////////////////////////////////////////////////////////////////
  3. //
  4. // http://qtcoder.blogspot.com/2010/10/qscintills.html
  5. // http://www.riverbankcomputing.co.uk/static/Docs/QScintilla2/classQsciScintilla.html
  6. //
  7. /////////////////////////////////////////////////////////////////////////////
  8. #include <Qsci/qscilexerxml.h>
  9. Fb2Scintilla::Fb2Scintilla(QWidget *parent) :
  10. QsciScintilla(parent)
  11. {
  12. zoomTo(1);
  13. setUtf8(true);
  14. setCaretLineVisible(true);
  15. setCaretLineBackgroundColor(QColor("gainsboro"));
  16. setWrapMode(QsciScintilla::WrapWord);
  17. setEolMode(QsciScintilla::EolWindows);
  18. setAutoIndent(true);
  19. setIndentationGuides(true);
  20. setAutoCompletionSource(QsciScintilla::AcsAll);
  21. setAutoCompletionCaseSensitivity(true);
  22. setAutoCompletionReplaceWord(true);
  23. setAutoCompletionShowSingle(true);
  24. setAutoCompletionThreshold(2);
  25. setMarginsBackgroundColor(QColor("gainsboro"));
  26. setMarginLineNumbers(0, true);
  27. setFolding(QsciScintilla::BoxedFoldStyle, 1);
  28. setBraceMatching(QsciScintilla::SloppyBraceMatch);
  29. setMatchedBraceBackgroundColor(Qt::yellow);
  30. setUnmatchedBraceForegroundColor(Qt::blue);
  31. QFont font("Courier", 10);
  32. font.setStyleHint(QFont::TypeWriter);
  33. QsciLexerXML * lexer = new QsciLexerXML;
  34. lexer->setFont(font, -1);
  35. setBraceMatching(QsciScintilla::SloppyBraceMatch);
  36. setLexer(lexer);
  37. connect(this, SIGNAL(linesChanged()), SLOT(linesChanged()));
  38. }
  39. void Fb2Scintilla::linesChanged()
  40. {
  41. QString width = QString().setNum(lines() * 10);
  42. setMarginWidth(0, width);
  43. }