WSF
EditorPrefObject.hpp
Go to the documentation of this file.
1// ****************************************************************************
2// CUI
3//
4// The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
5//
6// Copyright 2018 Infoscitex, a DCS Company. All rights reserved.
7//
8// The use, dissemination or disclosure of data in this file is subject to
9// limitation or restriction. See accompanying README and LICENSE for details.
10// ****************************************************************************
11
12#ifndef EDITORPREFOBJECT_HPP
13#define EDITORPREFOBJECT_HPP
14
15#include "UiResources.hpp"
16#include "UtCast.hpp"
17#include "ViExport.hpp"
18#include "WkfPrefObject.hpp"
19
20namespace wizard
21{
22enum class TextType : size_t
23{
24 // Normal styles
25
26 // Text not parsed
27 None = 0,
28 // Text token matches keyword in grammar
30 // Keyword marking the start or end of a block
32 // Keyword marking the start of a command
34 // A user-defined input value (number, string, etc...)
36 // A WSF type (WSF_PLATFORM ...)
37 Type = 5,
38 // A new user type (MY_PLATFORM)
39 Name = 6,
40 // include line
42 // Comment # or //
44 // Quoted string (not used right now)
45 Quoted = 9,
51
52 // Script styles
53
67
69};
70
72{
73 TextStyle() = default;
74
75 TextStyle(const QColor& aColor, bool aBold, bool aItalic, bool aUnderline)
76 : mColor(aColor)
77 , mBold(aBold)
78 , mItalic(aItalic)
79 , mUnderline(aUnderline)
80 {
81 }
82
83 QColor mColor{Qt::red};
84 bool mBold{false};
85 bool mItalic{false};
86 bool mUnderline{false};
87};
89{
91
92 bool mShowLineNumbers{true};
93 bool mShowSyntaxTips{true};
95 bool mEnableUndoPopups{false};
96 unsigned int mTabSpace{3};
97 bool mFoldText{true};
98 std::map<QString, QColor> mDarkEditorColor;
99 std::map<QString, QColor> mLightEditorColor;
100 std::map<TextType, TextStyle> mDarkStyle;
101 std::map<TextType, TextStyle> mLightStyle;
103 unsigned int mFontSize{ut::safe_cast<unsigned int>(UiResources::GetInstance().GetFont().pointSize())};
104 std::map<QString, std::pair<size_t, size_t>> mFilePositions;
105};
106
107class VI_EXPORT EditorPrefObject : public wkf::PrefObjectT<EditorPrefData>
108{
109 Q_OBJECT
110
111public:
112 static constexpr const char* cNAME = "EditorOptions";
113
114 EditorPrefObject(QObject* parent = nullptr);
115 ~EditorPrefObject() override = default;
116
117 void Apply() override;
118
119 EditorPrefData ReadSettings(QSettings& aSettings) const override;
120 void SaveSettingsP(QSettings& aSettings) const override;
121
122 bool ShowLineNumbers() const;
123 bool ShowSyntaxTips() const;
124 const QColor EditorColor(const QString& aName) const;
125 const unsigned int TabSpace() const;
126 bool AutocompleteAfterPeriod() const;
127 bool UndoPopupsEnabled() const;
128 const std::map<TextType, TextStyle>& GetStyles();
129 bool FoldText() const;
130 unsigned int FontSize() const;
131 void SetFontSize(unsigned int aSize);
132 QString FontType() const;
133
134 void RememberFilePosition(const QString& aPath, const size_t aLine, const size_t aColumn);
135 std::pair<size_t, size_t> RecallFilePosition(const QString& aPath);
136signals:
137 void Changed();
138};
139} // namespace wizard
140
142#endif
Q_DECLARE_METATYPE(wizard::ProjectWorkspace *)
#define VI_EXPORT
Definition ViExport.hpp:38
void SaveSettingsP(QSettings &aSettings) const override
Definition EditorPrefObject.cpp:192
~EditorPrefObject() override=default
static constexpr const char * cNAME
Definition EditorPrefObject.hpp:112
unsigned int FontSize() const
Definition EditorPrefObject.cpp:314
bool ShowSyntaxTips() const
Definition EditorPrefObject.cpp:348
bool UndoPopupsEnabled() const
Definition EditorPrefObject.cpp:292
bool ShowLineNumbers() const
Definition EditorPrefObject.cpp:256
void Apply() override
Definition EditorPrefObject.cpp:112
void RememberFilePosition(const QString &aPath, const size_t aLine, const size_t aColumn)
Definition EditorPrefObject.cpp:333
bool FoldText() const
Definition EditorPrefObject.cpp:309
const QColor EditorColor(const QString &aName) const
Definition EditorPrefObject.cpp:261
void SetFontSize(unsigned int aSize)
Definition EditorPrefObject.cpp:319
const unsigned int TabSpace() const
Definition EditorPrefObject.cpp:282
QString FontType() const
Definition EditorPrefObject.cpp:328
const std::map< TextType, TextStyle > & GetStyles()
Definition EditorPrefObject.cpp:297
bool AutocompleteAfterPeriod() const
Definition EditorPrefObject.cpp:287
std::pair< size_t, size_t > RecallFilePosition(const QString &aPath)
Definition EditorPrefObject.cpp:338
EditorPrefObject(QObject *parent=nullptr)
Definition EditorPrefObject.cpp:107
EditorPrefData ReadSettings(QSettings &aSettings) const override
Definition EditorPrefObject.cpp:117
static UiResources & GetInstance()
Definition UiResources.hpp:39
QFont & GetFont()
Definition UiResources.hpp:42
Definition Runner.hpp:22
TextType
Definition EditorPrefObject.hpp:23
@ Script_Keyword
Definition EditorPrefObject.hpp:54
@ Comment
Definition EditorPrefObject.hpp:43
@ Script_End
Definition EditorPrefObject.hpp:66
@ Script_Number
Definition EditorPrefObject.hpp:59
@ Keyword
Definition EditorPrefObject.hpp:29
@ Script_Local_Variable
Definition EditorPrefObject.hpp:63
@ Script_Comment
Definition EditorPrefObject.hpp:57
@ Script_Operator
Definition EditorPrefObject.hpp:55
@ Unmatched_Block
Definition EditorPrefObject.hpp:46
@ Include_Error
Definition EditorPrefObject.hpp:47
@ Syntax_Tip_Bold
Definition EditorPrefObject.hpp:49
@ Name
Definition EditorPrefObject.hpp:39
@ Script_Static_Method
Definition EditorPrefObject.hpp:60
@ Margin_None
Definition EditorPrefObject.hpp:68
@ None
Definition EditorPrefObject.hpp:27
@ Quoted
Definition EditorPrefObject.hpp:45
@ Block_Keyword
Definition EditorPrefObject.hpp:31
@ Script_Quoted
Definition EditorPrefObject.hpp:56
@ Type
Definition EditorPrefObject.hpp:37
@ Script_Method
Definition EditorPrefObject.hpp:61
@ Script_Local_Method
Definition EditorPrefObject.hpp:62
@ Script_Type
Definition EditorPrefObject.hpp:58
@ Script_Parameter
Definition EditorPrefObject.hpp:64
@ Syntax_Tip
Definition EditorPrefObject.hpp:48
@ Preprocessor
Definition EditorPrefObject.hpp:50
@ Command
Definition EditorPrefObject.hpp:33
@ Include
Definition EditorPrefObject.hpp:41
@ Script_None
Definition EditorPrefObject.hpp:65
@ User_Input
Definition EditorPrefObject.hpp:35
Definition EditorPrefObject.hpp:89
bool mFoldText
Definition EditorPrefObject.hpp:97
bool mShowLineNumbers
Definition EditorPrefObject.hpp:92
std::map< TextType, TextStyle > mLightStyle
Definition EditorPrefObject.hpp:101
std::map< TextType, TextStyle > mDarkStyle
Definition EditorPrefObject.hpp:100
std::map< QString, std::pair< size_t, size_t > > mFilePositions
Definition EditorPrefObject.hpp:104
bool mEnableUndoPopups
Definition EditorPrefObject.hpp:95
QString mFontType
Definition EditorPrefObject.hpp:102
unsigned int mTabSpace
Definition EditorPrefObject.hpp:96
bool mShowSyntaxTips
Definition EditorPrefObject.hpp:93
EditorPrefData()
Definition EditorPrefObject.cpp:20
std::map< QString, QColor > mLightEditorColor
Definition EditorPrefObject.hpp:99
bool mAutocompleteAfterPeriod
Definition EditorPrefObject.hpp:94
unsigned int mFontSize
Definition EditorPrefObject.hpp:103
std::map< QString, QColor > mDarkEditorColor
Definition EditorPrefObject.hpp:98
QColor mColor
Definition EditorPrefObject.hpp:83
bool mUnderline
Definition EditorPrefObject.hpp:86
TextStyle(const QColor &aColor, bool aBold, bool aItalic, bool aUnderline)
Definition EditorPrefObject.hpp:75
TextStyle()=default
bool mBold
Definition EditorPrefObject.hpp:84
bool mItalic
Definition EditorPrefObject.hpp:85
Copyrights Multiple, All Rights Reserved