static void init_system() { cur_sale = make_new_sale(1); cursor_hide(); init_clock(); update_clock(); }
/* Device polling has timed out, so we hide the mouse to avoid further * console pollution. */ void selection_poll_timeout(void) { if (!Selmouse.sm_selecting) cursor_hide(); }
void cursor_delete(struct cursor *crsr) { cursor_hide(crsr); if (crsr->sprite) free_sprite(crsr->sprite); cursor_list_remove(crsr); g_free(crsr); }
/* Mode cleanup. */ int selection_cleanup(void) { cursor_hide(); if (Selmouse.sm_ttyfd >= 0) (void)close(Selmouse.sm_ttyfd); return 1; }
/* Parse wscons status events. */ void selection_wscons_event(struct wscons_event evt, int preclose) { switch (evt.type) { case WSCONS_EVENT_SCREEN_SWITCH: if (preclose) { if (Selmouse.sm_selecting) selarea_hide(); cursor_hide(); } else { if (!Selmouse.sm_mouse->m_disabled) open_tty(evt.value); cursor_show(); if (Selmouse.sm_selecting) selarea_show(); } break; } }
void ascii_write_init() { console_clear(); cursor_reset(); cursor_hide(); }
int main(int argc, char *argv[]) { kbd_event_t ev; coord_t coord; bool new_file; spt_t pt; con = console_init(stdin, stdout); console_clear(con); console_get_size(con, &scr_columns, &scr_rows); pane.rows = scr_rows - 1; pane.columns = scr_columns; pane.sh_row = 1; pane.sh_column = 1; /* Start with an empty sheet. */ sheet_init(&doc.sh); /* Place caret at the beginning of file. */ coord.row = coord.column = 1; sheet_get_cell_pt(&doc.sh, &coord, dir_before, &pt); sheet_place_tag(&doc.sh, &pt, &pane.caret_pos); pane.ideal_column = coord.column; if (argc == 2) { doc.file_name = str_dup(argv[1]); } else if (argc > 1) { printf("Invalid arguments.\n"); return -2; } else { doc.file_name = NULL; } new_file = false; if (doc.file_name == NULL || file_insert(doc.file_name) != EOK) new_file = true; /* Move to beginning of file. */ caret_move(-ED_INFTY, -ED_INFTY, dir_before); /* Place selection start tag. */ tag_get_pt(&pane.caret_pos, &pt); sheet_place_tag(&doc.sh, &pt, &pane.sel_start); /* Initial display */ cursor_visible = true; cursor_hide(); console_clear(con); pane_text_display(); pane_status_display(); if (new_file && doc.file_name != NULL) status_display("File not found. Starting empty file."); pane_caret_display(); cursor_show(); done = false; while (!done) { console_get_kbd_event(con, &ev); pane.rflags = 0; if (ev.type == KEY_PRESS) { /* Handle key press. */ if (((ev.mods & KM_ALT) == 0) && ((ev.mods & KM_SHIFT) == 0) && (ev.mods & KM_CTRL) != 0) { key_handle_ctrl(&ev); } else if (((ev.mods & KM_ALT) == 0) && ((ev.mods & KM_CTRL) == 0) && (ev.mods & KM_SHIFT) != 0) { key_handle_shift(&ev); } else if ((ev.mods & (KM_CTRL | KM_ALT | KM_SHIFT)) == 0) { key_handle_unmod(&ev); } } /* Redraw as necessary. */ cursor_hide(); if (pane.rflags & REDRAW_TEXT) pane_text_display(); if (pane.rflags & REDRAW_ROW) pane_row_display(); if (pane.rflags & REDRAW_STATUS) pane_status_display(); if (pane.rflags & REDRAW_CARET) pane_caret_display(); cursor_show(); } console_clear(con); return 0; }
/* Parse wsmouse events. Both motion and button events are handled. The * former move the mouse across the screen and the later create a new * selection or paste the buffer. */ void selection_wsmouse_event(struct wscons_event evt) { if (IS_MOTION_EVENT(evt.type)) { if (Selmouse.sm_selecting) selarea_hide(); cursor_hide(); switch (evt.type) { case WSCONS_EVENT_MOUSE_DELTA_X: if (Selmouse.sm_count_x >= Selmouse.sm_slowdown_x) { Selmouse.sm_count_x = 0; if (evt.value > 0) Selmouse.sm_x++; else if (Selmouse.sm_x != 0) Selmouse.sm_x--; if (Selmouse.sm_x > Selmouse.sm_max_x) Selmouse.sm_x = Selmouse.sm_max_x; } else Selmouse.sm_count_x++; break; case WSCONS_EVENT_MOUSE_DELTA_Y: if (Selmouse.sm_count_y >= Selmouse.sm_slowdown_y) { Selmouse.sm_count_y = 0; if (evt.value < 0) Selmouse.sm_y++; else if (Selmouse.sm_y != 0) Selmouse.sm_y--; if (Selmouse.sm_y > Selmouse.sm_max_y) Selmouse.sm_y = Selmouse.sm_max_y; } else Selmouse.sm_count_y++; break; case WSCONS_EVENT_MOUSE_DELTA_Z: break; default: log_warnx("unknown event"); } if (Selmouse.sm_selecting) selarea_show(); cursor_show(); } else if (IS_BUTTON_EVENT(evt.type)) { switch (evt.type) { case WSCONS_EVENT_MOUSE_UP: if (evt.value == Selmouse.sm_but_select) { /* End selection */ selarea_end(); selarea_hide(); } break; case WSCONS_EVENT_MOUSE_DOWN: if (evt.value == Selmouse.sm_but_select) { /* Start selection */ selarea_start(); cursor_hide(); selarea_show(); } else if (evt.value == Selmouse.sm_but_paste) { /* Paste selection */ selarea_paste(); break; } break; default: log_warnx("unknown button event"); } } }
/* Hide the hotspot navigation cursor */ void hotspot_hide(void) { if (dts->top->hotspot_cursor) cursor_hide(dts->top->hotspot_cursor); }