diff --git a/.gitignore b/.gitignore index adc6a45..16886a1 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,7 @@ temp.ptm *.odt# *.ods# fernando/ -0.3/Build/files/main.ptm temp/ -cppcheck \ No newline at end of file +cppcheck +0.3/Build/files/main.ptm +0.4/build/root/AUTOEXEC diff --git a/0.4/build/PTM.exe b/0.4/build/PTM.exe index 6109704..8fb647e 100644 Binary files a/0.4/build/PTM.exe and b/0.4/build/PTM.exe differ diff --git a/0.4/src/PTM.cpp b/0.4/src/PTM.cpp index f09b1ff..1fb9879 100644 --- a/0.4/src/PTM.cpp +++ b/0.4/src/PTM.cpp @@ -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(); } } diff --git a/0.4/src/PTM.h b/0.4/src/PTM.h index 667693b..3f46303 100644 --- a/0.4/src/PTM.h +++ b/0.4/src/PTM.h @@ -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; diff --git a/0.4/src/t_interpreter.cpp b/0.4/src/t_interpreter.cpp index 37c60d2..33d3a0e 100644 --- a/0.4/src/t_interpreter.cpp +++ b/0.4/src/t_interpreter.cpp @@ -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); @@ -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 { @@ -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; diff --git a/0.4/src/t_interpreter.h b/0.4/src/t_interpreter.h index 8045097..670e885 100644 --- a/0.4/src/t_interpreter.h +++ b/0.4/src/t_interpreter.h @@ -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(); diff --git a/0.4/src/t_main_editor.cpp b/0.4/src/t_main_editor.cpp index 1c5f9d7..01da3de 100644 --- a/0.4/src/t_main_editor.cpp +++ b/0.4/src/t_main_editor.cpp @@ -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() diff --git a/0.4/src/t_screen.cpp b/0.4/src/t_screen.cpp index b79f29b..87a4320 100644 --- a/0.4/src/t_screen.cpp +++ b/0.4/src/t_screen.cpp @@ -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();