static void text_screen_scroll(struct text_screen *screen, int key) { int win_lines = getmaxy(screen->scr.sub_ncw); int win_cols = getmaxx(screen->scr.sub_ncw) - 1; int delta, len, i; if (key == KEY_UP) delta = -1; else if (key == KEY_DOWN) delta = 1; else return; if (screen->scroll_y + delta < 0) return; if (screen->scroll_y + delta + win_lines > screen->n_lines) return; screen->scroll_y += delta; wscrl(screen->scr.sub_ncw, delta); if (delta > 0) { i = screen->scroll_y + win_lines - 1; len = strncols(screen->lines[i]) > win_cols ? win_cols : -1; mvwaddnstr(screen->scr.sub_ncw, win_lines - 1, 1, screen->lines[i], len); } else if (delta < 0) { i = screen->scroll_y; len = strncols(screen->lines[i]) > win_cols ? win_cols : -1; mvwaddnstr(screen->scr.sub_ncw, 0, 1, screen->lines[i], len); } wrefresh(screen->scr.sub_ncw); }
void ConfirmationView::paint_into(WINDOW *view, State state) { int height, width; getmaxyx(view, height, width); (void)height; wattrset(view, UI::Colors::dialog(state == State::Focused)); whline(view, ' ', width); int row = 0; mvwaddnstr(view, row++, 0, _spec.text.c_str(), width); for (std::string line: _spec.supplement) { mvwhline(view, row, 0, ' ', width); mvwaddnstr(view, row, 2, line.c_str(), width - 2); ++row; } }
unsigned LoginBox (acclist_t al, char* password) { CursesInit(); if (!(_loginbox = newwin (LOGIN_WINDOW_HEIGHT, LOGIN_WINDOW_WIDTH, (LINES-LOGIN_WINDOW_HEIGHT)/2, (COLS-LOGIN_WINDOW_WIDTH)/2))) ExitWithMessage ("failed to create login window"); keypad (_loginbox, true); nodelay (_loginbox, false); wbkgd (_loginbox, COLOR_PAIR(1)|' '); int key; unsigned pwlen = 0; const unsigned aln = NAccounts(); if (!aln) ExitWithMessage ("no usable accounts found"); memset (password, 0, MAX_PW_LEN); // Make last logged in user default unsigned ali = 0; for (unsigned i = 0; i < aln; ++i) if (al[ali]->ltime <= al[i]->ltime) ali = i; do { wattrset (_loginbox, COLOR_PAIR(1)); werase (_loginbox); box (_loginbox, 0, 0); mvwaddstr (_loginbox, 1,2, USERNAME_PROMPT); mvwaddstr (_loginbox, 2,2, PASSWORD_PROMPT); wattrset (_loginbox, COLOR_PAIR(2)); mvwaddnstr (_loginbox, 1,2+sizeof(USERNAME_PROMPT), al[ali]->name, MAX_INPUT_WIDTH); mvwaddnstr (_loginbox, 2,2+sizeof(PASSWORD_PROMPT), PASSWORD_MASKSTR, min(strlen(PASSWORD_MASKSTR),pwlen)); wrefresh (_loginbox); key = wgetch (_loginbox); if (isprint(key) && pwlen < MAX_PW_LEN-1) password[pwlen++] = key; else if (key == KEY_BACKSPACE && pwlen > 0) password[--pwlen] = 0; else if (key == KEY_UP) ali = (ali-1) % aln; else if (key == KEY_DOWN || key == '\t') ali = (ali+1) % aln; } while (key != '\n'); delwin (_loginbox); CursesCleanup(); return ali; }
void nc_scr_frame_draw(struct nc_scr *scr) { int ltitle_len, rtitle_len; DBGS("ltitle '%s'\n", scr->frame.ltitle); DBGS("rtitle '%s'\n", scr->frame.rtitle); DBGS("help '%s'\n", scr->frame.help); DBGS("status '%s'\n", scr->frame.status); ltitle_len = strlen(scr->frame.ltitle); rtitle_len = scr->frame.rtitle ? strlen(scr->frame.rtitle) : 0; /* if both ltitle and rtitle don't fit, trim rtitle */ if (ltitle_len + rtitle_len + nc_scr_pos_lrtitle_space > COLS - 2) rtitle_len = COLS - 2 - ltitle_len - nc_scr_pos_lrtitle_space; mvwaddstr(scr->main_ncw, nc_scr_pos_title, 1, scr->frame.ltitle); mvwaddnstr(scr->main_ncw, nc_scr_pos_title, COLS - rtitle_len - 1, scr->frame.rtitle, rtitle_len); mvwhline(scr->main_ncw, nc_scr_pos_title_sep, 1, ACS_HLINE, COLS - 2); mvwhline(scr->main_ncw, LINES - nc_scr_pos_help_sep, 1, ACS_HLINE, COLS - 2); mvwaddstr(scr->main_ncw, LINES - nc_scr_pos_help, 1, scr->frame.help); nc_scr_status_draw(scr); }
static void monitor_satlist(WINDOW *win, int y, int x) /* display as much as we can of a satlist in a specified window */ { int ymax, xmax; char scr[128]; int i; assert(win != NULL); (void)wmove(win, y, x); (void)wclrtoeol(win); scr[0] = '\0'; for (i = 0; i < MAXCHANNELS; i++) { if (session.gpsdata.skyview[i].used) str_appendf(scr, sizeof(scr), "%d ", session.gpsdata.skyview[i].PRN); } getmaxyx(win, ymax, xmax); assert(ymax != 0); /* suppress compiler warning */ (void)mvwaddnstr(win, y, x, scr, xmax - 2 - x); if (strlen(scr) >= (size_t) (xmax - 2)) { (void)mvwaddch(win, y, xmax - 2 - x, (chtype) '.'); (void)mvwaddch(win, y, xmax - 3 - x, (chtype) '.'); (void)mvwaddch(win, y, xmax - 4 - x, (chtype) '.'); } monitor_fixframe(win); }
/*============================ * mvcwaddnstr -- convert to GUI codeset & call mvwaddstr with length limit * Created: 2002/12/13 (Perry Rapp) *==========================*/ int mvccwaddnstr (WINDOW *wp, int y, int x, const char *cp, int n) { ZSTR zstr = zs_news(cp); int rtn=0; int_to_disp(zstr); if (zs_len(zstr) < (unsigned int)n) { rtn = mvwaddstr(wp, y, x, zs_str(zstr)); } else { if (output_width(zstr) > (size_t)n) { STRING str = zs_str(zstr); /* We need to do length truncation correctly for UTF-8 output */ /* #1) We need to not break UTF-8 multibytes */ INT width=0; STRING prev = find_prev_char(&str[n-1], &width, str, gui8); width += (prev - str); zs_chop(zstr, width); /* #2) We should account for zero-width characters, eg, use wcwidth */ /* Unfortunately, lifelines doesn't yet use wcwidth or config test it */ /* TODO: config test for wcswidth and substitute Markus Kuhn's http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c */ } rtn = mvwaddnstr(wp, y, x, zs_str(zstr), n); } zs_free(&zstr); return rtn; }
int xmvwaddnstr (WINDOW *win, const int y, const int x, const char *str, const int n) { int res; if (using_utf8) res = mvwaddnstr (win, y, x, str, n); else { char *lstr = iconv_str (iconv_desc, str); res = mvwaddnstr (win, y, x, lstr, n); free (lstr); } return res; }
/* Repaint the statusbar when getting a character in * get_prompt_string(). The statusbar text line will be displayed * starting with curranswer[index]. */ void update_statusbar_line(const char *curranswer, size_t index) { size_t start_col, page_start; char *expanded; assert(prompt != NULL && index <= strlen(curranswer)); start_col = strlenpt(prompt) + 2; index = strnlenpt(curranswer, index); page_start = get_statusbar_page_start(start_col, start_col + index); if (interface_color_pair[TITLE_BAR].bright) wattron(bottomwin, A_BOLD); wattron(bottomwin, interface_color_pair[TITLE_BAR].pairnum); blank_statusbar(); mvwaddnstr(bottomwin, 0, 0, prompt, actual_x(prompt, COLS - 2)); waddch(bottomwin, ':'); waddch(bottomwin, (page_start == 0) ? ' ' : '$'); expanded = display_string(curranswer, page_start, COLS - start_col - 1, FALSE); waddstr(bottomwin, expanded); free(expanded); wattroff(bottomwin, A_BOLD); wattroff(bottomwin, interface_color_pair[TITLE_BAR].pairnum); statusbar_pww = statusbar_xplustabs(); reset_statusbar_cursor(); wnoutrefresh(bottomwin); }
static void print_list_field(int item, int line, int *x_pos, struct index_elem *e) { char *s, *p; int width, x_start, mustfree = FALSE, len = abs(e->d.field.len); struct list_field f; get_list_field(item, e, &f); s = f.data; if(!s || !*s) { *x_pos += len; return; } if(f.type == FIELD_EMAILS && !opt_get_bool(BOOL_SHOW_ALL_EMAILS)) if((p = strchr(s, ',')) != NULL) { s = xstrndup(s, p - s); mustfree = TRUE; } width = len ? bytes2width(s, len) : strwidth(s); x_start = *x_pos + ((e->d.field.len < 0) ? len - width : 0); if(width + x_start >= COLS) width = bytes2width(s, COLS - x_start); if(width) mvwaddnstr(list, line, x_start, s, width); if(mustfree) free(s); *x_pos += len ? len : width; }
void vtDrawText(VTScreenView *view, int col, int row, char *mbstring, int length, int width) { struct virtualTerminal *vt = (struct virtualTerminal*) view->object; mbstring[length] = 0; // add null character just in case //fprintf(stderr, "DrawText. view: %d col: %d row: %d string: %s\n", (int) (view->object), col, row, mbstring); mvwaddnstr(vt->window, row, col, mbstring, length); //wmove((WINDOW*)view->object, row, col + length - 1); }
void CLabel::update(int c) { if(_visible && _changed) { move_panel(_panel, _pos.y(), _pos.x()); top_panel(_panel); wclear(_window); uint tw = _size.width() - _leftMargin - _rightMargin; if(_centered) mvwaddnstr(_window, _topMargin, _leftMargin + (_text.size() < tw ? ( tw - _text.size() ) / 2 : 0), _text.c_str(), tw); else mvwaddnstr(_window, _topMargin, _leftMargin, _text.c_str(), tw); _changed = false; } }
/* Print the title of the dialog. Center the title and truncate * tile if wider than dialog (- 2 chars). **/ void print_title(WINDOW *dialog, const char *title, int width) { if (title) { int tlen = MIN(width - 2, strlen(title)); wattrset(dialog, dlg.title.atr); mvwaddch(dialog, 0, (width - tlen) / 2 - 1, ' '); mvwaddnstr(dialog, 0, (width - tlen)/2, title, tlen); waddch(dialog, ' '); } }
static void scr_box_text(struct wdgt *w, char *s, u8 c) { int l, pos; if(!s) return; l = strlen(s); //pos = (w->xsize-w->x-l)/2; /* center */ pos = w->xsize-w->x-l; /* right */ // pos = w->x+1; /* left */ mvwaddnstr((WINDOW*)w->decor, w->ysize-w->y+2, pos , s, l); }
void do_mvwaddstr(state *st) { int arity; long slot, y, x, strlen; ei_decode_tuple_header(st->args, &(st->index), &arity); ei_decode_long(st->args, &(st->index), &slot); ei_decode_long(st->args, &(st->index), &y); ei_decode_long(st->args, &(st->index), &x); ei_decode_long(st->args, &(st->index), &strlen); char str[strlen]; ei_decode_string(st->args, &(st->index), str); encode_ok_reply(st, mvwaddnstr(st->win[slot], (int)y, (int)x, str, strlen)); }
/* display the edit buffer in win_input */ static void editbuf_display () { wclear(win_input); if (terminal.flags & TERM_FLAG_ECHO) { mvwaddnstr(win_input, 0, 0, editbuf.buf, editbuf.size); } else { wmove(win_input, 0, 0); size_t i; for (i = 0; i != editbuf.size; ++i) waddch(win_input, '*'); } wmove(win_input, 0, editbuf.pos); }
static void rline_update() { #ifdef HANDLE_MULTIBYTE int real_point = rline_calc_point() + rl_x; #else int real_point = rl_point + rl_x; #endif if(real_point > (COLS - 1)) mvwaddnstr(rl_win, rl_y, rl_x, rl_line_buffer + (1 + real_point - COLS), COLS - rl_x - 1); else mvwaddnstr(rl_win, rl_y, rl_x, rl_line_buffer, rl_end); wclrtoeol(rl_win); wmove(rl_win, rl_y, min(real_point, COLS - 1)); rl_refresh(); }
void CWinMapEditor::refreshpos(int x, int y) { if (m_dpos.x <= x && x < m_dpos.x + m_winw - m_winx && m_dpos.y <= y && y < m_dpos.y + m_winh - m_winy ) { if (x > m_mapdata.width - 1 || y > m_mapdata.height - 1 ) { wattrset(m_this, COLOR_PAIR(0)); mvwaddnstr(m_this, y - m_dpos.y, adjx(x - m_dpos.x), " ", 2); } else { int tileno = gettile(x, y); int cpair = getcpair((int)m_tiledata[tileno].ch, (int)m_tiledata[tileno].bg); wattrset(m_this, COLOR_PAIR(cpair)); mvwaddnstr(m_this, y - m_dpos.y, adjx(x - m_dpos.x), m_tiledata[tileno].tile.c_str(), 2); } } }
void print_hostparam_line(struct filterent *fe, int idx, WINDOW * win, int attr) { struct in_addr binmask; wattrset(win, attr); scrollok(win, 0); mvwprintw(win, idx, 0, "%78c", ' '); mvwaddnstr(win, idx, 1, fe->hp.s_fqdn, 20); if (inet_aton(fe->hp.s_mask, &binmask) == 0) inet_aton("255.255.255.255", &binmask); wprintw(win, "/%u", cidr_get_maskbits(binmask.s_addr)); if (fe->hp.sport2 == 0) wprintw(win, ":%u", fe->hp.sport1); else wprintw(win, ":%u-%u", fe->hp.sport1, fe->hp.sport2); wmove(win, idx, 34); if (fe->hp.match_opposite != 'Y') wprintw(win, "-->"); else wprintw(win, "<->"); mvwaddnstr(win, idx, 38, fe->hp.d_fqdn, 15); if (inet_aton(fe->hp.d_mask, &binmask) == 0) inet_aton("255.255.255.255", &binmask); wprintw(win, "/%u", cidr_get_maskbits(binmask.s_addr)); if (fe->hp.dport2 == 0) wprintw(win, ":%u", fe->hp.dport1); else wprintw(win, ":%u-%u", fe->hp.dport1, fe->hp.dport2); mvwprintw(win, idx, 76, "%c", toupper(fe->hp.reverse)); wmove(win, idx, 0); }
void yatzy_ui_endgame_show(struct yatzy_game *game) { int i; WINDOW *win; struct yatzy_ui_endgame tmp; struct yatzy_ui_endgame list[game->totalPlayers]; for (i=0; i<game->totalPlayers; i++) { list[i].score = yatzy_player_total_score(game->players[i]); list[i].name = game->players[i]->name; } bool sorted = false; while (sorted == false) { sorted = true; for (i=1; i<game->totalPlayers; i++) { if (list[i - 1].score < list[i].score) { memcpy(&tmp, &list[i], sizeof(struct yatzy_ui_endgame)); memcpy(&list[i], &list[i - 1], sizeof(struct yatzy_ui_endgame)); memcpy(&list[i - 1], &tmp, sizeof(struct yatzy_ui_endgame)); sorted = false; } } } noecho(); curs_set(0); win = newwin(H + 2, W + 2, 0, 0); wborder(win, 0, 0, 0, 0, 0, 0, 0, 0); for (i=0; i<H; i++) { wmove(win, i + 1, 1); waddnstr(win, ENDGAME[i], W); } for (i=0; i<game->totalPlayers; i++) { int y = 7 + (i * 2); mvwprintw(win, y, 6, "%d.", (i + 1)); mvwaddnstr(win, y, 9, list[i].name, 28); mvwprintw(win, y, 38, "%3d", list[i].score); } wgetch(win); delwin(win); echo(); curs_set(1); refresh(); }
/* redraws properties change dialog */ void redraw_attr_dialog(void) { const char *title; int i; int x, y; size_t title_len; int need_ellipsis; werase(change_win); if(file_is_dir) wresize(change_win, 11, WIDTH); else wresize(change_win, 9, WIDTH); y = 2; x = 2; for(i = 0; i < ATTR_COUNT; i++) { mvwaddstr(change_win, y, x, " [ ] "); mvwaddstr(change_win, y, x + 5, attr_strings[i]); if(attrs[i]) mvwaddch(change_win, y, x + 2, (attrs[i] < 0) ? 'X' : '*'); y += 1; } if(file_is_dir) mvwaddstr(change_win, y + 1, x, " [ ] Set Recursively"); getmaxyx(stdscr, y, x); mvwin(change_win, (y - getmaxy(change_win))/2, (x - getmaxx(change_win))/2); box(change_win, 0, 0); x = getmaxx(change_win); title = get_title(); title_len = strlen(title); need_ellipsis = (title_len > (size_t)x - 2); if(need_ellipsis) { x -= 3; title_len = x; } mvwaddnstr(change_win, 0, (getmaxx(change_win) - title_len)/2, title, x - 2); if(need_ellipsis) { waddstr(change_win, "..."); } draw_curr(); }
/* Show the display */ void show_display_buffer(char *ddram) { char line1[linelen+1]; char *line2; memset(line1, 0, linelen+1); strncpy(line1, ddram, linelen); line2 = &(ddram[linelen]); line2[linelen] = '\0'; if (use_lcdd_menu) { set_lcd_line(1,line1,linelen); set_lcd_line(2,line2,linelen); } if (using_curses) { /* Convert special LCD chars */ makeprintable((unsigned char *)line1); makeprintable((unsigned char *)line2); mvwaddnstr(slimwin, 1, 1, line1, linelen); mvwaddnstr(slimwin, 2, 1, line2, linelen); wrefresh(slimwin); } }
void text_screen_draw(struct text_screen *screen) { int max_y, max_x, i, len; max_y = getmaxy(screen->scr.sub_ncw); max_x = getmaxx(screen->scr.sub_ncw) - 1; max_y = min(max_y, screen->scroll_y + screen->n_lines); for (i = screen->scroll_y; i < max_y; i++) { len = strncols(screen->lines[i]) > max_x ? max_x : -1; mvwaddnstr(screen->scr.sub_ncw, i, 1, screen->lines[i], len); } wrefresh(screen->scr.sub_ncw); }
/* draw a generic header */ void draw_header (WINDOW * win, const char *s, const char *fmt, int y, int x, int w, GColors * (*func) (void)) { GColors *color = (*func) (); char *buf; buf = xmalloc (snprintf (NULL, 0, fmt, s) + 1); sprintf (buf, fmt, s); wattron (win, color->attr | COLOR_PAIR (color->pair->idx)); mvwhline (win, y, x, ' ', w); mvwaddnstr (win, y, x, buf, w); wattroff (win, color->attr | COLOR_PAIR (color->pair->idx)); free (buf); }
/* draw a generic header */ void draw_header (WINDOW * win, char *header, int x, int y, int w, int color) { char buf[256]; snprintf (buf, sizeof buf, "%s%s", " ", header); if (conf.color_scheme == MONOCHROME) { init_pair (1, COLOR_BLACK, COLOR_WHITE); init_pair (2, COLOR_WHITE, -1); } else { init_pair (1, COLOR_BLACK, COLOR_GREEN); init_pair (2, COLOR_BLACK, COLOR_CYAN); } wattron (win, COLOR_PAIR (color)); mvwhline (win, y, x, ' ', w); mvwaddnstr (win, y, x, buf, w); wattroff (win, COLOR_PAIR (color)); }
/* draw a generic header */ void draw_header (WINDOW * win, const char *s, const char *fmt, int y, int x, int w, int color, int max_width) { char *buf; /* additional integer value for the width */ if (strchr (fmt, '*') != NULL && max_width > 0) { buf = xmalloc (snprintf (NULL, 0, fmt, max_width, s) + 1); sprintf (buf, fmt, max_width, s); } else { buf = xmalloc (snprintf (NULL, 0, fmt, s) + 1); sprintf (buf, fmt, s); } if (conf.color_scheme == STD_GREEN) { init_pair (1, COLOR_BLACK, COLOR_GREEN); init_pair (2, COLOR_BLACK, COLOR_CYAN); wattron (win, COLOR_PAIR (color)); } else if (conf.color_scheme == MONOCHROME) { init_pair (1, COLOR_BLACK, COLOR_WHITE); init_pair (2, COLOR_WHITE, -1); wattron (win, COLOR_PAIR (color)); } else { if (color == 1) wattron (win, A_REVERSE); else if (color == 2) wattron (win, A_NORMAL); } mvwhline (win, y, x, ' ', w); mvwaddnstr (win, y, x, buf, w); if (conf.color_scheme == STD_GREEN) wattroff (win, COLOR_PAIR (color)); else if (conf.color_scheme == MONOCHROME) wattroff (win, COLOR_PAIR (color)); else { if (color == 1) wattroff (win, A_REVERSE); else if (color == 2) wattroff (win, A_NORMAL); } free (buf); }
int curses_msgwin(const char *msg) { int key, len; int width = strlen(msg) + 4; int prevcurs = curs_set(0); WINDOW *win = newdialog(3, width); len = strlen(msg); while (isspace(msg[len-1])) len--; mvwaddnstr(win, 1, 2, msg, len); wrefresh(win); key = nh_wgetch(win); /* wait for any key */ delwin(win); curs_set(prevcurs); redraw_game_windows(); return key; }
void shNCursesMenu::showHelp (WINDOW *win) { int lines; const char **text = prepareHelp (&lines); for (int i = 0; i < lines; ++i) { int len = strlen (text[i]); for (int j = 0; j < len; ++j) { if (islower (text[i][j]) or text[i][j] == ':' or (j == 0 and (text[i][j] == 'I' or text[i][j] == 'Q'))) { wattrset (win, A_NORMAL); } else { wattrset (win, A_BOLD); } mvwaddnstr (win, i, j, &text[i][j], 1); } } free (text); }
/* draw a generic header */ void draw_header (WINDOW * win, const char *s, const char *fmt, int y, int x, int w, int color) { char *buf = xmalloc (snprintf (NULL, 0, fmt, s) + 1); sprintf (buf, fmt, s); if (conf.color_scheme == STD_GREEN) { init_pair (1, COLOR_BLACK, COLOR_GREEN); init_pair (2, COLOR_BLACK, COLOR_CYAN); wattron (win, COLOR_PAIR (color)); } else if (conf.color_scheme == MONOCHROME) { init_pair (1, COLOR_BLACK, COLOR_WHITE); init_pair (2, COLOR_WHITE, -1); wattron (win, COLOR_PAIR (color)); } else { if (color == 1) wattron (win, A_REVERSE); else if (color == 2) wattron (win, A_NORMAL); } mvwhline (win, y, x, ' ', w); mvwaddnstr (win, y, x, buf, w); if (conf.color_scheme == STD_GREEN) wattroff (win, COLOR_PAIR (color)); else if (conf.color_scheme == MONOCHROME) wattroff (win, COLOR_PAIR (color)); else { if (color == 1) wattroff (win, A_REVERSE); else if (color == 2) wattroff (win, A_NORMAL); } free (buf); }
static void lua_paint_info(struct window *wnd, const struct state *st) { struct lua_State *L = paint_state; int nx = st->cursor.x, ny = st->cursor.y; pnormalize(&nx, &ny, st->cursor.pl); lua_rawgeti(L, LUA_REGISTRYINDEX, paint_handle); lua_pushinteger(L, nx); lua_pushinteger(L, ny); if (lua_pcall(L, 2, 1, 0) != 0) { const char *error = lua_tostring(L, -1); log_error("paint function failed: %s\n", error); lua_pop(L, 1); tolua_error(L, TOLUA_CAST "event handler call failed", NULL); } else { const char *result = lua_tostring(L, -1); WINDOW *win = wnd->handle; int size = getmaxx(win) - 2; int line = 0, maxline = getmaxy(win) - 2; const char *str = result; wxborder(win); while (*str && line < maxline) { const char *end = strchr(str, '\n'); if (!end) break; else { int bytes = (int)(end - str); if (bytes < size) bytes = size; mvwaddnstr(win, line++, 1, str, bytes); wclrtoeol(win); str = end + 1; } } } }
void curses_load_backdrop(WINDOW *w, const char *filename) { FILE *f; char line[80]; int row = 1; int my, mx; getmaxyx(w, my, mx); wclear(w); curses_colors_set(w, CURSES_COLORS_BACKDROP); curses_window_blank(w); if ((f = fopen(filename, "r")) != NULL) { while (fgets(line, 79, f) != NULL) { if (row > my) break; if (line[strlen(line) - 1] == '\n') line[strlen(line) - 1] = '\0'; mvwaddnstr(w, row++, 0, line, mx); } fclose(f); } }