Popout PaletteEditor, general housekeeping

This commit is contained in:
scawful
2023-05-22 09:16:20 -05:00
parent 02b1adb6ab
commit 5ac7002c88
45 changed files with 254 additions and 334 deletions

68
src/app/gui/widgets.cc Normal file
View File

@@ -0,0 +1,68 @@
#include "widgets.h"
#include <ImGuiColorTextEdit/TextEditor.h>
#include "absl/status/status.h"
#include "app/core/constants.h"
namespace yaze {
namespace gui {
namespace widgets {
TextEditor::LanguageDefinition GetAssemblyLanguageDef() {
TextEditor::LanguageDefinition language_65816;
for (auto &k : app::core::kKeywords) language_65816.mKeywords.emplace(k);
for (auto &k : app::core::kIdentifiers) {
TextEditor::Identifier id;
id.mDeclaration = "Built-in function";
language_65816.mIdentifiers.insert(std::make_pair(std::string(k), id));
}
language_65816.mTokenRegexStrings.push_back(
std::make_pair<std::string, TextEditor::PaletteIndex>(
"[ \\t]*#[ \\t]*[a-zA-Z_]+", TextEditor::PaletteIndex::Preprocessor));
language_65816.mTokenRegexStrings.push_back(
std::make_pair<std::string, TextEditor::PaletteIndex>(
"L?\\\"(\\\\.|[^\\\"])*\\\"", TextEditor::PaletteIndex::String));
language_65816.mTokenRegexStrings.push_back(
std::make_pair<std::string, TextEditor::PaletteIndex>(
"\\'\\\\?[^\\']\\'", TextEditor::PaletteIndex::CharLiteral));
language_65816.mTokenRegexStrings.push_back(
std::make_pair<std::string, TextEditor::PaletteIndex>(
"[+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)([eE][+-]?[0-9]+)?[fF]?",
TextEditor::PaletteIndex::Number));
language_65816.mTokenRegexStrings.push_back(
std::make_pair<std::string, TextEditor::PaletteIndex>(
"[+-]?[0-9]+[Uu]?[lL]?[lL]?", TextEditor::PaletteIndex::Number));
language_65816.mTokenRegexStrings.push_back(
std::make_pair<std::string, TextEditor::PaletteIndex>(
"0[0-7]+[Uu]?[lL]?[lL]?", TextEditor::PaletteIndex::Number));
language_65816.mTokenRegexStrings.push_back(
std::make_pair<std::string, TextEditor::PaletteIndex>(
"0[xX][0-9a-fA-F]+[uU]?[lL]?[lL]?",
TextEditor::PaletteIndex::Number));
language_65816.mTokenRegexStrings.push_back(
std::make_pair<std::string, TextEditor::PaletteIndex>(
"[a-zA-Z_][a-zA-Z0-9_]*", TextEditor::PaletteIndex::Identifier));
language_65816.mTokenRegexStrings.push_back(
std::make_pair<std::string, TextEditor::PaletteIndex>(
"[\\[\\]\\{\\}\\!\\%\\^\\&\\*\\(\\)\\-\\+\\=\\~\\|\\<\\>\\?\\/"
"\\;\\,\\.]",
TextEditor::PaletteIndex::Punctuation));
language_65816.mCommentStart = "/*";
language_65816.mCommentEnd = "*/";
language_65816.mSingleLineComment = ";";
language_65816.mCaseSensitive = false;
language_65816.mAutoIndentation = true;
language_65816.mName = "65816";
return language_65816;
}
} // namespace widgets
} // namespace gui
} // namespace yaze