void edit_interface_rep::key_press (string gkey) { string zero= "a"; zero[0]= '\0'; string key= replace (gkey, "<#0>", zero); if (pre_edit_mark != 0) { ASSERT (sh_mark == 0, "invalid shortcut during pre-edit"); mark_cancel (pre_edit_mark); pre_edit_s= ""; pre_edit_mark= 0; } if (starts (key, "pre-edit:") ) { interrupt_shortcut (); string s= key (9, N(key)); if (s == "") return; int i, n= N(s), pos= N(s); for (i=0; i<n; i++) if (s[i] == ':' && is_int (s (0, i))) { int k= as_int (s (0, i)); s= s (i+1, n); pos= 0; for (int j=0; j<k && pos<N(s); j++) tm_char_forwards (s, pos); break; } pre_edit_s= s; pre_edit_mark= new_marker (); mark_start (pre_edit_mark); archive_state (); insert_tree (compound ("pre-edit", s), path (0, pos)); return; } string new_sh= N(sh_s)==0? key: sh_s * " " * key; if (try_shortcut (new_sh)) return; if (new_sh != key) { interrupt_shortcut (); if (try_shortcut (key)) return; } string rew= sv->kbd_post_rewrite (key); if (N(rew) == 1) { int i ((unsigned char) rew[0]); if ((i >= 32 && i <= 127) || (i >= 128 && i <= 255) || (i == 25)) if (!inside_active_graphics ()) { archive_state (); call ("kbd-insert", rew); } interrupt_shortcut (); } else if (contains_unicode_char (rew)) { archive_state (); call ("kbd-insert", key); interrupt_shortcut (); } else if (DEBUG_KEYBOARD) debug_keyboard << "unrecognized key " << key << ". " << "Undefined shortcut or key missing in the encoding files.\n"; }
void set_marker_at_loc (char * value, unsigned int x, unsigned int y) { unsigned int i; if ((i = which_marker(x, y)) < MAX_MARKERS) { strcpy(gmap.markers[i].name, value); } else { new_marker(value, x, y); map_change (x, y); map_change (x + 1, y); map_change (x, y - 1); map_change (x + 1, y - 1); } }
bool edit_interface_rep::try_shortcut (string comb) { int status; command cmd; string shorth; string help; sv->get_keycomb (comb, status, cmd, shorth, help); //cout << "Try " << comb << " -> " << shorth << ", " << help //<< "; " << sh_mark << ", " << status << "\n"; if (status != 0) { if (status >= 3) { interrupt_shortcut (); status -= 3; if (status == 0) return false; } else { if (sh_mark != 0 && !mark_cancel (sh_mark)) { sh_mark= 0; return false; } } sh_s= comb; sh_mark= new_marker (); mark_start (sh_mark); archive_state (); string rew_s= sv->kbd_post_rewrite (sh_s); tree rew= sv->kbd_system_rewrite (rew_s); if (N(help)>0) set_message (help, rew); tree rhs= (shorth == rew_s? tree (""): sv->kbd_system_rewrite (shorth)); //cout << "Shortcut: " << sh_s << " -> " << rew << "\n"; if ((search_forwards (" ", comb) >= 0 && comb != " ") || (search_forwards ("-", comb) >= 0 && comb != "-")) { tree t= rhs; if (is_compound (t, "render-key", 1)) t= t[0]; if (is_func (t, WITH)) t= t[N(t)-1]; string r= as_string (t); if (starts (r, "<") && !starts (r, "<#")) if (cork_to_utf8 (r) != r) rhs= tree (CONCAT, rhs, " (" * r(1, N(r)-1) * ")"); call ("set-temporary-message", tree (CONCAT, "keyboard shortcut: ", rew), rhs, shorth == ""? 1: 3000); } if ((status & 1) == 1) cmd (); else if (N(shorth) > 0) call ("kbd-insert", shorth); //cout << "Mark= " << sh_mark << "\n"; return true; } return false; }
static int checked(void *a) { int hashval; struct marker *m; hashval=((int)a)%hashsize; for(m=hash[hashval];m;m=m->next) if(m->marked == a) return 1; m=new_marker(); m->marked=a; m->next=hash[hashval]; hash[hashval]=m; hashed++; if(hashed / REHASH_LIMIT > hashsize) { struct marker **new_hash,*next; int new_hashsize; int e; new_hashsize=REHASH_FORMULA(hashsize); new_hash=(struct marker **)xalloc(sizeof(struct marker **)*new_hashsize); memset((char *)new_hash,0,sizeof(struct marker **)*new_hashsize); for(e=0;e<hashsize;e++) { for(m=hash[e];m;m=next) { next=m->next; m->next=new_hash[((int)m->marked)%new_hashsize]; new_hash[((int)m->marked)%new_hashsize]=m; } } free((char *)hash); hash=new_hash; hashsize=new_hashsize; } return 0; }
//----------------------------------------------------------------------------- /// Swap buffering for the markers void Profiler::synchronizeFrame() { // Don't do anything when frozen if(m_freeze_state == FROZEN) return; // Avoid using several times getTimeMilliseconds(), which would yield different results double now = getTimeMilliseconds(); // Swap buffers int old_write_id = m_write_id; m_write_id = !m_write_id; // For each thread: ThreadInfoList::iterator it_end = m_thread_infos.end(); for(ThreadInfoList::iterator it = m_thread_infos.begin() ; it != it_end ; it++) { // Get the thread information ThreadInfo& ti = *it; MarkerList& old_markers_done = ti.markers_done[old_write_id]; MarkerStack& old_markers_stack = ti.markers_stack[old_write_id]; MarkerList& new_markers_done = ti.markers_done[m_write_id]; MarkerStack& new_markers_stack = ti.markers_stack[m_write_id]; // Clear the containers for the new frame new_markers_done.clear(); while(!new_markers_stack.empty()) new_markers_stack.pop(); // Finish the markers in the stack of the previous frame // and start them for the next frame. // For each marker in the old stack: while(!old_markers_stack.empty()) { // - finish the marker for the previous frame and add it to the old "done" list Marker& m = old_markers_stack.top(); m.end = now - m_time_last_sync; old_markers_done.push_front(m); // - start a new one for the new frame Marker new_marker(0.0, -1.0, m.name.c_str(), m.color); new_markers_stack.push(new_marker); // - next iteration old_markers_stack.pop(); } } // Remember the date of last synchronization m_time_between_sync = now - m_time_last_sync; m_time_last_sync = now; // Freeze/unfreeze as needed if(m_freeze_state == WAITING_FOR_FREEZE) m_freeze_state = FROZEN; else if(m_freeze_state == WAITING_FOR_UNFREEZE) m_freeze_state = UNFROZEN; }