/* * create_swindow: (re)create window with specified position and size. */ static void create_swindow(SWINDOW **win, int nlines, int ncols, int begin_y, int begin_x) { if (*win) { int x = swin_getbegx(*win); int y = swin_getbegy(*win); int w = swin_getmaxx(*win); int h = swin_getmaxy(*win); /* If the window position + size hasn't changed, bail */ if (x == begin_x && y == begin_y && w == ncols && h == nlines) return; /* Delete the existing window */ swin_delwin(*win); *win = NULL; } if ((nlines > 0) && (ncols > 0)) { /* Create the ncurses window */ *win = swin_newwin(nlines, ncols, begin_y, begin_x); swin_werase(*win); } }
struct filedlg *filedlg_new(int pos_r, int pos_c, int height, int width) { struct filedlg *fd; /* Allocate a new structure */ fd = new filedlg(); /* Initialize the structure */ fd->win = swin_newwin(height, width, pos_r, pos_c); /* Initialize the buffer */ fd->buf = (struct file_buffer *)cgdb_malloc(sizeof(struct file_buffer)); fd->last_hlregex = NULL; fd->hlregex = NULL; fd->buf->files = NULL; fd->buf->max_width = 0; fd->buf->sel_line = 0; fd->buf->sel_col = 0; fd->buf->sel_rline = 0; return fd; }