static void dirty_check(void) { if (!dirty || dummy) return; term_resize_dirty(); if (full_redraw) { full_redraw = FALSE; /* first clear the screen so curses will be forced to redraw the screen */ term_clear(); term_refresh(NULL); mainwindows_redraw(); statusbar_redraw(NULL, TRUE); } mainwindows_redraw_dirty(); statusbar_redraw_dirty(); term_refresh(NULL); dirty = FALSE; }
/* * Tidy up the term ready to leave Zile (temporarily or permanently!). */ void term_tidy(void) { term_move(term_height() - 1, 0); term_clrtoeol(); term_attrset(1, FONT_NORMAL); term_refresh(); }
static void draw_minibuf_read (const char *prompt, const char *value, size_t prompt_len, char *match, size_t pointo) { int margin = 1, n = 0; term_minibuf_write (prompt); if (prompt_len + pointo + 1 >= term_width ()) { margin++; term_addch ('$'); n = pointo - pointo % (term_width () - prompt_len - 2); } term_addnstr (value + n, MIN (term_width () - prompt_len - margin, strlen (value) - n)); term_addnstr (match, strlen (match)); if (strlen (value + n) >= term_width () - prompt_len - margin) { term_move (term_height () - 1, term_width () - 1); term_addch ('$'); } term_move (term_height () - 1, prompt_len + margin - 1 + pointo % (term_width () - prompt_len - margin)); term_refresh (); }
static void view_remove_line(TEXT_BUFFER_VIEW_REC *view, LINE_REC *line, int linecount) { int realcount; view_bookmarks_check(view, line); if (view->buffer->cur_line == line) { /* the last line is being removed */ LINE_REC *prevline; prevline = view->buffer->first_line == line ? NULL : textbuffer_line_last(view->buffer); view->cache->last_linecount = prevline == NULL ? 0 : view_get_linecount(view, prevline); } if (view->buffer->first_line == line) { /* first line in the buffer - this is the most commonly removed line.. */ if (view->bottom_startline == line) { /* very small scrollback.. */ view->bottom_startline = view->bottom_startline->next; view->bottom_subline = 0; } if (view->startline == line) { /* removing the first line in screen */ int is_last = view->startline->next == NULL; realcount = view_scroll(view, &view->startline, &view->subline, linecount, FALSE); view->ypos -= realcount; view->empty_linecount += linecount-realcount; if (is_last == 1) view->startline = NULL; } } else { if (textbuffer_line_exists_after(view->bottom_startline, line)) { realcount = view_scroll(view, &view->bottom_startline, &view->bottom_subline, -linecount, FALSE); view->empty_linecount += linecount-realcount; } if (textbuffer_line_exists_after(view->startline, line)) { view_remove_line_update_startline(view, line, linecount); } } view->bottom = view_is_bottom(view); if (view->bottom) view->more_text = FALSE; if (view->window != NULL) term_refresh(view->window); }
/* * Tidy and close the terminal ready to leave Zile. */ void term_finish (void) { term_move (term_height () - 1, 0); term_clrtoeol (); term_attrset (FONT_NORMAL); term_refresh (); term_close (); }
/* Redraw a view to window */ void textbuffer_view_redraw(TEXT_BUFFER_VIEW_REC *view) { g_return_if_fail(view != NULL); if (view->window != NULL) { view->dirty = FALSE; view_draw_top(view, view->height, TRUE); term_refresh(view->window); } }
void gui_entry_set_active(GUI_ENTRY_REC *entry) { active_entry = entry; if (entry != NULL) { term_move_cursor(entry->xpos + entry->scrpos + entry->promptlen, entry->ypos); term_refresh(NULL); } }
static void gui_entry_draw(GUI_ENTRY_REC *entry) { if (entry->redraw_needed_from >= 0) { gui_entry_draw_from(entry, entry->redraw_needed_from); entry->redraw_needed_from = -1; } term_move_cursor(entry->xpos + entry->scrpos + entry->promptlen, entry->ypos); term_refresh(NULL); }
/* Scroll the view up/down */ void textbuffer_view_scroll(TEXT_BUFFER_VIEW_REC *view, int lines) { int count; g_return_if_fail(view != NULL); count = view_scroll(view, &view->startline, &view->subline, lines, TRUE); view->ypos += lines < 0 ? count : -count; view->bottom = view_is_bottom(view); if (view->bottom) view->more_text = FALSE; if (view->window != NULL) term_refresh(view->window); }
int set_value_start(t_edit_line *line, struct pollfd *pfd, int *pr) { if (modular_history(0, NULL)->cmd != NULL) free(modular_history(0, NULL)->cmd); modular_history(0, NULL)->cmd = StringToArray(line->output_string, STRING_NO_FREE); term_refresh(line); printString(line->output_string); curseur(line->cur_pos_x, line->cur_pos_y); pfd->fd = STDIN_FILENO; pfd->events = POLLIN; *pr = poll(pfd, 1, 5090000); return (0); }
MAIN_WINDOW_REC *mainwindow_create(void) { MAIN_WINDOW_REC *rec, *parent; int space; rec = g_new0(MAIN_WINDOW_REC, 1); rec->dirty = TRUE; rec->width = term_width; if (mainwindows == NULL) { active_mainwin = rec; rec->first_line = screen_reserved_top; rec->last_line = term_height-1 - screen_reserved_bottom; rec->height = rec->last_line-rec->first_line+1; } else { parent = WINDOW_MAIN(active_win); if (MAIN_WINDOW_TEXT_HEIGHT(parent) < WINDOW_MIN_SIZE+NEW_WINDOW_SIZE) parent = find_window_with_room(); if (parent == NULL) return NULL; /* not enough space */ space = parent->height / 2; rec->first_line = parent->first_line; rec->last_line = rec->first_line + space; rec->height = rec->last_line-rec->first_line+1; parent->first_line = rec->last_line+1; parent->height = parent->last_line-parent->first_line+1; mainwindow_resize(parent, 0, -space-1); } rec->screen_win = mainwindow_create_screen(rec); term_refresh(NULL); mainwindows = g_slist_append(mainwindows, rec); signal_emit("mainwindow created", 1, rec); return rec; }
static void console_refresh (void) { if (!HEADLESS && !enable_console) { return; } static char tmp[MAXSTR]; static char cursor_char[2] = { '_', '\0' }; strlcpy(tmp, wid_text, cursor_x + 1); strlcat(tmp, cursor_char, sizeof(tmp)); strlcat(tmp, wid_text + cursor_x, sizeof(tmp)); console_clear(); term_goto(0, TERM_HEIGHT - 1); term_putf("gorynlich> "); term_putf(tmp); term_putf(" "); term_refresh(); }
static void view_insert_line(TEXT_BUFFER_VIEW_REC *view, LINE_REC *line) { int linecount, ypos, subline; if (!view->bottom) view->more_text = TRUE; if (view->bottom_startline == NULL) { view->startline = view->bottom_startline = view->buffer->first_line; } if (view->buffer->cur_line != line && !textbuffer_line_exists_after(view->bottom_startline, line)) return; linecount = view->cache->last_linecount; view->ypos += linecount; if (view->empty_linecount > 0) { view->empty_linecount -= linecount; if (view->empty_linecount >= 0) linecount = 0; else { linecount = -view->empty_linecount; view->empty_linecount = 0; } } if (linecount > 0) { view_scroll(view, &view->bottom_startline, &view->bottom_subline, linecount, FALSE); } if (view->bottom) { if (view->scroll && view->ypos >= view->height) { linecount = view->ypos-view->height+1; view_scroll(view, &view->startline, &view->subline, linecount, FALSE); view->ypos -= linecount; } else { view->bottom = view_is_bottom(view); } if (view->window != NULL) { ypos = view->ypos+1 - view->cache->last_linecount; if (ypos >= 0) subline = 0; else { subline = -ypos; ypos = 0; } if (ypos < view->height) { view_line_draw(view, line, subline, ypos, view->height - ypos); } } } if (view->window != NULL) term_refresh(view->window); }
/* Returns number of lines actually scrolled */ static int view_scroll(TEXT_BUFFER_VIEW_REC *view, LINE_REC **lines, int *subline, int scrollcount, int draw_nonclean) { int linecount, realcount, scroll_visible; if (*lines == NULL) return 0; /* scroll down */ scroll_visible = lines == &view->startline; realcount = -*subline; scrollcount += *subline; *subline = 0; while (scrollcount > 0) { linecount = view_get_linecount(view, *lines); if ((scroll_visible && *lines == view->bottom_startline) && (scrollcount >= view->bottom_subline)) { *subline = view->bottom_subline; realcount += view->bottom_subline; scrollcount = 0; break; } realcount += linecount; scrollcount -= linecount; if (scrollcount < 0) { realcount += scrollcount; *subline = linecount+scrollcount; scrollcount = 0; break; } if ((*lines)->next == NULL) break; *lines = (*lines)->next; } /* scroll up */ while (scrollcount < 0 && (*lines)->prev != NULL) { *lines = (*lines)->prev; linecount = view_get_linecount(view, *lines); realcount -= linecount; scrollcount += linecount; if (scrollcount > 0) { realcount += scrollcount; *subline = scrollcount; break; } } if (scroll_visible && realcount != 0 && view->window != NULL) { if (realcount <= -view->height || realcount >= view->height) { /* scrolled more than screenful, redraw the whole view */ textbuffer_view_redraw(view); } else { term_set_color(view->window, ATTR_RESET); term_window_scroll(view->window, realcount); if (draw_nonclean) { if (realcount < 0) view_draw_top(view, -realcount, TRUE); else view_draw_bottom(view, realcount); } term_refresh(view->window); } } return realcount >= 0 ? realcount : -realcount; }
void* Worker::run() { for (int i = 0;; i++) { printf("thread %lu, loop %d - waiting for item...\n", (long unsigned int)self(), i); WorkItem* item = m_queue.remove(); printf("thread %lu, loop %d - got one item\n", (long unsigned int)self(), i); { int temps = 0, fdecoding = 0; // // ON CREE UN OBJET POUR LA MESURE DU TEMPS DE SIMULATION (REMISE A ZERO POUR CHAQUE Eb/N0) // CTimer temps_ecoule(true); CTimer term_refresh(true); CErrorAnalyzer errCounters(item->getData(), frameErrorLimit, false, false); CErrorAnalyzer errCounter (item->getData(), frameErrorLimit, true, true); // // ON CREE L'OBJET EN CHARGE DES INFORMATIONS DANS LE TERMINAL UTILISATEUR // CTerminal terminal(&errCounters, &temps_ecoule, item->getNoise()->getEb_N0()); // // ON GENERE LA PREMIERE TRAME BRUITEE // item->getNoise()->generate(); errCounter.store_enc_bits(); while( 1 ) { // // ON LANCE LE TRAITEMENT SUR PLUSIEURS THREAD... // CTimer essai(true); // decoder->decode( item->getData()->get_t_noise_data(), item->getData()->get_t_decode_data(), numberIter ); // temps += essai.get_time_ms(); fdecoding += 1; #pragma omp sections { #pragma omp section { // item->getNoise()->generate(); } #pragma omp section { // errCounter.generate(); } } // // ON COMPTE LE NOMBRE D'ERREURS DANS LA TRAME DECODE // // errCounters.reset_internals(); // errCounters.accumulate( &errCounter ); // // ON compares the frame error with the limits imposed by the user. // If it exceeds then displays the results on Eb / N0 current. // // if ( errCounters.fe_limit_achieved() == true ){ // break; // } // // AFFICHAGE A L'ECRAN DE L'EVOLUTION DE LA SIMULATION SI NECESSAIRE // // if( term_refresh.get_time_sec() >= 1 ){ // term_refresh.reset(); // terminal.temp_report(); // } // if( (simTotalTimer->get_time_sec() >= STOP_TIMER_SECOND) && (STOP_TIMER_SECOND != -1) ) // { // printf("(II) THE SIMULATION HAS STOP DUE TO THE (USER) TIME CONTRAINT.\n"); // printf("(II) PERFORMANCE EVALUATION WAS PERFORMED ON %d RUNS, TOTAL TIME = %dms\n", fdecoding, temps); // temps /= fdecoding; // printf("(II) + TIME / RUN = %dms\n", temps); // int workL = 4 * numberThreadOnGpu; // int kbits = workL * _N / temps ; // float mbits = ((float)kbits) / 1000.0; // printf("(II) + DECODER LATENCY (ms) = %d\n", temps); // printf("(II) + DECODER THROUGHPUT (Mbps)= %.1f\n", mbits); // printf("(II) + (%.2fdB, %dThd : %dCw, %dits) THROUGHPUT = %.1f\n", item->getNoise()->getEb_N0(), numberThreadOnGpu, workL, numberIter, mbits); // cout << endl << "Temps = " << temps << "ms : " << kbits; // cout << "kb/s : " << ((float)temps/numberThreadOnGpu) << "ms/frame" << endl << endl; // break; // } } // terminal.final_report(); } delete item; } return NULL; }
void show_status (int dtr_up) { int baud, bits, stopbits, mctl; enum flowcntrl_e flow; enum parity_e parity; term_refresh(tty_fd); baud = term_get_baudrate(tty_fd, NULL); flow = term_get_flowcntrl(tty_fd); parity = term_get_parity(tty_fd); bits = term_get_databits(tty_fd); stopbits = term_get_stopbits(tty_fd); fd_printf(STO, "\r\n"); if ( baud != opts.baud ) { fd_printf(STO, "*** baud: %d (%d)\r\n", opts.baud, baud); } else { fd_printf(STO, "*** baud: %d\r\n", opts.baud); } if ( flow != opts.flow ) { fd_printf(STO, "*** flow: %s (%s)\r\n", flow_str[opts.flow], flow_str[flow]); } else { fd_printf(STO, "*** flow: %s\r\n", flow_str[opts.flow]); } if ( parity != opts.parity ) { fd_printf(STO, "*** parity: %s (%s)\r\n", parity_str[opts.parity], parity_str[parity]); } else { fd_printf(STO, "*** parity: %s\r\n", parity_str[opts.parity]); } if ( bits != opts.databits ) { fd_printf(STO, "*** databits: %d (%d)\r\n", opts.databits, bits); } else { fd_printf(STO, "*** databits: %d\r\n", opts.databits); } if ( stopbits != opts.stopbits ) { fd_printf(STO, "*** stopbits: %d (%d)\r\n", opts.stopbits, stopbits); } else { fd_printf(STO, "*** stopbits: %d\r\n", opts.stopbits); } mctl = term_get_mctl(tty_fd); if (mctl >= 0 && mctl != MCTL_UNAVAIL) { if ( ((mctl & MCTL_DTR) ? 1 : 0) == dtr_up ) fd_printf(STO, "*** dtr: %s\r\n", dtr_up ? "up" : "down"); else fd_printf(STO, "*** dtr: %s (%s)\r\n", dtr_up ? "up" : "down", (mctl & MCTL_DTR) ? "up" : "down"); fd_printf(STO, "*** mctl: "); fd_printf(STO, "DTR:%c DSR:%c DCD:%c RTS:%c CTS:%c RI:%c\r\n", (mctl & MCTL_DTR) ? '1' : '0', (mctl & MCTL_DSR) ? '1' : '0', (mctl & MCTL_DCD) ? '1' : '0', (mctl & MCTL_RTS) ? '1' : '0', (mctl & MCTL_CTS) ? '1' : '0', (mctl & MCTL_RI) ? '1' : '0'); } else { fd_printf(STO, "*** dtr: %s\r\n", dtr_up ? "up" : "down"); } }