void editor_exit(void) { Text *txt = editor.txt; if(text_modified(txt)){ int choice = judgebox_manager("File not save,save?"); switch(choice) { case 0: return; case 1: text_free(txt); break; case 2: if(text_save(txt) == 2){ char * f = inputbox_manager("please input filename:"); text_saveas(txt,f); free(f); text_free(txt); } } } FreeMenu(editor.root); clipborad_close(editor.cli); print_close(); vga_close(); }
/* * Check whether tk requires a ')' and if so print it */ static void print_close_token(printer_t *p, pp_close_token_t *tk) { if (tk_has_close_par(tk)) { if (p->area.truncate) { if (p->col + 5 <= p->margin) { // tuncate mode, no pending tokens and enough space for ') ...' assert(!p->full_line && p->pending_tokens.size == 0); print_close(p, tk); } else if (p->col + 4 == p->margin) { // truncate mode, no pending tokens, space for 4 more characters assert(!p->full_line && p->pending_tokens.size == 0); p->pending_col = p->col; p->col ++; pvector_push(&p->pending_tokens, tag_close(tk)); } else if (!p->full_line) { // pending tokens, line not full assert(p->pending_tokens.size > 0); if (p->col < p->margin) { // enough space for one more ')' p->col ++; pvector_push(&p->pending_tokens, tag_close(tk)); } else { // no space for ')' print_pending_truncated(p); free_close_token(p, tk); p->full_line = true; } } else { // the line is full assert(p->pending_tokens.size == 0); free_close_token(p, tk); } } else { // not truncation print_close(p, tk); } } }
int main(int argc, char *argv[]) { print_level = LOG_NOTICE; // print_level = LOG_DEBUG; if (!parse_commandline(argc, argv)) { help(); return 1; } sprintf(program_info, "pidp11_blinkenlightd - Blinkenlight API server daemon for PiDP11 %s", VERSION); // info(); print(LOG_INFO, "Start\n"); // link set/get events blinkenlight_api_panel_get_controlvalues_evt = on_blinkenlight_api_panel_get_controlvalues; blinkenlight_api_panel_set_controlvalue_evt = on_blinkenlight_api_panel_set_controlvalue; blinkenlight_api_panel_set_controlvalues_evt = on_blinkenlight_api_panel_set_controlvalues; blinkenlight_api_panel_get_state_evt = on_blinkenlight_api_panel_get_state; blinkenlight_api_panel_set_state_evt = on_blinkenlight_api_panel_set_state; blinkenlight_api_panel_get_mode_evt = on_blinkenlight_api_panel_get_mode; blinkenlight_api_panel_set_mode_evt = on_blinkenlight_api_panel_set_mode; blinkenlight_api_get_info_evt = on_blinkenlight_api_get_info; register_controls(); if (opt_test) { printf("Dump of register <-> control data struct:\n"); blinkenlight_panels_diagprint(blinkenlight_panel_list, stdout); exit(0); } gpio_mux_thread_start(); gpiopattern_start_thread(); blinkenlight_api_server(); // does never end! print_close(); // well .... blinkenlight_panels_destructor(blinkenlight_panel_list); return 0; }
/* * Print all the pending tokens. * Free all pending tokens and empty the pending_vector. * - p->pending_col = column where printing should start */ static void print_pending(printer_t *p) { pvector_t *v; void *tk; bool space; uint32_t i, n; // restore p->col p->col = p->pending_col; v = &p->pending_tokens; n = v->size; assert(n > 0); // no space before the first token space = false; for (i=0; i<n; i++) { tk = v->data[i]; switch (ptr_tag(tk)) { case PP_TOKEN_OPEN_TAG: if (space) pp_space(p); print_label(p, untag_open(tk)); space = tk_sep_allowed(untag_open(tk)); break; case PP_TOKEN_ATOMIC_TAG: if (space) pp_space(p); print_atomic(p, untag_atomic(tk)); space = true; break; case PP_TOKEN_CLOSE_TAG: print_close(p, untag_close(tk)); space = true; break; case PP_TOKEN_SEPARATOR_TAG: // no space before or after that token print_atomic(p, untag_separator(tk)); space = false; break; } } pvector_reset(v); }
int main(int argc, char *argv[]) { print_level = LOG_NOTICE; // print_level = LOG_DEBUG; parse_commandline(argc, argv); /* if history-lowpass is used ... if ((opt_switch_mux_frequency / SWITCH_LOWPASS_FREQUENCY) > MAX_BLINKENLIGHT_HISTORY_ENTRIES) { print(LOG_ERR, "Configuration error: multiplexing with %d Hz, Switch lowpass %d Hz:\n", opt_mux_frequency, SWITCH_LOWPASS_FREQUENCY) ; print(LOG_ERR, " would need %d value history entries, but only %d available!\n", (opt_mux_frequency / SWITCH_LOWPASS_FREQUENCY), MAX_BLINKENLIGHT_HISTORY_ENTRIES) ; exit(1); } */ sprintf(program_info, "PDP-15 blinkenlightd - Blinkenlight API server daemon for PDP-15 %s", VERSION); info(); print(LOG_INFO, "Start\n"); #ifdef TEST while(1) { struct timespec ts; ts.tv_sec = 0; ts.tv_nsec = 1000 * 100000/*microsecs*/; nanosleep(&ts, NULL); } exit(0); #endif // link set/get events blinkenlight_api_panel_get_controlvalues_evt = on_blinkenlight_api_panel_get_controlvalues; blinkenlight_api_panel_set_controlvalues_evt = on_blinkenlight_api_panel_set_controlvalues; blinkenlight_api_panel_get_state_evt = on_blinkenlight_api_panel_get_state; blinkenlight_api_panel_set_state_evt = on_blinkenlight_api_panel_set_state; blinkenlight_api_panel_get_mode_evt = on_blinkenlight_api_panel_get_mode; blinkenlight_api_panel_set_mode_evt = on_blinkenlight_api_panel_set_mode; blinkenlight_api_get_info_evt = on_blinkenlight_api_get_info; register_controls(); if (opt_test) { printf("Dump of register <-> control data struct:\n"); blinkenlight_panels_diagprint(blinkenlight_panel_list, stdout); exit(0); } threads_start(); // does never end! blinkenlight_api_server(); // does never end! print_close(); // well .... blinkenlight_panels_destructor(blinkenlight_panel_list); return 0; }