qscilexerdiff.cpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. // This module implements the QsciLexerDiff class.
  2. //
  3. // Copyright (c) 2017 Riverbank Computing Limited <info@riverbankcomputing.com>
  4. //
  5. // This file is part of QScintilla.
  6. //
  7. // This file may be used under the terms of the GNU General Public License
  8. // version 3.0 as published by the Free Software Foundation and appearing in
  9. // the file LICENSE included in the packaging of this file. Please review the
  10. // following information to ensure the GNU General Public License version 3.0
  11. // requirements will be met: http://www.gnu.org/copyleft/gpl.html.
  12. //
  13. // If you do not wish to use this file under the terms of the GPL version 3.0
  14. // then you may purchase a commercial license. For more information contact
  15. // info@riverbankcomputing.com.
  16. //
  17. // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  18. // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  19. #include "Qsci/qscilexerdiff.h"
  20. #include <qcolor.h>
  21. #include <qfont.h>
  22. #include <qsettings.h>
  23. // The ctor.
  24. QsciLexerDiff::QsciLexerDiff(QObject *parent)
  25. : QsciLexer(parent)
  26. {
  27. }
  28. // The dtor.
  29. QsciLexerDiff::~QsciLexerDiff()
  30. {
  31. }
  32. // Returns the language name.
  33. const char *QsciLexerDiff::language() const
  34. {
  35. return "Diff";
  36. }
  37. // Returns the lexer name.
  38. const char *QsciLexerDiff::lexer() const
  39. {
  40. return "diff";
  41. }
  42. // Return the string of characters that comprise a word.
  43. const char *QsciLexerDiff::wordCharacters() const
  44. {
  45. return "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-";
  46. }
  47. // Returns the foreground colour of the text for a style.
  48. QColor QsciLexerDiff::defaultColor(int style) const
  49. {
  50. switch (style)
  51. {
  52. case Default:
  53. return QColor(0x00,0x00,0x00);
  54. case Comment:
  55. return QColor(0x00,0x7f,0x00);
  56. case Command:
  57. return QColor(0x7f,0x7f,0x00);
  58. case Header:
  59. return QColor(0x7f,0x00,0x00);
  60. case Position:
  61. return QColor(0x7f,0x00,0x7f);
  62. case LineRemoved:
  63. return QColor(0x00,0x7f,0x7f);
  64. case LineAdded:
  65. return QColor(0x00,0x00,0x7f);
  66. case LineChanged:
  67. return QColor(0x7f,0x7f,0x7f);
  68. }
  69. return QsciLexer::defaultColor(style);
  70. }
  71. // Returns the user name of a style.
  72. QString QsciLexerDiff::description(int style) const
  73. {
  74. switch (style)
  75. {
  76. case Default:
  77. return tr("Default");
  78. case Comment:
  79. return tr("Comment");
  80. case Command:
  81. return tr("Command");
  82. case Header:
  83. return tr("Header");
  84. case Position:
  85. return tr("Position");
  86. case LineRemoved:
  87. return tr("Removed line");
  88. case LineAdded:
  89. return tr("Added line");
  90. case LineChanged:
  91. return tr("Changed line");
  92. }
  93. return QString();
  94. }