Initial work on type registration in the binder.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -9,14 +9,14 @@ namespace MalachScriptRepl {
|
||||
private:
|
||||
WINDOW* _window;
|
||||
|
||||
std::vector<std::u8string> _lines = {u8""};
|
||||
std::vector<std::string> _lines = {""};
|
||||
int _row = 0;
|
||||
int _col = 0;
|
||||
int _rightPos = 0;
|
||||
int _scroll = 0;
|
||||
int _lineCount;
|
||||
|
||||
std::function<void(const std::vector<std::u8string>&)> _onChange;
|
||||
std::function<void(const std::vector<std::string>&)> _onChange;
|
||||
const MalachScript::Diagnostics::Diagnostic* _diag;
|
||||
|
||||
public:
|
||||
@@ -26,7 +26,7 @@ namespace MalachScriptRepl {
|
||||
_lineCount = height;
|
||||
}
|
||||
|
||||
inline void RegisterOnChange(std::function<void(const std::vector<std::u8string>&)> listener) {
|
||||
inline void RegisterOnChange(std::function<void(const std::vector<std::string>&)> listener) {
|
||||
_onChange = listener;
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ namespace MalachScriptRepl {
|
||||
}
|
||||
|
||||
inline void Return() {
|
||||
_lines.insert(_lines.begin() + _row + _scroll + 1, u8"");
|
||||
_lines.insert(_lines.begin() + _row + _scroll + 1, "");
|
||||
if (_row >= _lineCount - 1) {
|
||||
ScrollDown();
|
||||
} else {
|
||||
@@ -119,10 +119,10 @@ namespace MalachScriptRepl {
|
||||
wclrtoeol(_window);
|
||||
auto& line = _lines[_row + _scroll];
|
||||
if ((int)line.length() <= _col) {
|
||||
line += u8" ";
|
||||
line += " ";
|
||||
} else {
|
||||
for (size_t i = 0; i < 4; i++) {
|
||||
line.insert(line.begin() + _col, u8' ');
|
||||
line.insert(line.begin() + _col, ' ');
|
||||
}
|
||||
}
|
||||
waddstr(_window, (char*)line.c_str());
|
||||
@@ -148,7 +148,7 @@ namespace MalachScriptRepl {
|
||||
wmove(_window, _row, 0);
|
||||
auto& line = _lines[_row + _scroll];
|
||||
if ((int)line.length() <= _col) {
|
||||
line += (char8_t)c;
|
||||
line += (char)c;
|
||||
} else {
|
||||
line.insert(line.begin() + _col, c);
|
||||
}
|
||||
@@ -160,7 +160,7 @@ namespace MalachScriptRepl {
|
||||
}
|
||||
|
||||
inline void ResetText() {
|
||||
std::u8string script;
|
||||
std::string script;
|
||||
for (size_t i = 0; i < _lines.size(); i++) {
|
||||
script += _lines[i];
|
||||
if (i != _lines.size() - 1) {
|
||||
@@ -196,11 +196,11 @@ namespace MalachScriptRepl {
|
||||
wmove(_window, _row, _col);
|
||||
}
|
||||
|
||||
inline void SetScriptWithDiagnostics(std::u8string& script, const MalachScript::Diagnostics::Diagnostic* diag) {
|
||||
inline void SetScriptWithDiagnostics(std::string& script, const MalachScript::Diagnostics::Diagnostic* diag) {
|
||||
_diag = diag;
|
||||
auto yx = GetCursorPosition();
|
||||
Clear();
|
||||
script += u8" ";
|
||||
script += " ";
|
||||
|
||||
size_t linenum = 0;
|
||||
size_t index = 0;
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
#include "../src/Parser/Statements/ParsedStatementStringifier.hpp"
|
||||
#include "InputWindow.hpp"
|
||||
|
||||
void ParseAndUpdate(const std::vector<std::u8string>& lines, WINDOW* diagnosticsWindow, WINDOW* parsedWindow,
|
||||
void ParseAndUpdate(const std::vector<std::string>& lines, WINDOW* diagnosticsWindow, WINDOW* parsedWindow,
|
||||
MalachScriptRepl::InputWindow& inputWindow) {
|
||||
std::u8string script;
|
||||
std::string script;
|
||||
for (size_t i = 0; i < lines.size(); i++) {
|
||||
script += lines[i];
|
||||
if (i != lines.size() - 1) {
|
||||
@@ -23,9 +23,9 @@ void ParseAndUpdate(const std::vector<std::u8string>& lines, WINDOW* diagnostics
|
||||
outfile.close();
|
||||
|
||||
auto logger = MalachScript::Diagnostics::Logger();
|
||||
auto lexer = MalachScript::Parser::Lexer(u8"diag", script, &logger);
|
||||
auto lexer = MalachScript::Parser::Lexer("diag", script, &logger);
|
||||
const auto* firstToken = lexer.Lex();
|
||||
const auto* parsedResult = MalachScript::Parser::Parser::Parse(firstToken, u8"diag", &logger);
|
||||
const auto* parsedResult = MalachScript::Parser::Parser::Parse(firstToken, "diag", &logger);
|
||||
|
||||
const MalachScript::Diagnostics::Diagnostic* diag = nullptr;
|
||||
wclear(diagnosticsWindow);
|
||||
@@ -96,7 +96,7 @@ int main([[maybe_unused]] int argc, [[maybe_unused]] const char* argv[]) {
|
||||
|
||||
auto inputWindow = MalachScriptRepl::InputWindow(inputFieldSize, maxX - 3, 1, 2);
|
||||
inputWindow.RegisterOnChange(
|
||||
[diagnosticsWindow, parsedResultWindow, &inputWindow](const std::vector<std::u8string>& lines) {
|
||||
[diagnosticsWindow, parsedResultWindow, &inputWindow](const std::vector<std::string>& lines) {
|
||||
ParseAndUpdate(lines, diagnosticsWindow, parsedResultWindow, inputWindow);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user