qscilexermakefile.cpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. // This module implements the QsciLexerMakefile 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/qscilexermakefile.h"
  20. #include <qcolor.h>
  21. #include <qfont.h>
  22. // The ctor.
  23. QsciLexerMakefile::QsciLexerMakefile(QObject *parent)
  24. : QsciLexer(parent)
  25. {
  26. }
  27. // The dtor.
  28. QsciLexerMakefile::~QsciLexerMakefile()
  29. {
  30. }
  31. // Returns the language name.
  32. const char *QsciLexerMakefile::language() const
  33. {
  34. return "Makefile";
  35. }
  36. // Returns the lexer name.
  37. const char *QsciLexerMakefile::lexer() const
  38. {
  39. return "makefile";
  40. }
  41. // Return the string of characters that comprise a word.
  42. const char *QsciLexerMakefile::wordCharacters() const
  43. {
  44. return "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-";
  45. }
  46. // Returns the foreground colour of the text for a style.
  47. QColor QsciLexerMakefile::defaultColor(int style) const
  48. {
  49. switch (style)
  50. {
  51. case Default:
  52. case Operator:
  53. return QColor(0x00,0x00,0x00);
  54. case Comment:
  55. return QColor(0x00,0x7f,0x00);
  56. case Preprocessor:
  57. return QColor(0x7f,0x7f,0x00);
  58. case Variable:
  59. return QColor(0x00,0x00,0x80);
  60. case Target:
  61. return QColor(0xa0,0x00,0x00);
  62. case Error:
  63. return QColor(0xff,0xff,0x00);
  64. }
  65. return QsciLexer::defaultColor(style);
  66. }
  67. // Returns the end-of-line fill for a style.
  68. bool QsciLexerMakefile::defaultEolFill(int style) const
  69. {
  70. if (style == Error)
  71. return true;
  72. return QsciLexer::defaultEolFill(style);
  73. }
  74. // Returns the font of the text for a style.
  75. QFont QsciLexerMakefile::defaultFont(int style) const
  76. {
  77. QFont f;
  78. if (style == Comment)
  79. #if defined(Q_OS_WIN)
  80. f = QFont("Comic Sans MS",9);
  81. #elif defined(Q_OS_MAC)
  82. f = QFont("Comic Sans MS", 12);
  83. #else
  84. f = QFont("Bitstream Vera Serif",9);
  85. #endif
  86. else
  87. f = QsciLexer::defaultFont(style);
  88. return f;
  89. }
  90. // Returns the user name of a style.
  91. QString QsciLexerMakefile::description(int style) const
  92. {
  93. switch (style)
  94. {
  95. case Default:
  96. return tr("Default");
  97. case Comment:
  98. return tr("Comment");
  99. case Preprocessor:
  100. return tr("Preprocessor");
  101. case Variable:
  102. return tr("Variable");
  103. case Operator:
  104. return tr("Operator");
  105. case Target:
  106. return tr("Target");
  107. case Error:
  108. return tr("Error");
  109. }
  110. return QString();
  111. }
  112. // Returns the background colour of the text for a style.
  113. QColor QsciLexerMakefile::defaultPaper(int style) const
  114. {
  115. if (style == Error)
  116. return QColor(0xff,0x00,0x00);
  117. return QsciLexer::defaultPaper(style);
  118. }