about summary refs log tree commit diff stats
path: root/termbox/termbox.c
Commit message (Expand)AuthorAgeFilesLines
* 3222Kartik K. Agaram2016-08-181-0/+4
* 2131 - better tb_sync()Kartik K. Agaram2015-09-021-6/+10
* 2113 - stop updating entire screen on tb_present()Kartik K. Agaram2015-08-291-0/+9
* 2078 - update entire screen on tb_present()Kartik K. Agaram2015-08-261-4/+0
* 1964 - don't mess up pasteKartik K. Agaram2015-08-091-0/+2
* 1731 - ah, now fully responsiveKartik K. Agaram2015-07-081-0/+5
* 1573Kartik K. Agaram2015-06-161-0/+8
* 1531 - enable termbox's mouse supportKartik K. Agaram2015-06-051-0/+1
* 1530 - switch to termbox's 256-color modeKartik K. Agaram2015-06-051-34/+10
* 1486 - repl: hitting enter now workingKartik K. Agaram2015-05-271-0/+5
* 1327 - better error handling in chessboardKartik K. Agaram2015-05-101-2/+10
* 1323 - keyboard supports backspace and newlineKartik K. Agaram2015-05-101-4/+1
* 1276 - make C++ version the defaultKartik K. Agaram2015-05-051-0/+562
hStrong */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
//: Calls can take ingredients just like primitives. To access a recipe's
//: ingredients, use 'next-ingredient'.

:(scenario next_ingredient)
recipe main [
  f 2:literal
]
recipe f [
  12:number <- next-ingredient
  13:number <- add 1:literal, 12:number
]
+run: instruction f/1
+mem: location 12 is 2
+mem: storing 3 in location 13

:(scenario next_ingredient_missing)
recipe main [
  f
]
recipe f [
  _, 12:number <- next-ingredient
]
+mem: storing 0 in location 12

:(before "End call Fields")
vector<vector<double> > ingredient_atoms;
index_t next_ingredient_to_process;
:(replace{} "call(recipe_number r)")
call(recipe_number r) :running_recipe(r), running_step_index(0), next_ingredient_to_process(0) {}

:(replace "Current_routine->calls.push_front(call(current_instruction().operation))" following "End Primitive Recipe Implementations")
call callee(current_instruction().operation);
for (size_t i = 0; i < ingredients.size(); ++i) {
  callee.ingredient_atoms.push_back(ingredients.at(i));
}
Current_routine->calls.push_front(callee);

:(before "End Primitive Recipe Declarations")
NEXT_INGREDIENT,
:(before "End Primitive Recipe Numbers")
Recipe_number["next-ingredient"] = NEXT_INGREDIENT;
:(before "End Primitive Recipe Implementations")
case NEXT_INGREDIENT: {
  assert(!Current_routine->calls.empty());
  if (Current_routine->calls.front().next_ingredient_to_process < Current_routine->calls.front().ingredient_atoms.size()) {
    products.push_back(
        Current_routine->calls.front().ingredient_atoms.at(Current_routine->calls.front().next_ingredient_to_process));
    assert(products.size() == 1);  products.resize(2);  // push a new vector
    products.at(1).push_back(1);
    ++Current_routine->calls.front().next_ingredient_to_process;
  }
  else {
    products.resize(2);
    products.at(0).push_back(0);  // todo: will fail noisily if we try to read a compound value
    products.at(1).push_back(0);
  }
  break;
}

:(scenario rewind_ingredients)
recipe main [
  f 2:literal
]
recipe f [
  12:number <- next-ingredient  # consume ingredient
  _, 1:boolean <- next-ingredient  # will not find any ingredients
  rewind-ingredients
  13:number, 2:boolean <- next-ingredient  # will find ingredient again
]
+mem: storing 2 in location 12
+mem: storing 0 in location 1
+mem: storing 2 in location 13
+mem: storing 1 in location 2

:(before "End Primitive Recipe Declarations")
REWIND_INGREDIENTS,
:(before "End Primitive Recipe Numbers")
Recipe_number["rewind-ingredients"] = REWIND_INGREDIENTS;
:(before "End Primitive Recipe Implementations")
case REWIND_INGREDIENTS: {
  Current_routine->calls.front().next_ingredient_to_process = 0;
  break;
}

:(scenario ingredient)
recipe main [
  f 1:literal, 2:literal
]
recipe f [
  12:number <- ingredient 1:literal  # consume second ingredient first
  13:number, 1:boolean <- next-ingredient  # next-ingredient tries to scan past that
]
+mem: storing 2 in location 12
+mem: storing 0 in location 1

:(before "End Primitive Recipe Declarations")
INGREDIENT,
:(before "End Primitive Recipe Numbers")
Recipe_number["ingredient"] = INGREDIENT;
:(before "End Primitive Recipe Implementations")
case INGREDIENT: {
  assert(isa_literal(current_instruction().ingredients.at(0)));
  assert(ingredients.at(0).size() == 1);  // scalar
  if (static_cast<index_t>(ingredients.at(0).at(0)) < Current_routine->calls.front().ingredient_atoms.size()) {
    Current_routine->calls.front().next_ingredient_to_process = ingredients.at(0).at(0);
    products.push_back(
        Current_routine->calls.front().ingredient_atoms.at(Current_routine->calls.front().next_ingredient_to_process));
    assert(products.size() == 1);  products.resize(2);  // push a new vector
    products.at(1).push_back(1);
    ++Current_routine->calls.front().next_ingredient_to_process;
  }
  else {
    if (current_instruction().products.size() > 1) {
      products.resize(2);
      products.at(0).push_back(0);  // todo: will fail noisily if we try to read a compound value
      products.at(1).push_back(0);
    }
  }
  break;
}