Skip to content

Commit

Permalink
View history
Browse files Browse the repository at this point in the history
  • Loading branch information
FernandoAiresCastello committed Jul 28, 2024
1 parent 8902047 commit 229f546
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 6 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ temp.ptm
*.odt#
*.ods#
fernando/
0.3/Build/files/main.ptm
temp/
cppcheck
cppcheck
0.3/Build/files/main.ptm
0.4/build/root/AUTOEXEC
Binary file modified 0.4/build/PTM.exe
Binary file not shown.
10 changes: 9 additions & 1 deletion 0.4/src/PTM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,17 @@ void PTM::init()

void PTM::run_main()
{
main_editor.print_welcome();
bool autoexec = t_filesystem::file_exists(autoexec_file);
if (!autoexec)
main_editor.print_welcome();

while (wnd.is_open()) {
if (autoexec) {
autoexec = false;
load_program(autoexec_file, true);
run_program();
intp.print_prompt();
}
on_machine_cycle();
}
}
Expand Down
1 change: 1 addition & 0 deletions 0.4/src/PTM.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class PTM
public:
const t_string version_string = "PTM 0.4";
const t_string title = "PTM - Programmable Tile Machine";
const t_string autoexec_file = "AUTOEXEC";

t_tile tilereg;
bool auto_screen_update = true;
Expand Down
9 changes: 7 additions & 2 deletions 0.4/src/t_interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ void t_interpreter::init(PTM* ptm, t_screen* scr, t_keyboard* kb)
PTML::set_env(ptm, scr);
}

void t_interpreter::print_prompt()
{
scr->print_string_crlf(prompt);
}

void t_interpreter::interpret_line(t_string& src, bool from_file)
{
tokenizer.tokenize_line(src, tokens);
Expand All @@ -32,7 +37,7 @@ void t_interpreter::interpret_line(t_string& src, bool from_file)
bool ok = ptm->delete_program_line(line_number);
if (!ok) {
scr->print_string_crlf("Undefined line number");
scr->print_string_crlf(prompt);
print_prompt();
}
}
else {
Expand Down Expand Up @@ -76,7 +81,7 @@ bool t_interpreter::execute_line(t_program_line& line)
}

if (line.immediate)
scr->print_string_crlf(prompt);
print_prompt();

PTML::error = "";
return !has_error;
Expand Down
1 change: 1 addition & 0 deletions 0.4/src/t_interpreter.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class t_interpreter
t_string prompt = "Ok";

void init(PTM* ptm, t_screen* scr, t_keyboard* kb);
void print_prompt();
void interpret_line(t_string& line, bool from_file = false);
bool execute_line(t_program_line& line);
const t_string& get_last_error();
Expand Down
2 changes: 1 addition & 1 deletion 0.4/src/t_main_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void t_main_editor::reset()
void t_main_editor::print_welcome()
{
scr->print_string_crlf(ptm->version_string);
scr->print_string_crlf(intp->prompt);
intp->print_prompt();
}

void t_main_editor::on_keydown()
Expand Down
3 changes: 3 additions & 0 deletions 0.4/src/t_screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -460,14 +460,17 @@ void t_screen::toggle_insert_mode()
void t_screen::set_insert_mode(bool state)
{
insert_mode = state;
bool csr_visible = csr->tile.flags.visible;

if (insert_mode) {
t_tile tile(126, fore_color, back_color);
tile.flags.hide_bgc = true;
tile.flags.visible = csr_visible;
csr->set_tile(tile);
}
else {
csr->set_tile(t_tile());
csr->set_visible(csr_visible);
}

update_cursor();
Expand Down

0 comments on commit 229f546

Please sign in to comment.