示例#1
0
void
edit_interface_rep::set_input_mode (int mode) {
  interrupt_shortcut ();
  // avoids keyboard shortcuts when using the menu between two keystrokes

  if ((mode == INPUT_NORMAL) && (input_mode != INPUT_NORMAL)) {
    selection_cancel ();
    completions= array<string> ();
  }
  input_mode= mode;
}
示例#2
0
void
edit_select_rep::select_enlarge () {
  path sp, sq;
  if (start_p == end_p) {
    sp= path_up (start_p);
    sq= sp;
  }
  else {
    sp= common (start_p, end_p);
    if (!(rp < sp)) {
      selection_cancel ();
      set_message ("", "");
      return;
    }
    sq= path_up (sp);
  }
  path pp= sp, p1= start_p, p2= end_p;
  if (start_p == pp * 0 && end_p == pp * right_index (subtree (et, pp)))
    if (!is_nil (pp)) pp= path_up (pp);
  if (is_func (subtree (et, pp), TFORMAT)) pp= path_up (pp);
  if (semantic_select (pp, p1, p2, 1))
    select (p1, p2);
  else {
    if (is_atomic (subtree (et, sp))) select_enlarge_text ();
    else select (sq * 0, sq * 1);
  }

  path p = common (start_p, end_p);
  tree st= subtree (et, p);
  if (drd->var_without_border (L(st)) ||
      is_func (st, TFORMAT) ||
      is_func (st, DOCUMENT, 1) ||
      is_script (st) ||
      incomplete_script_selection (st, start_p / p, end_p / p))
    select_enlarge ();
  else {
    tree s;
    if (is_atomic (st)) s= "text";
    else if (is_func (st, COMPOUND)) s= as_string (st[0]);
    else if (is_func (st, WITH)) s= concat ("with ", as_string (st[0]));
    else s= as_string (L(st));
    set_message (concat ("selected ", s), "enlarge selection");
  }
  selecting= shift_selecting= false;
}
示例#3
0
void
edit_select_rep::selection_set (string key, tree t, bool persistant) {
  selecting= shift_selecting= false;
  string mode= as_string (selection_get_env_value (MODE));
  string lan = as_string (selection_get_env_value (MODE_LANGUAGE (mode)));
  tree sel= tuple ("texmacs", t, mode, lan);
  /* TODO: add mode="graphics" somewhere in the context of the <graphics>
     tag. To be done when implementing the different embeddings for
     nicely copying graphics into text, text into graphics, etc. */
  string s;
  if (key == "primary" || key == "mouse") {
    if (selection_export == "verbatim") t= exec_verbatim (t, tp);
    if (selection_export == "html") t= exec_html (t, tp);
    if (selection_export == "latex") t= exec_latex (t, tp);
    if ((selection_export == "latex") && (mode == "math"))
      t= compound ("math", t);
    s= tree_to_generic (t, selection_export * "-snippet");
    s= selection_encode (lan, s);
  }
  if (::set_selection (key, sel, s, selection_export) && !persistant)
    selection_cancel ();
}
示例#4
0
void
edit_select_rep::select_from_cursor_if_active () {
  if (selecting) select (mid_p, tp);
  else selection_cancel ();
}