path edit_cursor_rep::make_cursor_accessible (path p, bool forwards) { //time_t t1= texmacs_time (); path start_p= p; bool inverse= false; int old_mode= get_access_mode (); if (get_init_string (MODE) == "src") set_access_mode (DRD_ACCESS_SOURCE); while (!is_accessible_cursor (et, p) && !in_source ()) { path pp; ASSERT (rp <= p, "path outside document"); p= rp * closest_inside (subtree (et, rp), p / rp); if (forwards ^ inverse) pp= rp * next_valid (subtree (et, rp), p / rp); else pp= rp * previous_valid (subtree (et, rp), p / rp); if (pp == p) { if (inverse) break; else { p= start_p; inverse= true; } } else p= pp; } set_access_mode (old_mode); //time_t t2= texmacs_time (); //if (t2-t1 >= 1) cout << "made_cursor_accessible took " << t2-t1 << "ms\n"; return p; }
void edit_interface_rep::append_left_footer (tree& l, string env_var) { if (!is_concat (l)) l= concat (l); string i= get_init_string (env_var); string c= get_env_string (env_var); if (c != i) l << (" " * c); }
void edit_interface_rep::draw_surround (renderer ren, rectangle r) { ren->set_background (light_grey); string medium= get_init_string (PAGE_MEDIUM); if ((medium == "papyrus") || (medium == "paper")) ren->clear (max (eb->x2, r->x1), r->y1, r->x2, min (eb->y2+ 2*pixel, r->y2)); else if (medium == "paper") ren->clear (r->x1, r->y1, r->x2, min (eb->y1, r->y2)); }
void edit_select_rep::selection_correct (path i1, path i2, path& o1, path& o2) { ASSERT (rp <= i1 && rp <= i2, "paths not inside document"); int old_mode= get_access_mode (); if (get_init_string (MODE) == "src") set_access_mode (DRD_ACCESS_SOURCE); ::selection_correct (subtree (et, rp), i1 / rp, i2 / rp, o1, o2); set_access_mode (old_mode); o1= rp * o1; o2= rp * o2; }
string edit_main_rep::get_metadata (string kind) { string var= "global-" * kind; string val= get_init_string (var); if (val != "") return val; val= search_metadata (subtree (et, rp), kind); if (val != "") return val; if (kind == "title") return as_string (tail (get_name ())); #ifndef __MINGW32__ if (kind == "author" && !is_none (resolve_in_path ("finger")) && !is_none (resolve_in_path ("sed"))) { string val= var_eval_system ("finger `whoami` | sed -e '/Name/!d' -e 's/.*Name: //'"); if (N(val) > 1) return utf8_to_cork (val); } #endif return ""; }
static paralist *get_init(PJ_CONTEXT *ctx, char *key) { /************************************************************************* Expand key from buffer or (if not in buffer) from init file *************************************************************************/ char *xkey, *definition; paralist *init_items = 0; /* support "init=file:section", "+init=file:section", and "file:section" format */ xkey = strstr (key, "init="); if (0==xkey) xkey = key; else xkey += 5; pj_log (ctx, PJ_LOG_TRACE, "get_init: searching cache for key: [%s]", xkey); /* Is file/key pair already in cache? */ init_items = pj_search_initcache (xkey); if (init_items) return init_items; /* If not, we must read it from file */ pj_log (ctx, PJ_LOG_TRACE, "get_init: searching on in init files for [%s]", xkey); definition = get_init_string (ctx, xkey); if (0==definition) return 0; init_items = string_to_paralist (ctx, definition); if (init_items) pj_log (ctx, PJ_LOG_TRACE, "get_init: got [%s], paralist[0,1]: [%s,%s]", definition, init_items->param, init_items->next ? init_items->next->param : "(empty)"); pj_dealloc (definition); if (0==init_items) return 0; /* We found it in file - now insert into the cache, before returning */ pj_insert_initcache (xkey, init_items); return init_items; }
bool edit_process_rep::get_save_aux () { return as_bool (get_init_string (SAVE_AUX)); }