Esempio n. 1
0
/* We are given a new text 
	If it is different from current text in window, 
	copy text to window and redraw window
*/
void 
win_new_text(struct Window *win, char *s){
	/* We copy the new text to our internal buffer with clipping if necessary
		We also check if the text currently in buffer is identical
	*/
	if ( strn_cpy_cmp(win->txt, s, win->buffer_size - 1, &(win->text_len)) != 0)
		return;			// the two strings are identical, do nothing

	win_draw_text(win);
};
Esempio n. 2
0
void win_draw_bar(win_t *win)
{
	int len, x, y, w, tw;
	win_env_t *e;
	win_bar_t *l, *r;
	XftDraw *d;
	const XftColor *bg, *fg;

	if ((l = &win->bar.l)->buf == NULL || (r = &win->bar.r)->buf == NULL)
		return;

	e = &win->env;
	y = win->h + font->ascent + V_TEXT_PAD;
	w = win->w - 2*H_TEXT_PAD;
	d = XftDrawCreate(e->dpy, win->buf.pm, DefaultVisual(e->dpy, e->scr),
	                  DefaultColormap(e->dpy, e->scr));

	if (win->fullscreen && !win->light)
		bg = &win->bg, fg = &win->fg;
	else
		bg = &win->fg, fg = &win->bg;

	XSetForeground(e->dpy, gc, bg->pixel);
	XFillRectangle(e->dpy, win->buf.pm, gc, 0, win->h, win->w, win->bar.h);

	XSetForeground(e->dpy, gc, fg->pixel);
	XSetBackground(e->dpy, gc, bg->pixel);

	if ((len = strlen(r->buf)) > 0) {
		if ((tw = TEXTWIDTH(win, r->buf, len)) > w)
			return;
		x = win->w - tw - H_TEXT_PAD;
		w -= tw;
		win_draw_text(win, d, fg, x, y, r->buf, len, tw);
	}
	if ((len = strlen(l->buf)) > 0) {
		x = H_TEXT_PAD;
		w -= 2 * H_TEXT_PAD; /* gap between left and right parts */
		win_draw_text(win, d, fg, x, y, l->buf, len, w);
	}
	XftDrawDestroy(d);
}
Esempio n. 3
0
/* 
	Clear the input window. Reset cursor to start position. 
	Stop char_tmr.
*/
void
win_cursor_clr(){
	if (NULL == pcursor_win) 
		return; 
	pcursor_win->txt[0] = '\0';
	pcursor_win->text_len = 0;
	cursor_pos = 0;
	key_cnt = -1;
	last_key = -1;
	timer_stop(&char_tmr);
	win_draw_text(pcursor_win);	
}
Esempio n. 4
0
void
win_redraw(struct Window *win){
	if (! (win->flags & WINFLG_VISIBLE)) return;
	win_draw_border(win);
	if (win->flags & WINFLG_TEXT)
		win_draw_text(win);
	else if (win->flags & WINFLG_BAR){
		draw_progressbar(win->start_row+1, win->start_col, win->height-2, win->fg_color, win->bg_color, 100, 0);
		draw_progressbar(win->start_row+1, win->start_col, win->height-2, win->fg_color, win->bg_color, 0, win->cur_char);
	} else if (win->flags & WINFLG_RAMP){			
			trianglebar_border(win->start_row+1, win->start_col+1, win->width-2, win->height-2, win->fg_color, win->bg_color);
			draw_trianglebar(win->start_row+1, win->start_col+1, win->width-2, win->height-2, win->fg_color, win->bg_color, 0, win->cur_char);
	};
};
Esempio n. 5
0
/*
	Delete a character at position p in the window text.
*/
static void
del_char(struct Window *win, int p){
	// No text ==> nothing to delete 
	if ( (0 == win->text_len) || (p > win->text_len) )
		return;
	
	/* Clear old cursor */
	cursor_on = 0;
	draw_cursor(win, cursor_pos, 0);
				
	if (p == win->text_len) {
		win->text_len = str_del(win->txt, win->text_len - 1);
	} else {	
		win->text_len = str_del(win->txt, p);	
	};
	win_draw_text(win);	
};
Esempio n. 6
0
/* 
	Store a character at pos p in the window text 
	If p is beyond the current text, the character is appended at the
	end (if possible)
*/
static void
store_char(struct Window *win, int p, char c){
	if (p >= max_txt_len)
		return;
	
	/* Clear old cursor */
	cursor_on = 0;
	draw_cursor(win, cursor_pos, 0);
			
	if (p >= win->text_len){ 
		win->txt[win->text_len++] = c;
		win->txt[win->text_len] = '\0';
	} else {
		win->txt[p] = c;
	};
	
	win_draw_text(win);	
};