int checkHold(){ int x0, y0, x1, y1; time_t start; time_t end; static int firstCall = 1; if (firstCall) { firstCall = 0; time(&start); get_cursor(&x0, &y0); return 0; } sched_yield(); get_cursor(&x1, &y1); if ( (abs(x0-x1)+abs(y0-y1)) > 3 ) { x0 = x1; y0 = y1; time(&start); return 0; } time(&end); printf("%lf\n", difftime(end, start) ); if ( difftime(end, start) > 3 ) { time(&start); get_cursor(&x0, &y0); printf("I have got the cursor\n"); return 1; } return 0; }
void set(CURSOR_TYPE type) { // Change only if it's a valid cursor if (type != NUM_CURSORS) { current_cursor = type; } else if (current_cursor == NUM_CURSORS) { // Except if the current one is also invalid. // In this case, change to a valid one. current_cursor = NORMAL; } #if SDL_VERSION_ATLEAST(2,0,0) SDL_Cursor * cursor_image = get_cursor(current_cursor); #else const CURSOR_TYPE new_cursor = use_color_cursors() && color_ready ? cursor::NO_CURSOR : current_cursor; SDL_Cursor * cursor_image = get_cursor(new_cursor); #endif // Causes problem on Mac: //if (cursor_image != NULL && cursor_image != SDL_GetCursor()) SDL_SetCursor(cursor_image); SDL_ShowCursor(SDL_ENABLE); }
bool mouse_is_hovering(button_t * b) { if(get_cursor()->pos.x > b->pos.x && get_cursor()->pos.x < b->pos.x + b->width && get_cursor()->pos.y > b->pos.y && get_cursor()->pos.y < b->pos.y + b->height) return true; return false; }
friend iterator_difference_t<I> operator-(common_iterator<I, S> const &end, common_iterator<I, S> const &begin) { common_cursor const &this_ = get_cursor(begin), &that = get_cursor(end); return that.is_sentinel() ? (this_.is_sentinel() ? 0 : that.se() - this_.it()) : (this_.is_sentinel() ? that.it() - this_.se() : that.it() - this_.it()); }
void tf_move_cursor(TxtField *tf, const int dir) { if (tf == NULL) return; if (dir < 0 && get_cursor(X) > tf->x) --tf->cursor_offset; else if (dir > 0 && tf->cursor_offset < 0) ++tf->cursor_offset; move(tf->y, get_cursor(X) + tf->cursor_offset); }
static int do_if_clicked_handle(DDisplay *ddisp, ModifyTool *tool, Point *clickedpoint, GdkEventButton *event) { DiaObject *obj; Handle *handle; real dist; handle = NULL; dist = diagram_find_closest_handle(ddisp->diagram, &handle, &obj, clickedpoint); if (handle_is_clicked(ddisp, handle, clickedpoint)) { tool->state = STATE_MOVE_HANDLE; tool->break_connections = TRUE; tool->last_to = handle->pos; tool->handle = handle; tool->object = obj; gdk_pointer_grab (gtk_widget_get_window(ddisp->canvas), FALSE, GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK, NULL, NULL, event->time); tool->start_at = handle->pos; tool->start_time = time_micro(); ddisplay_set_all_cursor(get_cursor(CURSOR_SCROLL)); return TRUE; } return FALSE; }
void update_lcd(void) { if(show_settings_time) //Einstellungen anzeigen { lcd_clrscr(); lcd_gotoxy(0,0); lcd_puts(font_name); char buf[3]; itoa(font_size,buf,10); lcd_puts(buf); } else //normaler Editor { lcd_command(LCD_DISP_ON); lcd_gotoxy(0,0); //_delay_us(30); uint8_t x; uint8_t cx, cy, vx, vy; get_viewport(&vx, &vy); get_cursor(&cx, &cy); for(x=0;x<LCD_WIDTH;x++) lcd_putc(get_text_buffer(vy)[vx+x]); for(x=0;x<LCD_WIDTH;x++) lcd_putc(get_text_buffer(vy+1)[vx+x]); lcd_gotoxy(cx-vx,cy-vy); lcd_command(LCD_DISP_ON_CURSOR); } }
// ------------------------------------------------------------------------ // window to display an adventure map // determine correct cursor to display // ------------------------------------------------------------------------ void t_adventure_map_window::update_cursor( t_screen_point point ) { t_mouse_window* cursor = get_new_cursor( point ); if (cursor != get_cursor( false )) set_cursor( cursor ); }
friend iterator_rvalue_reference_t<I> indirect_move(common_iterator<I, S> const &it) noexcept(noexcept(iter_move(std::declval<I const &>()))) { common_cursor const &cur = get_cursor(it); RANGES_ASSERT(!cur.is_sentinel()); return iter_move(cur.it()); }
Point apc_pointer_get_hot_spot( Handle self) { Point hot_spot; int idx; int id = get_cursor(self, nil, nil, &hot_spot, nil); XFontStruct *fs; XCharStruct *cs; Point ret = {0,0}; if ( id < crDefault || id > crUser) return ret; if ( id == crUser) return hot_spot; if ( !load_pointer_font()) return ret; idx = cursor_map[id]; fs = guts.pointer_font; if ( !fs-> per_char) cs = &fs-> min_bounds; else if ( idx < fs-> min_char_or_byte2 || idx > fs-> max_char_or_byte2) { int default_char = fs-> default_char; if ( default_char < fs-> min_char_or_byte2 || default_char > fs-> max_char_or_byte2) default_char = fs-> min_char_or_byte2; cs = fs-> per_char + default_char - fs-> min_char_or_byte2; } else cs = fs-> per_char + idx - fs-> min_char_or_byte2; ret. x = -cs->lbearing; ret. y = guts.cursor_height - cs->ascent; if ( ret. x < 0) ret. x = 0; if ( ret. y < 0) ret. y = 0; if ( ret. x >= guts. cursor_width) ret. x = guts. cursor_width - 1; if ( ret. y >= guts. cursor_height) ret. y = guts. cursor_height - 1; return ret; }
void print_char(char ch, int row, int col){ unsigned char* vm = (unsigned char*)VIDEO_ADDRESS; //get the memory offset to write the char. int offset = get_screen_offset(row, col); if(offset == -1){ offset = get_cursor(); } switch(ch){ case '\n': //row may be changed to the row of cursor row = offset / (MAX_COLS * 2); //scroll screen offset = get_screen_offset(row, MAX_COLS - 1); break; default: vm[offset] = ch; vm[offset + 1] = text_color; break; } offset += 2; //move offset to the next cell offset = handle_scroll(offset); //scroll if required set_cursor(offset); //update the location of cursor }
int main( int argc, char *argv[] ) { struct map_data *map; if ( init(&map, argc, argv) ) { exit( 0 ); } int cur = '\0'; point_t start = get_start_point( map ); do { clear(); print_map( map ); process_key( cur ); switch ( cur ) { default: { point_t target = get_cursor(); //mvprintw( 0, 0, "Cursor was at : (%d, %d)", target.x, target.y); path_t *path_to_target = search_path( start, target, map ); print_path( path_to_target ); refresh(); } } refresh(); } while ( (cur = getch()) != 'q' ); cleanup_all(); return 0; }
void edit_interface_rep::draw_graphics (renderer ren) { if (got_focus || full_screen) { cursor cu= get_cursor(); if (over_graphics(cu->ox, cu->oy) && inside_active_graphics ()) { eval ("(graphics-reset-context 'graphics-cursor)"); draw_graphical_object (ren); string tm_curs= as_string (eval ("graphics-texmacs-pointer")); if (tm_curs != "none") { if (tm_curs == "graphics-cross") { ren->set_line_style (pixel); ren->set_color (red); ren->line (cu->ox, cu->oy-5*pixel, cu->ox, cu->oy+5*pixel); ren->line (cu->ox-5*pixel, cu->oy, cu->ox+5*pixel, cu->oy); } else if (tm_curs == "graphics-cross-arrows") { static int s= 6*pixel, a= 2*pixel; ren->set_line_style (pixel); ren->set_color (red); ren->line (cu->ox, cu->oy-s, cu->ox, cu->oy+s); ren->line (cu->ox-s, cu->oy, cu->ox+s, cu->oy); ren->line (cu->ox, cu->oy-s,cu->ox-a, cu->oy-s+a); ren->line (cu->ox, cu->oy-s, cu->ox+a, cu->oy-s+a); ren->line (cu->ox, cu->oy+s, cu->ox-a, cu->oy+s-a); ren->line (cu->ox, cu->oy+s, cu->ox+a, cu->oy+s-a); ren->line (cu->ox-s, cu->oy, cu->ox-s+a, cu->oy+a); ren->line (cu->ox-s, cu->oy, cu->ox-s+a, cu->oy-a); ren->line (cu->ox+s, cu->oy, cu->ox+s-a, cu->oy+a); ren->line (cu->ox+s, cu->oy, cu->ox+s-a, cu->oy-a); } } } else eval ("(graphics-reset-context 'text-cursor)"); } }
/* * invert_label - highlight the label of the given menu item. */ void invert_label(int state, MENUITEM *m) { unsigned i, j; int col_offset, savettrow, savettcol; char *lp; get_cursor(&savettrow, &savettcol); /* * Leave the command name bold */ col_offset = (state || !(lp=strchr(m->label, ' '))) ? 0 : (lp - m->label); movecursor((int)m->tl.r, (int)m->tl.c + col_offset); flip_inv(state); for(i = m->tl.r; i <= m->br.r; i++) for(j = m->tl.c + col_offset; j <= m->br.c; j++) if(i == m->lbl.r && j == m->lbl.c + col_offset && m->label){ lp = m->label + col_offset; /* show label?? */ while(*lp && j++ < m->br.c) putc(*lp++, stdout); continue; } else putc(' ', stdout); if(state) flip_inv(FALSE); movecursor(savettrow, savettcol); }
void puts( const char *str ) { if ( (s_x < 0) || (s_y < 0) ) get_cursor(); puts_xy( &s_x, &s_y, str ); set_cursor( s_x, s_y ); }
static void modify_button_press(ModifyTool *tool, GdkEventButton *event, DDisplay *ddisp) { Point clickedpoint; DiaObject *clicked_obj; gboolean some_selected; ddisplay_untransform_coords(ddisp, (int)event->x, (int)event->y, &clickedpoint.x, &clickedpoint.y); /* don't got to single handle movement if there is more than one object selected */ some_selected = g_list_length (ddisp->diagram->data->selected) > 1; if (!some_selected && do_if_clicked_handle(ddisp, tool, &clickedpoint, event)) return; clicked_obj = click_select_object(ddisp, &clickedpoint, event); if (!some_selected && do_if_clicked_handle(ddisp, tool, &clickedpoint, event)) return; if ( clicked_obj != NULL ) { tool->state = STATE_MOVE_OBJECT; tool->object = clicked_obj; tool->move_compensate = clicked_obj->position; point_sub(&tool->move_compensate, &clickedpoint); tool->break_connections = TRUE; /* unconnect when not grabbing handles, just setting to * FALSE is not enough. Need to refine the move op, too. */ gdk_pointer_grab (gtk_widget_get_window(ddisp->canvas), FALSE, GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK, NULL, NULL, event->time); tool->start_at = clickedpoint; tool->start_time = time_micro(); ddisplay_set_all_cursor(get_cursor(CURSOR_SCROLL)); } else { tool->state = STATE_BOX_SELECT; tool->start_box = clickedpoint; tool->end_box = clickedpoint; tool->x1 = tool->x2 = (int) event->x; tool->y1 = tool->y2 = (int) event->y; if (tool->gc == NULL) { tool->gc = gdk_gc_new(gtk_widget_get_window(ddisp->canvas)); gdk_gc_set_line_attributes(tool->gc, 1, GDK_LINE_ON_OFF_DASH, GDK_CAP_BUTT, GDK_JOIN_MITER); gdk_gc_set_foreground(tool->gc, &color_gdk_white); gdk_gc_set_function(tool->gc, GDK_XOR); } gdk_draw_rectangle (gtk_widget_get_window (ddisp->canvas), tool->gc, FALSE, tool->x1, tool->y1, tool->x2 - tool->x1, tool->y2 - tool->y1); gdk_pointer_grab (gtk_widget_get_window (ddisp->canvas), FALSE, GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK, NULL, NULL, event->time); } }
int main_menu() { continue_condition = true; fade_condition = false; function_to_call = NULL; darken = 127; int failure = 0; initialize_main_menu_buttons(); int ipc_status; message msg; int r; char * display_name = (char*)malloc(sizeof(char) * strlen("Player name: ")+MAX_PLAYER_NAME_LENGTH); strcpy(display_name, "Player name: "); display_name = strcat(display_name, get_program_playername()); if(!failure){ do{ /* Get a request message. */ if ( (r = driver_receive(ANY, &msg, &ipc_status)) != 0 ) { printf("driver_receive failed with: %d", r); continue; } if (is_ipc_notify(ipc_status)) { /* received notification */ switch (_ENDPOINT_P(msg.m_source)) { case HARDWARE: /* hardware interrupt notification */ if (msg.NOTIFY_ARG & get_kbd_irq_set()){ /* subscribed kbd interrupt */ kbd_int_handler(); } if (msg.NOTIFY_ARG & get_rtc_irq_set()) { /* subscribed timer interrupt */ if(rtc_ih()) failure = 1; getDateString(get_date_str_ptr()); } if(msg.NOTIFY_ARG & get_timer_irq_set()){ timer_int_handler(); main_menu_render(); } if (msg.NOTIFY_ARG & get_mouse_irq_set()) { /* subscribed timer interrupt */ mouse_int_handler(); } break; default: break; /* no other notifications expected: do nothing */ } } else {/* received a standard message, not a notification */ /* no standard messages expected: do nothing */ } if(mouse_is_updated()) { assign_mouse(get_previous_mouse(), get_mouse()); assign_mouse(get_mouse(), get_mouse_state()); main_menu_mouse_event(get_previous_mouse(), get_mouse()); move_cursor(get_cursor(), get_mouse()->coords); } } while(continue_condition); } return failure; }
css_error css__compose_cursor(const css_computed_style *parent, const css_computed_style *child, css_computed_style *result) { css_error error; lwc_string **urls = NULL; uint8_t type = get_cursor(child, &urls); if ((child->uncommon == NULL && parent->uncommon != NULL) || type == CSS_CURSOR_INHERIT || (child->uncommon != NULL && result != child)) { size_t n_urls = 0; lwc_string **copy = NULL; if ((child->uncommon == NULL && parent->uncommon != NULL) || type == CSS_CURSOR_INHERIT) { type = get_cursor(parent, &urls); } if (urls != NULL) { lwc_string **i; for (i = urls; (*i) != NULL; i++) n_urls++; copy = result->alloc(NULL, (n_urls + 1) * sizeof(lwc_string *), result->pw); if (copy == NULL) return CSS_NOMEM; memcpy(copy, urls, (n_urls + 1) * sizeof(lwc_string *)); } error = set_cursor(result, type, copy); if (error != CSS_OK && copy != NULL) result->alloc(copy, 0, result->pw); return error; } return CSS_OK; }
point frame::write(const point& pt, const std::string& str, int n) { CONS_ASSERT(handle, "invalid handle"); CONS_ASSERT(n>=0 && std::size_t(n) <= str.size(), "n is greater than string length"); set_cursor(pt); //throws if(waddnstr(handle.get(), str.c_str(), n)==ERR) { throw CONS_MAKE_EXCEPTION("Unable to write string to frame"); } return get_cursor(); }
//Content point frame::write(const point& pt, char ch) { CONS_ASSERT(handle, "inavlid handle"); set_cursor(pt); //throws if(waddch(handle.get(), ch)==ERR) { std::ostringstream oss; oss << "Unable to write char to frame at point: " << pt << " frame size: " << get_dimension(); throw CONS_MAKE_EXCEPTION(oss.str()); } return get_cursor(); }
point frame::write(const point& pt, const std::string& str) { CONS_ASSERT(handle, "inavlid handle"); set_cursor(pt); //throws if(waddstr(handle.get(), str.c_str())==ERR) { std::ostringstream oss; oss << "Unable to write string to frame at point: " << pt << " string size: " << str.size() << " frame size: " << get_dimension(); throw CONS_MAKE_EXCEPTION(oss.str()); } return get_cursor(); }
static void rescan_and_refresh(void) { GtkTreePath *old_path = get_cursor(); //log("old_path1:'%s'", gtk_tree_path_to_string(old_path)); //leak rescan_dirs_and_add_to_dirlist(); /* Try to restore cursor position */ //log("old_path2:'%s'", gtk_tree_path_to_string(old_path)); //leak sanitize_cursor(old_path); if (old_path) gtk_tree_path_free(old_path); }
Bool apc_pointer_set_shape( Handle self, int id) { DEFXX; Cursor uc = None; if ( id < crDefault || id > crUser) return false; XX-> pointer_id = id; id = get_cursor( self, nil, nil, nil, &uc); if ( id == crUser) { if ( uc != None || ( uc = XX-> user_pointer) != None) { if ( self != application) { if ( guts. pointer_invisible_count < 0) { if ( !XX-> flags. pointer_obscured) { XDefineCursor( DISP, XX-> udrawable, prima_null_pointer()); XX-> flags. pointer_obscured = 1; } } else { XDefineCursor( DISP, XX-> udrawable, uc); XX-> flags. pointer_obscured = 0; } XCHECKPOINT; } } else id = crArrow; } if ( id != crUser) { if ( predefined_cursors[id] == None) { predefined_cursors[id] = XCreateFontCursor( DISP, cursor_map[id]); XCHECKPOINT; } XX-> actual_pointer = predefined_cursors[id]; if ( self != application) { if ( guts. pointer_invisible_count < 0) { if ( !XX-> flags. pointer_obscured) { XDefineCursor( DISP, XX-> udrawable, prima_null_pointer()); XX-> flags. pointer_obscured = 1; } } else { XDefineCursor( DISP, XX-> udrawable, predefined_cursors[id]); XX-> flags. pointer_obscured = 0; } XCHECKPOINT; } } XFlush( DISP); if ( guts. grab_widget) apc_widget_set_capture( guts. grab_widget, true, guts. grab_confine); return true; }
extern CAMLprim value kc_cursor_jump(value caml_cursor, value key) { CAMLparam2(caml_cursor, key); KCCUR* cur = get_cursor(caml_cursor); if (! kccurjumpkey(cur, String_val(key), caml_string_length(key))) { if (kccurecode(cur) != KCENOREC) { RAISE(kccuremsg(cur)); } } CAMLreturn(Val_unit); }
void showprogress(int startCur, const char* msg, unsigned progNum) { int c = get_cursor() ; while(c > startCur) { movcursor(-1) ; c-- ; } clrline(Display_CURSOR_CUR) ; printf("%s%d", msg, progNum) ; }
void Canvas::draw_poly_P(const int8_t* poly, uint8_t scale) { if (scale == 0) return; for (;;) { int8_t dx = pgm_read_byte(poly++); int8_t dy = pgm_read_byte(poly++); if (dx == 0 && dy == 0) return; uint8_t x, y; get_cursor(x, y); x += dx*scale; y += dy*scale; draw_line(x, y); } }
point frame::write(const point& pt, std::string::const_iterator first, std::string::const_iterator last) { CONS_ASSERT(handle, "invalid handle"); set_cursor(pt); //throws if(waddnstr(handle.get(), &*first, std::distance(first, last))==ERR) { std::ostringstream oss; oss << "Unable to write string to frame no. of chars: " << std::distance(first, last) << " size: " << get_dimension() << " pos " << pt; throw CONS_MAKE_EXCEPTION(oss.str()); } return get_cursor(); }
int mail_previous (int argc, char **argv) { size_t n; mu_message_t msg; if (argc < 2) { int rc = 1; n = get_cursor (); if (n) while (--n > 0) { if (util_isdeleted (n)) continue; rc = util_get_message (mbox, n, &msg); if (rc == 0) break; } if (rc) { mu_error (_("No applicable message")); return 1; } } else { msgset_t *list = NULL; int rc = msgset_parse (argc, argv, MSG_NODELETED|MSG_SILENT, &list); if (!rc) { n = list->msg_part[0]; msgset_free (list); if (util_get_message (mbox, n, &msg)) return 1; } else { mu_error (_("No applicable message")); return 1; } } set_cursor (n); util_do_command ("print"); return 0; }
//affiche les états des processus void affiche_etats(void) { int i = 0; int l = 2; uint32_t col = 0; uint32_t lig = 0 ; get_cursor(&lig, &col); while ( i < l ) { place_curseur(i, 60); printf(" "); i++; } afficher_l0_c72(heure); i = 0; while (i < NB_PROCESSES) { place_curseur(l, 60); if( proc_table[i].state == ENDORMI ) { printf(" "); place_curseur(l, 60); printf("%s : ENDORMI", proc_table[i].name); } else if ( proc_table[i].state == ELU ) { printf(" "); place_curseur(l, 60); printf("%s : ELU", proc_table[i].name); } else if ( proc_table[i].state == MORT ) { printf(" "); place_curseur(l, 60); printf("%s : MORT", proc_table[i].name); } else if ( proc_table[i].state == ACTIVABLE ) { printf(" "); place_curseur(l, 60); printf("%s : ACTIVABLE", proc_table[i].name); } i++; l++; } place_curseur(lig, col); }
void Tree_active::on_cursor_changed() { // get the position of the cursor if (empty()) return; int id = get_cursor()->get_value(m_columns->id); // set the cursor auto begin = m_handler->get_begin_cursor(); m_handler->set_tab_cursor(begin + id); m_handler->redraw(); }