//: Take raw control of the text-mode display and console, putting it in //: 'console' mode rather than the usual automatically-scrolling 'typewriter' //: mode. //:: Display management :(before "End Globals") int Display_row = 0; int Display_column = 0; bool Autodisplay = true; :(before "End Includes") #define CHECK_SCREEN \ if (!tb_is_active()) { \ if (Run_tests) \ raise << maybe(current_recipe_name()) << "tried to print to real screen before 'open-console'\n" << end(); \ else \ raise << maybe(current_recipe_name()) << "tried to print to real screen in a test!\n" << end(); \ break; \ } #define CHECK_CONSOLE \ if (!tb_is_active()) { \ if (Run_tests) \ raise << maybe(current_recipe_name()) << "tried to read event from real keyboard/mouse before 'open-console'\n" << end(); \ else \ raise << maybe(current_recipe_name()) << "tried to read event from real keyboard/mouse in a test!\n" << end(); \ break; \ } :(before "End Primitive Recipe Declarations") OPEN_CONSOLE, :(before "End Primitive Recipe Numbers") put(Recipe_ordinal, "open-console", OPEN_CONSOLE); :(before "End Primitive Recipe Checks") case OPEN_CONSOLE: { break; } :(before "End Primitive Recipe Implementations") case OPEN_CONSOLE: { tb_init(); Display_row = Display_column = 0; int width = tb_width(); int height = tb_height(); if (width > 222 || height > 222) tb_shutdown(); if (width > 222) raise << "sorry, mu doesn't support windows wider than 222 characters in console mode. Please resize your window.\n" << end(); if (height > 222) raise << "sorry, mu doesn't support windows taller than 222 characters in console mode. Please resize your window.\n" << end(); break; } :(before "End Primitive Recipe Declarations") CLOSE_CONSOLE, :(before "End Primitive Recipe Numbers") put(Recipe_ordinal, "close-console", CLOSE_CONSOLE); :(before "End Primitive Recipe Checks") case CLOSE_CONSOLE: { break; } :(before "End Primitive Recipe Implementations") case CLOSE_CONSOLE: { tb_shutdown(); break; } :(before "End Teardown") tb_shutdown(); :(before "End Primitive Recipe Declarations") CLEAR_DISPLAY, :(before "End Primitive Recipe Numbers") put(Recipe_ordinal, "clear-display", CLEAR_DISPLAY); :(before "End Primitive Recipe Checks") case CLEAR_DISPLAY: { break; } :(before "End Primitive Recipe Implementations") case CLEAR_DISPLAY: { CHECK_SCREEN; tb_clear(); Display_row = Display_column = 0; break; } :(before "End Primitive Recipe Declarations") SYNC_DISPLAY, :(before "End Primitive Recipe Numbers") put(Recipe_ordinal, "sync-display", SYNC_DISPLAY); :(before "End Primitive Recipe Checks") case SYNC_DISPLAY: { break; } :(before "End Primitive Recipe Implementations") case SYNC_DISPLAY: { CHECK_SCREEN; tb_sync(); break; } :(before "End Primitive Recipe Declarations") CLEAR_LINE_ON_DISPLAY, :(before "End Primitive Recipe Numbers") put(Recipe_ordinal, "clear-line-on-display", CLEAR_LINE_ON_DISPLAY); :(before "End Primitive Recipe Checks") case CLEAR_LINE_ON_DISPLAY: { break; } :(before "End Primitive Recipe Implementations") case CLEAR_LINE_ON_DISPLAY: { CHECK_SCREEN; int width = tb_width(); for (int x = Display_column; x < width; ++x) { tb_change_cell(x, Display_row, ' ', TB_WHITE, TB_BLACK); } tb_set_cursor(Display_column, Display_row); if (Autodisplay) tb_present(); break; } :(before "End Primitive Recipe Declarations") PRINT_CHARACTER_TO_
# This is test program for the osproc module.
import os
echo getCurrentDir()
for i in 1..paramCount():
echo paramStr(i)