Example #1
0
static void
MovePrompt(WINDOW *txtwin, int limit, int y, int x)
{
    wchgat(txtwin, Remainder(txtwin), A_NORMAL, 0, NULL);
    wmove(txtwin, y, x);
    ShowPrompt(txtwin, limit);
}
Example #2
0
static void
test_wchgat(WINDOW *win)
{
    STATUS st;

    init_status(win, &st);

    do {
	switch (st.ch) {
	case '.':		/* change from current position */
	    wchgat(win, st.count, st.attr, st.pair, (void *) 0);
	    touch_if_needed(win, st.y_val);
	    break;
	case ',':		/* change from beginning of window */
	    mvwchgat(win, 0, 0, st.count, st.attr, st.pair, (void *) 0);
	    touch_if_needed(win, 0);
	    wmove(win, st.y_val, st.x_val);
	    break;
	case 'w':
	    do_subwindow(win, &st, test_wchgat);
	    break;
	case 'q':
	    return;
	default:
	    update_status(win, &st);
	    break;
	}
    } while ((st.ch = wgetch(win)) != ERR);
}
Example #3
0
void mrutils::ColChooser::printPrompt(const char * prompt, const char * prefix) {
    int n = 0;

    wmove((WINDOW*)chooserWin,maxLines-1,0);
    wattrset((WINDOW*)chooserWin,ATR_INPUT);
    wclrtoeol((WINDOW*)chooserWin);

    if (prefix != NULL) {
        waddnstr((WINDOW*)chooserWin,prefix,-1);
        n += strlen(prefix);
    }

    waddnstr((WINDOW*)chooserWin,prompt,-1);
    n += strlen(prompt);

    if (data[active].applySearch && !enteringSearch && prompt[0] != '>') {
        waddnstr((WINDOW*)chooserWin," searching /",-1);
        n += 12;
        waddnstr((WINDOW*)chooserWin,data[active].search,-1);
        n += strlen(data[active].search);
        waddnstr((WINDOW*)chooserWin,"/",-1);
        ++n;
    }

    wattrset((WINDOW*)chooserWin,ATR_BLANK);
    wchgat((WINDOW*)chooserWin, -1, A_NORMAL, COL_INPUT, NULL);
    wrefresh((WINDOW*)chooserWin);

    move(maxLines-1,n);
}
Example #4
0
File: draw.c Project: jlsandell/tig
static inline void
set_view_attr(struct view *view, enum line_type type)
{
	if (!view->curline->selected && view->curtype != type) {
		(void) wattrset(view->win, get_line_attr(type));
		wchgat(view->win, -1, 0, get_line_color(type), NULL);
		view->curtype = type;
	}
}
Example #5
0
int
chgat(int n, attr_t at, short co, const void *opts)
{
	int code;

	code = wchgat(stdscr, n, at, co, opts);

	return (code);
}
Example #6
0
int mvchgat(int y, int x, int n, attr_t attr, short color, const void *opts)
{
    PDC_LOG(("mvchgat() - called\n"));

    if (move(y, x) == ERR)
        return ERR;

    return wchgat(stdscr, n, attr, color, opts);
}
Example #7
0
int
mvchgat(int y, int x, int n, attr_t at, short co, const void *opts)
{
	int code;

	if ((code = wmove(stdscr, y, x)) == OK)
		code = wchgat(stdscr, n, at, co, opts);

	return (code);
}
Example #8
0
int mvwchgat(WINDOW *win, int y, int x, int n, attr_t attr, short color,
             const void *opts)
{
    PDC_LOG(("mvwchgat() - called\n"));

    if (wmove(win, y, x) == ERR)
        return ERR;

    return wchgat(win, n, attr, color, opts);
}
Example #9
0
int
mvwchgat(WINDOW *w, int y, int x, int n, attr_t at,
	short co, const void *opts)
{
	int code;

	if ((code = wmove(w, y, x)) == OK)
		code = wchgat(w, n, at, co, opts);

	return (code);
}
Example #10
0
File: output.c Project: k6s/yaod
void			print_addr(WINDOW *win, size_t var_len, size_t x, size_t y,
							   char *reg, int colors)
{
  size_t		idx;

  wmove(win, y, x);
  idx = 0;
  while (idx < var_len)
    print_byte(win, *(reg + idx++));
  wmove(win, y, x);
  wchgat(win, var_len * 2, COLOR_PAIR(colors), colors, 0);
}
Example #11
0
int
(chgat)(int n, attr_t at, short co, const void *opts)
{
	int code;

#ifdef M_CURSES_TRACE
	__m_trace("chgat(%d, %x, %d, %p)", n, at, co, opts);
#endif

	code = wchgat(stdscr, n, at, co, opts);

	return __m_return_code("chgat", code);
}
Example #12
0
int
(mvchgat)(int y, int x, int n, attr_t at, short co, const void *opts)
{
	int code;

#ifdef M_CURSES_TRACE
	__m_trace("mvchgat(%d, %d, %d, %x, %d, %p)", y, x, n, at, co, opts);
#endif

	if ((code = wmove(stdscr, y, x)) == OK)
		code = wchgat(stdscr, n, at, co, opts);

	return __m_return_code("mvchgat", code);
}
Example #13
0
void 
Draw_Find_OutPut(void)
{
	int totallines = fdview->lineidx;
	int i,highlight, j = 0;
	int start =0,end = 0;
	enum line_type  type;
	
	start = 0;
	highlight = g_current + g_change;
	if(highlight < 0){
		mvwaddstr(status_win,0,0,"At the top");
		highlight = 0;
	}else if(highlight < LINES -2){
		if(highlight == totallines) {
			mvwaddstr(status_win,0,0,"At the end");
			highlight = totallines - 1;
		}
	}else{
		start = highlight - LINES + 2;
		if(highlight == totallines){
			mvwaddstr(status_win,0,0,"Hit the bottom");
			highlight = totallines - 1;
			start = highlight - LINES + 1;
		}
	}

	if(totallines < LINES - 1)
		end = totallines;
	else if(totallines >= LINES)
		end = start + LINES;

	werase(stdscr);
	for(i = start; i < end; i++){
		if(i == highlight){
			snprintf(vim_cmd,sizeof(vim_cmd),VIM_CMD_FIND,fdview->findinfo[i].path,fdview->findinfo[i].name);
			type = LINE_CURSOR;
			g_current = i;
			wattrset(stdscr,get_line_attr(type));
			wchgat(stdscr,-1,0,type,NULL);
		}else{
			type = LINE_FILE_LINCON;
			wchgat(stdscr,-1,0,type,NULL);
			wattrset(stdscr,get_line_attr(LINE_FILE_NAME));
		}
		
		if(type != LINE_CURSOR){
			wattrset(stdscr,get_line_attr(LINE_FILE_NAME));
			mvwaddstr(stdscr,j,0,fdview->findinfo[i].path);
		}else{
			mvwaddstr(stdscr,j,0,fdview->findinfo[i].path);
		}

		if(type != LINE_CURSOR){
			wattrset(stdscr,get_line_attr(LINE_FILE_LINUM));
		}
		right_trim(fdview->findinfo[i].name);
		mvwaddstr(stdscr,j,35,fdview->findinfo[i].name);

		if(type != LINE_CURSOR){
			wattrset(stdscr,get_line_attr(LINE_DELIMITER));
		}
		mvwaddstr(stdscr,j,60,fdview->findinfo[i].type);
		mvwaddch(stdscr,j,COLS-1,'\n');
		j++;
	}
	g_change = 0;
}
Example #14
0
int chgat(int n, attr_t attr, short color, const void *opts)
{
    PDC_LOG(("chgat() - called\n"));

    return wchgat(stdscr, n, attr, color, opts);
}
Example #15
0
NCURSES_EXPORT(int) (mvwchgat) (WINDOW * a1, int a2, int a3, int a4, attr_t a5, short a6, const void * z)
{
	T((T_CALLED("mvwchgat(%p,%d,%d,%d,%s,%d,%p)"), (const void *)a1, a2, a3, a4, _traceattr2(4,a5), a6, (const void *)z)); returnCode((wmove(a1,a2,a3) == (-1) ? (-1) : wchgat(a1,a4,a5,a6,z)));
}
Example #16
0
void mrutils::ColChooser::Column::highlight(int hid, bool refreshInput,
    bool selectFirst, bool refreshWindow) {

    mrutils::mutexAcquire(cc.updateMutex);

    int start, end, d, id; bool addMatches = false;

    if (hid > tail) {
        start = tail + 1;
        end  = choices.size();

        headMatches += tail == -1 ? 0 : MIN(cc.lines-1,(unsigned)searchMatches.size()-headMatches);

        if (headMatches+1 >= searchMatches.size()) {
            addMatches = true;
            head = tail = -1;
        } else {
            head = searchMatches[headMatches];
            tail = searchMatches[MIN((unsigned)searchMatches.size()-1,headMatches + cc.lines-2)];
        }
    } else {
        if (hid < head) {
            headMatches = MAX(0u, headMatches - cc.lines+1);
            head = searchMatches[headMatches];
            tail = searchMatches[MIN((unsigned)searchMatches.size()-1,headMatches + cc.lines-2)];
        }

        start = headMatches;
        end = searchMatches.size();
    }

    d = headMatches;
    selMatches = -1;

    wattrset((WINDOW*)chooserWin,ATR_BLANK);

    for (int i = start; i < end && d-headMatches < cc.lines-1; ++i) {
        if (addMatches) {
            if (applySearch && !mrutils::stristr(choices[i].c_str(), search)) {
                continue;
            }

            if (d == headMatches) head = i; tail = i;
            searchMatches.push_back(i);
        }

        id = searchMatches[d];
        wmove((WINDOW*)chooserWin,d++ - headMatches,cc.colStart); wclrtoeol((WINDOW*)chooserWin);

        if (id == hid) {
            selMatches = d-1;

            wattrset((WINDOW*)chooserWin,ATR_SELECTED);
            waddnstr((WINDOW*)chooserWin,choices[id].c_str(), colWidth);
            wattrset((WINDOW*)chooserWin,ATR_BLANK);

            int left = colWidth - choices[id].size();
            if (left > 0)
                wchgat((WINDOW*)chooserWin,left, 0, COL_SELECTED, NULL);
        } else {
            bool targeted = colNumber+1 == cc.data.size() && cc.targeted[id];
            if (targeted)
                wattrset((WINDOW*)chooserWin,ATR_TARGETED);
            waddnstr((WINDOW*)chooserWin,choices[id].c_str(), colWidth);
            wattrset((WINDOW*)chooserWin,ATR_BLANK);

            int left = colWidth - choices[id].size();
            if (left > 0) {
                if (targeted)
                    wchgat((WINDOW*)chooserWin,left, 0, COL_TARGETED, NULL);
                else 
                    wchgat((WINDOW*)chooserWin,left, 0, COL_BLANK, NULL);
            }
        }
    }

    if (selMatches == -1 && selectFirst) {
        selMatches = headMatches;
        wmove((WINDOW*)chooserWin,0,cc.colStart);
        wchgat((WINDOW*)chooserWin, colWidth, A_BLINK, COL_SELECTED, NULL);
    }

    for (int i = d - headMatches; i < cc.lines-1; ++i) { 
        wmove((WINDOW*)chooserWin,i,cc.colStart); wclrtoeol((WINDOW*)chooserWin);
    }

    // set the depth selection
    if ( selMatches < 0 ||
         selMatches >= searchMatches.size() )
        cc.depth[colNumber] = -1;
    else 
        cc.depth[colNumber] = searchMatches[selMatches] + cc.startIndex;

    // build next column
    if (cc.data.size() > colNumber + 1 
        && hid >= 0 && cc.depth[colNumber] >= 0) {


        mvwvline((WINDOW*)chooserWin, 0, 
                cc.colStart + colWidth, ACS_VLINE, cc.lines-1);

        std::vector<std::string>& choices = cc.data[colNumber+1].choices;

        if (refreshWindow) {
            cc.targeted.clear();
            cc.targets.clear();

            choices.clear();
            (cc.optionsFn)(cc, cc.optionData);
            if (cc.building >= 0) cc.build();
        }

        int colWidth = cc.data[colNumber+1].colWidth;
        int rows = MIN((unsigned)choices.size(), cc.lines-1);

        for (int i = 0; i < rows; ++i) {
            bool targeted = colNumber+2 == cc.data.size() && cc.targeted[i];
            if (targeted)
                wattrset((WINDOW*)chooserWin,ATR_TARGETED);
            wmove((WINDOW*)chooserWin,i,cc.colStart+this->colWidth+1); 
            waddnstr((WINDOW*)chooserWin,choices[i].c_str(), colWidth);
            if (targeted) {
                wchgat((WINDOW*)chooserWin,-1, 0, COL_TARGETED, NULL);
                wattrset((WINDOW*)chooserWin,ATR_BLANK);
            }
        }
    }

    if (refreshInput) { cc.printPrompt(cc.name.c_str()); }
    else {
        if (refreshWindow) wrefresh((WINDOW*)chooserWin);
        move(cc.maxLines-1,0);
    }

    if (colNumber == cc.data.size()-1 && cc.changeFn != NULL) {
        (cc.changeFn)(cc, cc.changeData);
    }

    mrutils::mutexRelease(cc.updateMutex);
}
Example #17
0
/*
 * Show a highlighted line in the place where input will happen.
 */
static void
ShowPrompt(WINDOW *txtwin, int limit)
{
    wchgat(txtwin, limit, A_REVERSE, 0, NULL);
    wnoutrefresh(txtwin);
}
Example #18
0
NCURSES_EXPORT(int) (mvchgat) (int a1, int a2, int a3, attr_t a4, short a5, const void * z)
{
	T((T_CALLED("mvchgat(%d,%d,%d,%s,%d,%p)"), a1, a2, a3, _traceattr2(3,a4), a5, (const void *)z)); returnCode((wmove(stdscr,a1,a2) == (-1) ? (-1) : wchgat(stdscr,a3,a4,a5,z)));
}
Example #19
0
File: xxx.c Project: yaomoon/GT2440
static bool default_render(struct view *view, unsigned int lineno)
{
	struct fileinfo *fileinfo;
	enum line_type type;
	int col = 0;
	size_t namelen;
    char *fname, *fnumber;
    int opt_file_name = 25;
	char text[SIZEOF_STR];

	if (view->offset + lineno >= view->lines)
		return false;

	fileinfo = view->line[view->offset + lineno];
	if (!*fileinfo->name)
		return false;

    fnumber = fileinfo->number;
    fname = blankspace(fileinfo->name);
	wmove(view->win, lineno, col);

	if (view->offset + lineno == view->lineno) {
        snprintf(vim_cmd, sizeof(vim_cmd), VIM_CMD, fnumber, fname);
		type = LINE_CURSOR;
		wattrset(view->win, get_line_attr(type));
		wchgat(view->win, -1, 0, type, NULL);
        string_copy(view->file, fileinfo->name);

	} else {
		type = LINE_FILE_LINCON;
        wchgat(view->win, -1, 0, type, NULL);
		wattrset(view->win, get_line_attr(LINE_FILE_NAME));
	}

    namelen = strlen(fileinfo->name);
    if (namelen > opt_file_name){
        int n = namelen-opt_file_name;
	    if (type != LINE_CURSOR)
            wattrset(view->win, get_line_attr(LINE_DELIMITER));
        waddch(view->win, '~');
	    if (type != LINE_CURSOR)
            wattrset(view->win, get_line_attr(LINE_FILE_NAME));
    	waddnstr(view->win, fileinfo->name + n, opt_file_name);
    }
    else
        waddstr(view->win, fileinfo->name);

    col += opt_file_name + 2;
	wmove(view->win, lineno, col);
	if (type != LINE_CURSOR)
		wattrset(view->win, get_line_attr(LINE_FILE_LINUM));

	waddstr(view->win, fileinfo->number);

    col += 9;
	if (type != LINE_CURSOR)
		wattrset(view->win, A_NORMAL);

	wmove(view->win, lineno, col);

	if (type != LINE_CURSOR)
		wattrset(view->win, get_line_attr(type));

    int contentlen = strlength(fileinfo->content);
    string_expand(text, sizeof(text), fileinfo->content, opt_tab_size);

    if (col + contentlen > view->width){
        contentlen = view->width - col;
        if (contentlen < 0)
            return TRUE;
        else {
            waddnstr(view->win, text, contentlen-1);
            if (type != LINE_CURSOR)
                wattrset(view->win, get_line_attr(LINE_DELIMITER));
            waddch(view->win, '~');
        }
    }
    else { 
        waddstr(view->win, fileinfo->content);
    }

	return TRUE;
}
Example #20
0
static bool default_render(struct view *view, unsigned int lineno)
{
	struct fileinfo *fileinfo;
	enum line_type type;
	int col = 0;
	size_t numberlen;
	size_t namelen;
    char *fname, *fnumber;

	if (view->offset + lineno >= view->lines)
		return false;

	fileinfo = view->line[view->offset + lineno];
	if (!*fileinfo->name)
		return false;

	wmove(view->win, lineno, col);

	if (view->offset + lineno == view->lineno) {
        fnumber = fileinfo->number;
        fname = fileinfo->name;
        snprintf(vim_cmd, sizeof(vim_cmd), VIM_CMD, fnumber, fname);
		type = LINE_CURSOR;
		wattrset(view->win, get_line_attr(type));
		wchgat(view->win, -1, 0, type, NULL);

	} else {
		type = LINE_FILE_LINCON;
		wchgat(view->win, -1, 0, type, NULL);
		wattrset(view->win, get_line_attr(LINE_FILE_NAME));
	}

	waddstr(view->win, fileinfo->name);
    namelen = strlen(fileinfo->name);

    col += 20;
	wmove(view->win, lineno, col);
	if (type != LINE_CURSOR)
		wattrset(view->win, get_line_attr(LINE_FILE_LINUM));

	waddstr(view->win, fileinfo->number);
    numberlen = strlen(fileinfo->number);

    col += 7;
	if (type != LINE_CURSOR)
		wattrset(view->win, A_NORMAL);

	wmove(view->win, lineno, col + 2);
	col += 2;

	if (type != LINE_CURSOR)
		wattrset(view->win, get_line_attr(type));

    int contentlen = strlength(fileinfo->content);

    if (col + contentlen > view->width)
        contentlen = view->width - col - 20;

    if (contentlen > 0)
        waddnstr(view->win, fileinfo->content, contentlen);
    else 
        waddnstr(view->win, fileinfo->content, 4);

	return TRUE;
}
Example #21
0
int
chgat(int n, attr_t attr, short color, const void *opts)
{
	return wchgat(stdscr, n, attr, color, opts);
}
Example #22
0
/**
 * This function is used to draw the ls output, 
 * we store all the output of the ls into a global
 * struct lsview. so we render each item one by one
 * and support the scroll.
 * */
void 
Draw_LS_OutPut()
{
	int totallines = lsview->fileno;  
	int i,highlight,j=0;
	int start, end;
	enum line_type  type;
	
	start = 0;
	highlight = g_current + g_change;
	if(highlight <= 0)
	{
		mvwaddstr(status_win,0,0,"At the top");
		highlight = 0;
	}else if(highlight <= LINES - 2){
		if(highlight == totallines) {/*mean at the end */
			mvwaddstr(status_win,0,0,"At the end");
			highlight = totallines - 1;
		}
	}else
	{
		start = highlight - LINES + 2; /*hide one line*/
		//end = highlight+1; /*current line is hightghit - 1*/
		if(highlight == totallines ){ /*really at the end of the array*/
			mvwaddstr(status_win,0,0,"Hit the bottom");
			highlight = totallines - 1;
			start=highlight - LINES + 1;
		}
	}

	
	if(totallines <= LINES-1)
		end = totallines; /*not overlap the screen*/
	else if(totallines >= LINES)
		end = start + LINES;

	werase(stdscr);
	for(i = start; i < end; i++)
	{
		if(i == highlight)
		{
			snprintf(vim_cmd,sizeof(vim_cmd), VIM_CMD,lsview->fileinfo[i].name);
			type = LINE_CURSOR;
			g_current = i;
			wattrset(stdscr, get_line_attr(type));
			wchgat(stdscr,-1,0,type,NULL);
		}else{
			type = LINE_FILE_LINCON;
			wchgat(stdscr,-1,0,type,NULL);
			wattrset(stdscr,get_line_attr(LINE_FILE_NAME));
		}

		/*set filename, size and type*/
		if(type != LINE_CURSOR){
			wattrset(stdscr,get_line_attr(LINE_FILE_NAME));
			mvwaddstr(stdscr,j,0,lsview->fileinfo[i].name);
		}else{
			mvwaddstr(stdscr,j,0,lsview->fileinfo[i].name);
		}
		
		//wmove(stdscr,i,40);
		if(type != LINE_CURSOR){
			wattrset(stdscr,get_line_attr(LINE_FILE_LINUM));
		}

		mvwaddstr(stdscr,j,40,lsview->fileinfo[i].size);

		//wmove(stdscr,i,60);
		if(type != LINE_CURSOR){
			wattrset(stdscr, get_line_attr(LINE_DELIMITER));
		}
		mvwaddstr(stdscr,j,60,lsview->fileinfo[i].type);
		mvwaddch(stdscr,j,COLS-1,'\n');
		j++; /*j control the screen loop*/
	}
	g_change = 0; /*clear the offset*/
}
EIF_INTEGER c_ecurses_wchgat (EIF_POINTER w, EIF_INTEGER n, EIF_INTEGER attr, EIF_INTEGER color, EIF_POINTER opt)
{
    return  wchgat(((WINDOW*)w), ((int) n), ((attr_t)attr), ((short)color), ((char*)opt) ) ;
};
Example #24
0
NCURSES_EXPORT(int) (chgat) (int a1, attr_t a2, short a3, const void * z)
{
	T((T_CALLED("chgat(%d,%s,%d,%p)"), a1, _traceattr2(1,a2), a3, (const void *)z)); returnCode(wchgat(stdscr,a1,a2,a3,z));
}