diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-06-21 23:23:57 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-06-21 23:27:54 -0700 |
commit | 45c08fea47de1a23ce98f4fc7a1c5c3bed92b5fb (patch) | |
tree | 78cbc5db454f79c6baf91afa49f090cf8cb14a58 /075scenario_keyboard.cc | |
parent | e552479afac60bdf3f5c089213cbc6422902ee5a (diff) | |
download | mu-45c08fea47de1a23ce98f4fc7a1c5c3bed92b5fb.tar.gz |
1616 - merging keyboard and events into 'console'
Only core layers currently passing. Console apps are probably still broken.
Diffstat (limited to '075scenario_keyboard.cc')
-rw-r--r-- | 075scenario_keyboard.cc | 84 |
1 files changed, 0 insertions, 84 deletions
diff --git a/075scenario_keyboard.cc b/075scenario_keyboard.cc deleted file mode 100644 index 6a5da304..00000000 --- a/075scenario_keyboard.cc +++ /dev/null @@ -1,84 +0,0 @@ -//: Clean syntax to manipulate and check the keyboard in scenarios. -//: Instruction 'assume-keyboard' implicitly creates a variable called -//: 'keyboard' that is accessible inside other 'run' instructions in the -//: scenario. Like with the fake screen, 'assume-keyboard' transparently -//: supports unicode. - -:(scenarios run_mu_scenario) -:(scenario keyboard_in_scenario) -scenario keyboard-in-scenario [ - assume-keyboard [abc] - run [ - 1:character, 2:boolean, keyboard:address <- read-key keyboard:address - 3:character, 4:boolean, keyboard:address <- read-key keyboard:address - 5:character, 6:boolean, keyboard:address <- read-key keyboard:address - 7:character, 8:boolean, keyboard:address <- read-key keyboard:address - ] - memory-should-contain [ - 1 <- 97 # 'a' - 2 <- 1 - 3 <- 98 # 'b' - 4 <- 1 - 5 <- 99 # 'c' - 6 <- 1 - 7 <- 0 # eof - 8 <- 1 - ] -] - -:(before "End Scenario Globals") -const long long int KEYBOARD = Next_predefined_global_for_scenarios++; -:(before "End Predefined Scenario Locals In Run") -Name[tmp_recipe.at(0)]["keyboard"] = KEYBOARD; - -//: allow naming just for 'keyword' -:(before "End is_special_name Cases") -if (s == "keyboard") return true; - -:(before "End Rewrite Instruction(curr)") -// rewrite `assume-keyboard string` to -// ``` -// keyboard:address <- new string # hacky reuse of location -// keyboard:address <- new-fake-keyboard keyboard:address -// ``` -if (curr.name == "assume-keyboard") { - // insert first instruction - curr.operation = Recipe_number["new"]; - curr.name = "new"; - assert(curr.products.empty()); - curr.products.push_back(reagent("keyboard:address")); - curr.products.at(0).set_value(KEYBOARD); - result.steps.push_back(curr); // hacky that "Rewrite Instruction" is converting to multiple instructions - // leave second instruction in curr - curr.clear(); - curr.operation = Recipe_number["new-fake-keyboard"]; - curr.name = "new-fake-keyboard"; - assert(curr.ingredients.empty()); - curr.ingredients.push_back(reagent("keyboard:address")); - curr.ingredients.at(0).set_value(KEYBOARD); - assert(curr.products.empty()); - curr.products.push_back(reagent("keyboard:address")); - curr.products.at(0).set_value(KEYBOARD); -} - -//: Since we don't yet have a clean way to represent characters like backspace -//: in literal strings we can't easily pretend they were typed into the fake -//: keyboard. So we'll use special unicode characters in the literal and then -//: manually replace them with backspace. -:(before "End Primitive Recipe Declarations") -REPLACE_IN_KEYBOARD, -:(before "End Primitive Recipe Numbers") -Recipe_number["replace-in-keyboard"] = REPLACE_IN_KEYBOARD; -:(before "End Primitive Recipe Implementations") -case REPLACE_IN_KEYBOARD: { - long long int size = Memory[KEYBOARD]; - assert(scalar(ingredients.at(0))); - assert(scalar(ingredients.at(1))); - for (long long int curr = KEYBOARD+1; curr <= KEYBOARD+size; ++curr) { - if (Memory[curr] == ingredients.at(0).at(0)) { -//? cerr << "replacing\n"; //? 1 - Memory[curr] = ingredients.at(1).at(0); - } - } - break; -} |