Example #1
0
Win *
winsel(Mousectl *mc, int but)
{
	extern Cursor crosscursor;
	int m;
	Win *w;
	
	m = 1 << but - 1;
	setcursor(mc, &crosscursor);
	for(;;){
		readmouse(mc);
		if((mc->buttons & ~m) != 0){
			w = nil;
			goto end;
		}
		if((mc->buttons & m) != 0)
			break;
	}
	w = winpoint(mc->xy);
end:
	while(readmouse(mc), mc->buttons != 0)
		;
	setcursor(mc, nil);
	return w;
}
Example #2
0
void PromptForCorrectScreenSize()
{
	char* prompt = "Please Press ALT + ENTER To Maximize Your Screen Size";
	char* prompt2 = "When Ready, Press SPACE To Begin";
	int key;
	COORD promptdrawcoords;

	promptdrawcoords = retrieveTextCenter(prompt);
	LRED;
	setcursor(promptdrawcoords.X, promptdrawcoords.Y);
	printf(prompt);
	promptdrawcoords = retrieveTextCenter(prompt2);
	promptdrawcoords.Y++;
	setcursor(promptdrawcoords.X, promptdrawcoords.Y);
	printf(prompt2);
	
	while(1)
	{
		key = waitforkey();
		if (key == ' '){
			cls();
			return;
		}
	}
}
void changecursor(insmode)
/* Changes the cursor shape based on the current insert mode */
{
 if (insmode)
  setcursor(tallcursor);
 else
  setcursor(shortcursor);
} /* changecursor */
Example #4
0
File: xs.c Project: npe9/harvey
void
suspend(int s)
{
    suspended = s;
    if (suspended)
        setcursor(mousectl, &whitearrow);
    else
        setcursor(mousectl, nil);
    if (!suspended)
        drawpiece();
    drawboard();
    flushimage(display, 1);
}
Example #5
0
/* Prints a prompt and gets a yes or no answer - returns FALSE if ESC was
    pressed, TRUE if not. */
int getyesno(int *yesno, char *prompt)
{
    writeprompt(prompt);
    setcursor(shortcursor);
    do {
        *yesno = toupper(getkey());
        if (*yesno == ESC) {
            setcursor(nocursor);
            return(FALSE);
        }
    }
    while (strchr("YN", *yesno) == NULL);
    setcursor(nocursor);
    return(TRUE);
} /* getyesno */
Example #6
0
int Gpm_GetEvent(Gpm_Event *e){
    VimEvent event;

    int n = read(gpm_fd, (void*)&event, sizeof(VimEvent));
    if(event.type == VIM_EVENT_TYPE_GPM) {
        memcpy(e, (void*)&event.event.gpm, sizeof(Gpm_Event));
        return 1;
    }else if(event.type == VIM_EVENT_TYPE_CMD) {
        do_cmdline_cmd((char_u *) event.event.cmd);
    }else if(event.type == VIM_EVENT_TYPE_RELINE) {
        char* str = event.event.cmd;
        ml_replace(curwin->w_cursor.lnum,(char_u*)str, TRUE);
        changed_lines(curwin->w_cursor.lnum, 0, curwin->w_cursor.lnum, 1L);
    }else if(event.type == VIM_EVENT_TYPE_UPDATE){
        vimtouch_lock();
        update_screen(0);
        setcursor();
        out_flush();
        vimtouch_unlock();
    }else if(event.type == VIM_EVENT_TYPE_SETCOL){
        curwin->w_cursor.col = event.event.num;
    }else if(event.type == VIM_EVENT_TYPE_SCROLL){
        int do_scroll = event.event.num;
        scroll_redraw(do_scroll > 0, do_scroll>0?do_scroll:-do_scroll);
    }else if(event.type == VIM_EVENT_TYPE_RESIZE){
        out_flush();
        shell_resized_check();
        redraw_later(CLEAR);
        update_screen(CLEAR);
        out_flush();
    }
    return 0;
}
Example #7
0
void
duplicate(Flayer *l, Rectangle r, Font *f, int close)
{
	Text *t=(Text *)l->user1;
	Flayer *nl = findl(t);
	Rune *rp;
	uint32_t n;

	if(nl){
		flnew(nl, gettext, l->user0, (char *)t);
		flinit(nl, r, f, l->f.cols);
		nl->origin = l->origin;
		rp = (*l->textfn)(l, l->f.nchars, &n);
		flinsert(nl, rp, rp+n, l->origin);
		flsetselect(nl, l->p0, l->p1);
		if(close){
			flclose(l);
			if(l==which)
				which = 0;
		}else
			t->nwin++;
		current(nl);
		hcheck(t->tag);
	}
	setcursor(mousectl, cursor);
}
Example #8
0
int Gpm_GetEvent(Gpm_Event *e){
    VimEvent event;

    int n = read(gpm_fd, (void*)&event, sizeof(VimEvent));
    if(event.type == VIM_EVENT_TYPE_GPM) {
        memcpy(e, (void*)&event.event.gpm, sizeof(Gpm_Event));
        return 1;
    }else if(event.type == VIM_EVENT_TYPE_ANDROID_SEND) {
        vimtouch_send_android_event(event.event.num, (char_u *) &event.event.nums[1]);
		return 0;
    }else if(event.type == VIM_EVENT_TYPE_CMD) {
        do_cmdline_cmd((char_u *) event.event.cmd);
    }else if(event.type == VIM_EVENT_TYPE_RELINE) {
        char* str = event.event.cmd;
        ml_replace(curwin->w_cursor.lnum,(char_u*)str, TRUE);
        changed_lines(curwin->w_cursor.lnum, 0, curwin->w_cursor.lnum, 1L);
    }else if(event.type == VIM_EVENT_TYPE_UPDATE){
        //vimtouch_lock();
        update_screen(0);
        setcursor();
        out_flush();
        //vimtouch_unlock();
    }else if(event.type == VIM_EVENT_TYPE_CURSOR){
        mouse_col = event.event.nums[0];
        mouse_row = event.event.nums[1];

        jump_to_mouse(MOUSE_DID_MOVE, NULL, 0);
    }else if(event.type == VIM_EVENT_TYPE_SETCOL){
        curwin->w_cursor.col = event.event.num;
    }else if(event.type == VIM_EVENT_TYPE_SCROLL){
        int do_scroll = event.event.num;
        scroll_redraw(do_scroll > 0, do_scroll>0?do_scroll:-do_scroll);
    }else if(event.type == VIM_EVENT_TYPE_RESIZE){
        out_flush();
        shell_resized_check();
        redraw_later(CLEAR);
        out_flush();
    }else if(event.type == VIM_EVENT_TYPE_SETTAB){
        int nr = event.event.nums[0];

        if (nr != tabpage_index(curtab)){
            current_tab = nr;
            if (current_tab == 255)     /* -1 in a byte gives 255 */
            current_tab = -1;
            goto_tabpage(current_tab);
            update_screen(CLEAR);
            out_flush();
        }
    }else if(event.type == VIM_EVENT_TYPE_HISTORY){
        char buf[1024];
        int i = 1;
        for(i = 1; i <= 10; i++){
            sprintf(buf, "HISTORY:%d,%s\n",i-1,get_history_entry(HIST_CMD,i));
            write(gpm_fd,buf,strlen(buf));
        }
    }
    vimtouch_sync();
    return 0;
}
Example #9
0
void
Cursortocursor(Cursor *c)
{
	lock(&cursor.lk);
	cursor.cursor = *c;
	unlock(&cursor.lk);
	setcursor(c);
}
Example #10
0
File: stg1.c Project: acalvoa/SNAKE
void select_diff(){
	clear_screen();
	set_border();
	setcursor(8,5,1);
	printg("SNAKE: SELECT DIFFICULT",0,_C_YELLOW);
	draw_game_line(23,25,133,25,_C_YELLOW,1);
	setcursor(8,8,1);
	printg("1.- Easy",0,_C_YELLOW);
	setcursor(8,9,1);
	printg("2.- Medium",0,_C_YELLOW);
	setcursor(8,10,1);
	printg("3.- Hard",0,_C_YELLOW);
	setcursor(8,11,1);
	printg("4.- Adin",0,_C_YELLOW);
	get_difficult();
	write_diff();
}
Example #11
0
/*
 * Move to a particular position and see if we hit a mine.
 * If not, then count the number of mines adjacent to us so it can be seen.
 * If we are stepping onto a location where we remembered a mine is at,
 * then don't do it.  Moving is only allowed to old locations, or to
 * locations adjacent to old ones.
 */
static void
movetopos(POS newpos)
{
    POS		fixpos;		/* position to fix up */
    CELL		cell;		/* current cell */
    GR_COUNT	count;		/* count of cells */
    GR_COUNT	i;		/* index for neighbors */

    if ((newpos < 0) || (newpos >= (FULLSIZE * FULLSIZE)) || !playing)
        return;

    cell = board[newpos];

    if (isedge(cell) || (isseen(cell)) || isold(cell))
        return;

    count = isold(cell);
    for (i = 0; i < 8; i++)
        if (isold(board[newpos + steptable[i]]))
            count++;

    if (count <= 0)
        return;

    cell = (cell & F_FLAGS) | F_OLD;
    steps++;

    PRINTSTEPS;

    if (ismine(cell)) {		/* we hit a mine */
        legs--;
        board[newpos] = (F_REMEMBER | F_MINE);
        cell = (F_EMPTY | F_OLD);
        board[newpos] = cell;
        drawbomb(newpos, redgc, GR_TRUE);
        clearcell(newpos);
        setcursor();
        for (i = 0; i < 8; i++) {
            fixpos = newpos + steptable[i];
            if (isold(board[fixpos])) {
                board[fixpos]--;
                drawcell(fixpos);
            }
        }
        drawstatus();
    }

    count = 0;
    for (i = 0; i < 8; i++)
        if (ismine(board[newpos + steptable[i]]))
            count++;
    board[newpos] = cell | (count + '0');

    drawcell(newpos);

    if ((legs <= 0) || (newpos == boardpos(size,size)))
        gameover();
}
Example #12
0
// Get current mouse position.  If the mouse is above/below the current
// window then scroll the window down/up proportionally to the time the LMB
// is held down.  This function is called from autoscroll_thread() when the
// mouse is captured and a wipe selection is active.
static void
AutoScroll(WINDOW *wp)
{
#define DVSR    10
#define INCR    6
#define TRIGGER (DVSR + INCR)

    POINT current;
    int Scroll = 0;
    static int ScrollCount = 0, Throttle = INCR;

    GetMousePos(&current);

    if (wp == 0)
	return;

    // Determine if we are above or below the window,
    // and if so, how far...
    if (current.y < wp->w_toprow) {
	// Above the window
	// Scroll = wp->w_toprow - current.y;
	Scroll = 1;
    }
    if (current.y > mode_row(wp)) {
	// Below
	// Scroll = current.y - mode_row(wp);
	// Scroll *= -1;
	Scroll = -1;
    }
    if (Scroll) {
	int row;
	if (Scroll > 0) {
	    row = wp->w_toprow;
	} else {
	    row = mode_row(wp) - 1;
	}

	// Scroll the pre-determined amount, ensuring at least one line of
	// window movement per timer tick.  Note also that ScrollScale is
	// signed, so it will be negative if we want to scroll down.
	mvupwind(TRUE, Scroll * max(ScrollCount, TRIGGER) / (Throttle + DVSR));

	// Set the cursor. Column doesn't really matter, it will
	// get updated as soon as we get back into the window...
	setcursor(row, 0) && sel_extend(TRUE, TRUE);
	(void) update(TRUE);
	ScrollCount++;
	if (ScrollCount > TRIGGER && Throttle > 0 && ScrollCount % INCR == 0)
	    Throttle--;
    } else {
	// Reset counters
	Throttle = INCR;
	ScrollCount = 0;
    }
#undef DVSR
#undef INCR
#undef TRIGGER
}
Example #13
0
File: cons.c Project: fmeola/MTask
void
mt_cons_gotoxy(unsigned x, unsigned y)
{
	if (y < NUMROWS && x < NUMCOLS)
	{
		cur_x = x;
		cur_y = y;
		setcursor();
	}
}
Example #14
0
/*
 * FUNCTION
 *   mousemove(int    *sel_pending,
 *             POINT  *first,
 *             POINT  *current,
 *             MARK   *lmbdn_mark,
 *             int    rect_rgn)
 *
 *   sel_pending - Boolean, T -> client has recorded a left mouse button (LMB)
 *                 click, and so, a selection is pending.
 *
 *   first       - editor row/col coordinates where LMB was initially recorded.
 *
 *   latest      - during the mouse move, assuming the LMB is still down,
 *                 "latest" tracks the cursor position wrt window resizing
 *                 operations (via a modeline drag).
 *
 *   current     - current cursor row/col coordiantes.
 *
 *   lmbdn_mark  - editor MARK when "LMB down" was initially recorded.
 *
 *   rect_rgn    - Boolean, T -> user wants rectangular region selection.
 *
 * DESCRIPTION
 *   Using several state variables, this function handles all the semantics
 *   of a left mouse button "MOVE" event.  The semantics are as follows:
 *
 *   1) This function will not be called unless the LMB is down and the
 *      cursor is not being used to drage the mode line (enforced by caller).
 *   2) a LMB move within the current editor window selects a region of text.
 *      Later, when the user releases the LMB, that text is yanked to the
 *      unnamed register (the yank code is not handled in this function).
 *
 * RETURNS
 *   None
 */
static void
mousemove(int *sel_pending,
	  COORD * first,
	  COORD * current,
	  MARK *lmbdn_mark,
	  int rect_rgn)
{
    int dummy;

    if (WaitForSingleObject(hAsMutex, AS_TMOUT) == WAIT_OBJECT_0) {
	if (*sel_pending) {
	    /*
	     * Selection pending.  If the mouse has moved at least one char,
	     * start a selection.
	     */

	    if (MouseClickSetPos(current, &dummy)) {
		/* ignore mouse jitter */

		if (current->X != first->X || current->Y != first->Y) {
		    *sel_pending = FALSE;
		    DOT = *lmbdn_mark;
		    (void) sel_begin();
		    (void) update(TRUE);
		} else {
		    (void) ReleaseMutex(hAsMutex);
		    return;
		}
	    }
	}
	if (mouse_wp != row2window(current->Y)) {
	    /*
	     * mouse moved into a different editor window or row2window()
	     * returned a NULL ptr.
	     */

	    (void) ReleaseMutex(hAsMutex);
	    return;
	}
	if (!setcursor(current->Y, current->X)) {
	    (void) ReleaseMutex(hAsMutex);
	    return;
	}
	if (rect_rgn)
	    (void) sel_setshape(rgn_RECTANGLE);
	if (sel_extend(TRUE, TRUE))
	    (void) update(TRUE);
	(void) ReleaseMutex(hAsMutex);
    }
    /*
     * Else either the worker thread abandonded the mutex (not possible as
     * currently coded) or timed out.  If the latter, something is
     * hung--don't do anything.
     */
}
Example #15
0
File: stg1.c Project: acalvoa/SNAKE
void stg1(){
	while(1){
		BACK_TO_FLAG = 0;
		clear_screen();
		setcursor(8,5,1);
		printg("SNAKE: ADIN EDITION MENU\n\r\0",0,_C_YELLOW);
		set_border();
		draw_game_line(23,25,133,25,_C_YELLOW,1);
		setcursor(8,8,1);
		printg("1.- Start Game",0,_C_YELLOW);
		setcursor(8,9,1);
		printg("2.- Select Difficult",0,_C_YELLOW);
		setcursor(8,10,1);
		printg("3.- Back to screen",0,_C_YELLOW);
		write_diff();
		write_highscore();
		select_menu();
		if(BACK_TO_FLAG == 1) break;
	}
}
Example #16
0
void PrintPercentageComplete(char* text, int percentage)
{
	char buf[200];
	int timetosleep = 30;
	POINT pt;
	sprintf(buf, "%s - %2.2d%%", text, percentage);
	pt.x = retrieveTextCenterH(buf);
	pt.y = retrieveTextCenterV();
	setcursor(pt.x, pt.y);
	LRED;
	printf("%s", buf);
//	Sleep(timetosleep);
}
Example #17
0
void StartMissionChronoSequence(PMISSIONCHRONO mchrono)
{
	COORD mcdrawcoords;
	TIMER timer;
	char mctimebuf[80];
	int i;
	
	
	mchrono->countdown = TRUE;
	sprintf(mctimebuf, "%2.2d:%2.2d.%2.2d", mchrono->minutes, mchrono->seconds, mchrono->split);
	mcdrawcoords = retrieveTextCenter(mctimebuf);
	GREEN;
	
	setcursor(mcdrawcoords.X, mcdrawcoords.Y);
	printf(mctimebuf);
	Sleep(80);
	LGREEN;
	setcursor(mcdrawcoords.X, mcdrawcoords.Y);
	printf(mctimebuf);
	Sleep(1000);
	LRED;
	setcursor(mcdrawcoords.X, mcdrawcoords.Y);
	printf(mctimebuf);
	Sleep(500);
	for (i = 0; i < 150; i++){
		if(i == 148){
			RED;
		}
		StartTimer(&timer);
		sprintf(mctimebuf, "%2.2d:%2.2d.%2.2d", mchrono->minutes, mchrono->seconds, mchrono->split);
		setcursor(mcdrawcoords.X, mcdrawcoords.Y);
		printf(mctimebuf);
		Sleep(50);
		EndTimer(&timer);
		mchrono->split -= SplitElapsed(&timer);
		calibratemissionchrono(mchrono);
	}
	cls();
}
Example #18
0
File: cons.c Project: fmeola/MTask
static void
put(unsigned char ch)
{
	vidmem[cur_y][cur_x++] = (ch & 0xFF) | cur_attr;
	if (cur_x >= NUMCOLS)
	{
		cur_x = 0;
		if (cur_y == NUMROWS - 1)
			scroll();
		else
			cur_y++;
	}
	setcursor();
}
Example #19
0
void
reset_grafx()
{
#ifdef IRIS
#undef setvaluator
  setvaluator(MOUSEX,getgdesc(GD_XPMAX)/2,0,getgdesc(GD_XPMAX));
  setvaluator(MOUSEY,getgdesc(GD_YPMAX)/2,0,getgdesc(GD_YPMAX));
#define setvaluator gl_setvaluator
  attachcursor(MOUSEX,MOUSEY);
  setcursor(0,0,0);
  curson();
  gexit();
#endif
}
sqInt ioSetCursor(sqInt cursorBitsIndex, sqInt offsetX, sqInt offsetY) {
	uchar* cursorBits = (uchar*)pointerForOop(cursorBitsIndex);
	int i;
	Cursor c;
	c.offset.x = offsetX;
	c.offset.y = offsetY;
	for (i = 0; i < 16; i++) {
		c.clr[i*2] = 0;
		c.clr[i*2+1] = 0;
		c.set[i*2] = cursorBits[i*4+3];
		c.set[i*2+1] = cursorBits[i*4+2];
	}
	setcursor(mousectl, &c);
	return 0;
}
Example #21
0
bool ShootingPrintHitGraphic(COORD location, int timeshit)
{
	COORD consize = getconsize();

	if (location.X < 0 || location.X >= consize.X || location.Y < 0 || location.Y > consize.Y)
		return false;

	if(timeshit >= SHOOTING_SILHOUETTE_HITMARKERSNUM)
	{
		timeshit = SHOOTING_SILHOUETTE_HITMARKERSNUM - 1;
	}
	char toprint = g_Shooting_HitMarkers[timeshit];
	setcursor(location.X, location.Y);
	writechar(toprint);
	return true;
}
Example #22
0
/*
 * Initialize the board for playing
 */
static void
newgame(void)
{
    GR_COORD	row;
    GR_COORD	col;
    GR_COUNT	count;
    CELL		cell;
    POS		pos;

    for (row = 0; row < FULLSIZE; row++) {
        for (col = 0; col < FULLSIZE; col++) {
            cell = F_EMPTY;
            if (badsquare(row) || badsquare(col))
                cell |= F_EDGE;
            board[boardpos(row, col)] = cell;
        }
    }

    playing = GR_TRUE;
    count = 0;
    legs = 2;
    steps = 0;
    drawstatus();
    setcursor();

    while (count < mines) {
        do {
            row = (rand() / 16) % (size * size + 1);
        } while (row == (size * size));

        col = (row % size) + 1;
        row = (row / size) + 1;
        pos = boardpos(row, col);

        if ((pos == boardpos(1,1)) || (pos == boardpos(1,2)) ||
                (pos == boardpos(2,1)) || (pos == boardpos(2,2)) ||
                (pos == boardpos(size,size)))
            continue;

        if (!ismine(board[pos]) && checkpath(pos))
            count++;
    }

    board[boardpos(1,1)] = (F_OLD | '0');

    GrClearWindow(boardwid, GR_TRUE);
}
Example #23
0
void showcell(int row,coltype col)
{
int back,fore,curs;
switch(row)
	{
	case 0 :
	case 1 :
	case 2 :
	case 3 :
	case 4 :
	case 5 :
	case 7 :
	case 9 :
	case 14 :
	case 15 :
	case 16 :
	case 17 :
	case 18 :
	case 19 :
	case 20 :
		 back = data[col][6];
		 fore = data[col][row];
		 curs = data[col][11];
		 break;
	case 6  :
	case 8  :
	case 10 :
	case 13 :
		 back = data[col][row];
		 fore = data[col][5];
		 curs = data[col][11];
		 break;
	case 11 :
	case 12 :
		 back = data[col][6];
		 fore = data[col][5];
		 curs = data[col][row];
		 break;
	}
gotoxy(row+2,40+col*8);
textcolor(fore);
textbackground(back);
setcursor(curs);
cputs("       ");
gotoxy(row+2,40+col*8);
}
Example #24
0
void _setcursortype(int type)
{
    unsigned cursor_shape;
    switch (type)
    {
        case _NOCURSOR:
            cursor_shape = 0x0700;
            break;
        case _SOLIDCURSOR:
            cursor_shape = 0x0007;
            break;
/*      case _NORMALCURSOR: */
        default:
            cursor_shape = 0x0607;
            break;
    }
    setcursor(cursor_shape);
}
Example #25
0
static void create_dialog()
{
    setcursor(ArrowCursor);  /* not `busy' cursor */
    win = newwindow("t-test entry", rect(0, 0, 200, 200),
                    Titlebar | Centered | Modal);
    setbackground(win, dialog_bg());
    setkeydown(win, hit_key);
    bApply = newbutton("Apply", rect(20, 160, 50, 25), apply);
    bCancel = newbutton("Cancel", rect(120, 160, 50, 25), NULL);
    l_var1 = newlabel("x", rect(10, 10, 30, 20), AlignLeft);
    var1 = newfield("", rect(40, 10, 130, 20));
    l_var2 = newlabel("y", rect(10, 40, 30, 20), AlignLeft);
    var2 = newfield("", rect(40, 40, 130, 20));
    paired = newcheckbox("paired", rect(10, 70, 80, 20), NULL);
    varequal = newcheckbox("equal var", rect(110, 70, 80, 20), NULL);
    alt = newdroplist(alts , rect(30, 90, 120, 20), NULL);
    setlistitem(alt, 0);
    l_lvl = newlabel("confidence level", rect(20, 120, 90, 20), AlignLeft);
    lvl = newfield("0.95", rect(120, 120, 40, 20));
}
Example #26
0
void setupbenchmark()
{
	int x,y;

	setcursor(CURSORARROW);
	SDL_FillRect(screen,NULL,color.background);

	for (x=0;x<WIDTH;x++)
		for (y=0;y<HEIGHT;y++)
		{
			if (x<BORDERLEFT || x>=BORDERRIGHT || y <BORDERTOP || y>=BORDERBOTTOM) 	
				grid[x][y]='X';
			else
				grid[x][y]=' ';
		}
	
	drawgridblocks();

	updateall();
}
Example #27
0
void		key_events(t_env *w)
{
	shape(w);
	move(w);
	choose_mode(w);
	if (w->inkeys[SDL_SCANCODE_MINUS])
		iteration_less(w);
	if (w->inkeys[SDL_SCANCODE_EQUALS])
		iteration_more(w);
	if (w->inkeys[SDL_SCANCODE_M])
		zoomin(w);
	if (w->inkeys[SDL_SCANCODE_N])
		zoomout(w);
	if (w->inkeys[SDL_SCANCODE_V])
		setcursor(w);
	if (w->inkeys[SDL_SCANCODE_P])
	{
		w->posx = 0;
		w->posy = 0;
	}
}
Example #28
0
static int
MouseClickSetPos(COORD * result, int *onmode)
{
    WINDOW *wp;

    TRACE(("GETC:setcursor(%d, %d)\n", result->Y, result->X));

    /*
     * If we're getting a button-down in a window, allow it to begin a
     * selection.  A button-down on its modeline will allow resizing the
     * window.
     */
    *onmode = FALSE;
    if ((wp = row2window(result->Y)) != 0) {
	if (result->Y == mode_row(wp)) {
	    *onmode = TRUE;
	    return TRUE;
	}
	return setcursor(result->Y, result->X);
    }
    return FALSE;
}
Example #29
0
void
screeninit(int x, int y, char *chanstr)
{
	Point p, q;
	char *greet;
	char buf[128];
	Memimage *grey;
	Rectangle r;
	int chan;

	cursorver = 0;

	memimageinit();
	chan = strtochan(chanstr);
	if(chan == 0)
		error("bad screen channel string");

	r = Rect(0, 0, x, y);
	gscreen = allocmemimage(r, chan);
	if(gscreen == nil){
		snprint(buf, sizeof buf, "can't allocate screen image: %r");
		error(buf);
	}

	offscreen = Pt(x + 100, y + 100);
	cursorr = Rect(0, 0, CURSORDIM, CURSORDIM);
	cursorset = allocmemimage(cursorr, GREY8);
	cursorclear = allocmemimage(cursorr, GREY1);
	if(cursorset == nil || cursorclear == nil){
		freememimage(gscreen);
		freememimage(cursorset);
		freememimage(cursorclear);
		gscreen = nil;
		cursorset = nil;
		cursorclear = nil;
		snprint(buf, sizeof buf, "can't allocate cursor images: %r");
		error(buf);
	}

	drawlock();

	/*
	 * set up goo for screenputs
	 */
	memdefont = getmemdefont();

	back = memwhite;
	conscol = memblack;

	/* a lot of work to get a grey color */
	curscol = allocmemimage(Rect(0,0,1,1), RGBA32);
	curscol->flags |= Frepl;
	curscol->clipr = gscreen->r;
	memfillcolor(curscol, 0xff0000ff);

	memfillcolor(gscreen, 0x444488FF);

	w = memdefont->info[' '].width;
	h = memdefont->height;

	window.min = addpt(gscreen->r.min, Pt(20,20));
	window.max.x = window.min.x + Dx(gscreen->r)*3/4-40;
	window.max.y = window.min.y + Dy(gscreen->r)*3/4-100;

	memimagedraw(gscreen, window, memblack, ZP, memopaque, ZP, S);
	window = insetrect(window, 4);
	memimagedraw(gscreen, window, memwhite, ZP, memopaque, ZP, S);

	/* a lot of work to get a grey color */
	grey = allocmemimage(Rect(0,0,1,1), CMAP8);
	grey->flags |= Frepl;
	grey->clipr = gscreen->r;
	memfillcolor(grey, 0xAAAAAAFF);
	memimagedraw(gscreen, Rect(window.min.x, window.min.y,
			window.max.x, window.min.y+h+5+6), grey, ZP, nil, ZP, S);
	freememimage(grey);
	window = insetrect(window, 5);

	greet = " Plan 9 Console ";
	p = addpt(window.min, Pt(10, 0));
	q = memsubfontwidth(memdefont, greet);
	memimagestring(gscreen, p, conscol, ZP, memdefont, greet);
	window.min.y += h+6;
	curpos = window.min;
	window.max.y = window.min.y+((window.max.y-window.min.y)/h)*h;
	flushmemscreen(gscreen->r);

	drawunlock();

	setcursor(&arrow);
}
Example #30
0
/*ARGSUSED*/
j31_set_cursor(f, n)
{
	register int	s;
	register char	*p;
	register char	c;
	register int	pos = 0;
	register int	i;
	char	buf[NFILEN];

	if ((s = ereply("IBM PC Cursor: ", buf, NFILEN)) != TRUE) {
		return (s);
	}

	i = -1;

	for (p = buf; *p;) {
		c = *p++ & 0xff;
		switch (c) {
			case ',':
			case ':':
			if (i >= 0 && i <= 15) {
				if (pos == 0) {
					new_start_line = i;
				} else if (pos == 1) {
					new_end_line = i;
				}
			}
			i = -1;
			if (++pos > 3) {
				return TRUE;
			}
			break;
			case 't':
			case 'T':
			if (pos == 2) {
				new_blink_mode = 0;	/* Blink on. */
			} else if (pos == 3) {
				hold_new_cursor = 1;	/* Hold on. */
			}
			break;
			case 'n':
			case 'N':
			if (pos == 2) {
				new_blink_mode = 1;	/* Blink off. */
			} else if (pos == 3) {
				hold_new_cursor = 0;	/* Hold off. */
			}
			break;
			case '0': case '1': case '2': case '3': case '4':
			case '5': case '6': case '7': case '8': case '9':
			if (i == -1) {
				i = 0;
			}
			i = i * 10 + c - '0';
			break;
		}
	}
	if (i >= 0 && i <= 15) {
		if (pos == 0) {
			new_start_line = i;
		} else if (pos == 1) {
			new_end_line = i;
		}
	}
	setcursor(new_start_line, new_end_line, new_blink_mode);
	return (TRUE);
}