qscilexercsharp.cpp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. // This module implements the QsciLexerCSharp 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/qscilexercsharp.h"
  20. #include <qcolor.h>
  21. #include <qfont.h>
  22. // The ctor.
  23. QsciLexerCSharp::QsciLexerCSharp(QObject *parent)
  24. : QsciLexerCPP(parent)
  25. {
  26. }
  27. // The dtor.
  28. QsciLexerCSharp::~QsciLexerCSharp()
  29. {
  30. }
  31. // Returns the language name.
  32. const char *QsciLexerCSharp::language() const
  33. {
  34. return "C#";
  35. }
  36. // Returns the foreground colour of the text for a style.
  37. QColor QsciLexerCSharp::defaultColor(int style) const
  38. {
  39. if (style == VerbatimString)
  40. return QColor(0x00,0x7f,0x00);
  41. return QsciLexerCPP::defaultColor(style);
  42. }
  43. // Returns the end-of-line fill for a style.
  44. bool QsciLexerCSharp::defaultEolFill(int style) const
  45. {
  46. if (style == VerbatimString)
  47. return true;
  48. return QsciLexerCPP::defaultEolFill(style);
  49. }
  50. // Returns the font of the text for a style.
  51. QFont QsciLexerCSharp::defaultFont(int style) const
  52. {
  53. if (style == VerbatimString)
  54. #if defined(Q_OS_WIN)
  55. return QFont("Courier New",10);
  56. #elif defined(Q_OS_MAC)
  57. return QFont("Courier", 12);
  58. #else
  59. return QFont("Bitstream Vera Sans Mono",9);
  60. #endif
  61. return QsciLexerCPP::defaultFont(style);
  62. }
  63. // Returns the set of keywords.
  64. const char *QsciLexerCSharp::keywords(int set) const
  65. {
  66. if (set != 1)
  67. return 0;
  68. return "abstract as base bool break byte case catch char checked "
  69. "class const continue decimal default delegate do double else "
  70. "enum event explicit extern false finally fixed float for "
  71. "foreach goto if implicit in int interface internal is lock "
  72. "long namespace new null object operator out override params "
  73. "private protected public readonly ref return sbyte sealed "
  74. "short sizeof stackalloc static string struct switch this "
  75. "throw true try typeof uint ulong unchecked unsafe ushort "
  76. "using virtual void while";
  77. }
  78. // Returns the user name of a style.
  79. QString QsciLexerCSharp::description(int style) const
  80. {
  81. if (style == VerbatimString)
  82. return tr("Verbatim string");
  83. return QsciLexerCPP::description(style);
  84. }
  85. // Returns the background colour of the text for a style.
  86. QColor QsciLexerCSharp::defaultPaper(int style) const
  87. {
  88. if (style == VerbatimString)
  89. return QColor(0xe0,0xff,0xe0);
  90. return QsciLexer::defaultPaper(style);
  91. }