Beispiel #1
0
/* calc cursor pos and show cursor correctly */
static int
cursor_pos(keeploc_t * locmem, int val, int from_top, int isshow)
{
    int  top=locmem->top_ln;
    if (!last_line) {
        cursor_show(3 , 0);
        return DONOTHING;
    }
    if (val > last_line)
        val = last_line;
    if (val <= 0)
        val = 1;
    if (val >= top && val < top + headers_size) {
        if(isshow) {
            if(locmem->crs_ln >= top)
                cursor_clear(3 + locmem->crs_ln - top, 0);
            cursor_show(3 + val - top, 0);
        }
        locmem->crs_ln = val;
        return DONOTHING;
    }
    locmem->top_ln = val - from_top;
    if (locmem->top_ln <= 0)
        locmem->top_ln = 1;
    locmem->crs_ln = val;
    return isshow ? PARTUPDATE : HEADERS_RELOAD;
}
Beispiel #2
0
// TODO
// move this function to vtuikit.c
int
cursor_key(int row, int column)
{
    int             ch;

    cursor_show(row, column);
    ch = vkey();
    cursor_clear(row, column);
    return ch;
}
Beispiel #3
0
/* Parse wscons status events. */
void
selection_wscons_event(struct wscons_event evt, int preclose)
{

	switch (evt.type) {
	case WSCONS_EVENT_SCREEN_SWITCH:
		if (preclose) {
			if (Selmouse.sm_selecting)
				selarea_hide();
			cursor_hide();
		} else {
			if (!Selmouse.sm_mouse->m_disabled)
				open_tty(evt.value);

			cursor_show();
			if (Selmouse.sm_selecting)
				selarea_show();
		}

		break;
	}
}
Beispiel #4
0
void ascii_write_destroy() {
    console_clear();
    cursor_reset();
    cursor_show();
}
Beispiel #5
0
int main(int argc, char *argv[])
{
	kbd_event_t ev;
	coord_t coord;
	bool new_file;

	spt_t pt;

	con = console_init(stdin, stdout);
	console_clear(con);

	console_get_size(con, &scr_columns, &scr_rows);

	pane.rows = scr_rows - 1;
	pane.columns = scr_columns;
	pane.sh_row = 1;
	pane.sh_column = 1;

	/* Start with an empty sheet. */
	sheet_init(&doc.sh);

	/* Place caret at the beginning of file. */
	coord.row = coord.column = 1;
	sheet_get_cell_pt(&doc.sh, &coord, dir_before, &pt);
	sheet_place_tag(&doc.sh, &pt, &pane.caret_pos);
	pane.ideal_column = coord.column;

	if (argc == 2) {
		doc.file_name = str_dup(argv[1]);
	} else if (argc > 1) {
		printf("Invalid arguments.\n");
		return -2;
	} else {
		doc.file_name = NULL;
	}

	new_file = false;

	if (doc.file_name == NULL || file_insert(doc.file_name) != EOK)
		new_file = true;

	/* Move to beginning of file. */
	caret_move(-ED_INFTY, -ED_INFTY, dir_before);

	/* Place selection start tag. */
	tag_get_pt(&pane.caret_pos, &pt);
	sheet_place_tag(&doc.sh, &pt, &pane.sel_start);

	/* Initial display */
	cursor_visible = true;

	cursor_hide();
	console_clear(con);
	pane_text_display();
	pane_status_display();
	if (new_file && doc.file_name != NULL)
		status_display("File not found. Starting empty file.");
	pane_caret_display();
	cursor_show();

	done = false;

	while (!done) {
		console_get_kbd_event(con, &ev);
		pane.rflags = 0;

		if (ev.type == KEY_PRESS) {
			/* Handle key press. */
			if (((ev.mods & KM_ALT) == 0) &&
			    ((ev.mods & KM_SHIFT) == 0) &&
			     (ev.mods & KM_CTRL) != 0) {
				key_handle_ctrl(&ev);
			} else if (((ev.mods & KM_ALT) == 0) &&
			    ((ev.mods & KM_CTRL) == 0) &&
			     (ev.mods & KM_SHIFT) != 0) {
				key_handle_shift(&ev);
			} else if ((ev.mods & (KM_CTRL | KM_ALT | KM_SHIFT)) == 0) {
				key_handle_unmod(&ev);
			}
		}

		/* Redraw as necessary. */

		cursor_hide();

		if (pane.rflags & REDRAW_TEXT)
			pane_text_display();
		if (pane.rflags & REDRAW_ROW)
			pane_row_display();
		if (pane.rflags & REDRAW_STATUS)
			pane_status_display();
		if (pane.rflags & REDRAW_CARET)
			pane_caret_display();

		cursor_show();
	}

	console_clear(con);

	return 0;
}
Beispiel #6
0
int p_seven()
{
    char buf1[8],log[80];
    char *kind[9]= {"¯QÀs","³æ­F","¨ß­F","¤T±ø","¶¶¤l","¦Pªá","¸¬Äª",
                    "ÅK¤ä","¬h¤B"
                   };
    char *poker[52]= {"¢±","¢±","¢±","¢±","¢²","¢²","¢²","¢²",
                      "¢³","¢³","¢³","¢³","¢´","¢´","¢´","¢´","¢µ","¢µ","¢µ","¢µ",
                      "¢¶","¢¶","¢¶","¢¶","¢·","¢·","¢·","¢·","¢¸","¢¸","¢¸","¢¸",
                      "10","10","10","10","¢Ø","¢Ø","¢Ø","¢Ø","¢ß","¢ß","¢ß","¢ß",
                      "¢Ù","¢Ù","¢Ù","¢Ù","¢Ï","¢Ï","¢Ï","¢Ï"
                     };
    int cardlist[52]= {0};
    int mark[2]= {7,7}, set[6],key,tax=0; /* tax ¬°ª±®aĹ®É©âªºµ| */
    int i,j,k,x,m,ch,z=1;
    int win,color,color2,bet;
    int host_card[7]= {0}, guest_card[7]= {0};

    time_t now = time(0);
    time(&now);

    while(-1) {
        clear();
        setutmpmode(SEVENCARD);
        showtitle("½ä«°¤C±i", BoardName);
        show_money(bet=0);
        do
        {
            getdata(21, 0,"­n¤Uª`¦h¤Ö©O(¤W­­250000)? «ö Enter Â÷¶}>", buf1, 7, 1, 0);
            bet=atoi(buf1);
            if(bet<0) bet=0;
        } while(bet>250000);
        if(!bet) return 0;
        if(bet>cuser.silvermoney)
        {
            pressanykey("§Aªº²{ª÷¤£°÷³á.. :)");
            return 0;
        }

        demoney(bet);
        show_money(bet);
        move(21,0);
        prints("(«ö ¡ô¡õ¡ö¡÷ ©Î ijkl ¿ïµP, ¿ï¦n«ö enter ÅuµP)");

        for(i=0; i<52; i++) cardlist[i]=0;
        mark[0]=mark[1]=7;
        z=1;

        for(i=1; i<=52; i++) {
            m=0;
            do {
                j=(time(0)+cuser.silvermoney+random())%52;
                if (cardlist[j]==0) {
                    cardlist[j]=i;
                    m=1;
                }
            } while(m==0);
        };
        for(i=0; i<52; i++)cardlist[i]--; /* ¬~µP */

        j=0;
        for(i=0; i<7; i++) {
            host_card[i]=cardlist[j];
            j++;
            guest_card[i]=cardlist[j];
            j++;
        }        /* µo«e¤Q¥|±iµP */

        for(i=0; i<7; i++) {
            for(j=0; j<(6-i); j++) {
                if(guest_card[j]>guest_card[j+1]) {
                    x=guest_card[j];
                    guest_card[j]=guest_card[j+1];
                    guest_card[j+1]=x;
                }
                if(host_card[j]>host_card[j+1]) {
                    x=host_card[j];
                    host_card[j]=host_card[j+1];
                    host_card[j+1]=x;
                }
            }
        }        /* ±Æ§Ç */
        move(1,0);
        prints("¥»¹CÀ¸¥Ñ¯îÂÕ¤Û¹Ò(weird.twbbs.org)¯¸ªø weiren ³]­p´£¨Ñ! ¯S¦¹·PÁÂ!!\n");
        prints("e-mail: [email protected]");

        move(3,0);
        prints("¢~¢w¢~¢w¢~¢w¢~¢w¢~¢w¢~¢w¢~¢w¢w¢w¢¡");
        move(4,0);
        prints("¢x  ¢x  ¢x  ¢x  ¢x  ¢x  ¢x      ¢x");
        move(5,0);
        prints("¢x  ¢x  ¢x  ¢x  ¢x  ¢x  ¢x      ¢x");
        move(6,0);
        prints("¢x  ¢x  ¢x  ¢x  ¢x  ¢x  ¢x      ¢x");
        move(7,0);
        prints("¢x  ¢x  ¢x  ¢x  ¢x  ¢x  ¢x      ¢x");
        move(8,0);
        prints("¢x  ¢x  ¢x  ¢x  ¢x  ¢x  ¢x      ¢x");
        move(9,0);
        prints("¢¢¢w¢¢¢w¢¢¢w¢¢¢w¢¢¢w¢¢¢w¢¢¢w¢w¢w¢£");

        for(i=0; i<7; i++) {
            print_Scard(guest_card[i],11,0+4*i);  /* ¦L¥X«e¤C±iµP */
        }

        j=2;
        k=0;
        x=0;
        move(15,2);
        do {
            ch=igetkey();
            switch (ch)
            {
            case KEY_RIGHT:
            case 'l':
                j+=4;
                if(j>26)j=26;
                break;
            case KEY_LEFT:
            case 'j':
                j-=4;
                if(j<2)j=2;
                break;
            case KEY_UP:
            case 'i':
                k=(j-2)/4;
                if(x<2&&mark[0]!=k&&mark[1]!=k) {
                    if(mark[0]==7)mark[0]=k;
                    else mark[1]=k;
                    x++;
                    cursor_show(15,j);
                }
                break;
            case KEY_DOWN:
            case 'k':
                k=(j-2)/4;
                if(mark[0]==k) {
                    mark[0]=7;
                    x--;
                }
                if(mark[1]==k) {
                    mark[1]=7;
                    x--;
                }
                cursor_clear(15,j);
                break;
            case 13:   /* ¿ï¥X¨â±i«á«ö enter */
                if(x==2)z=0;
                break;
                prints("¥»¹CÀ¸¥Ñ¯îÂÕ¤Û¹Ò(weird.twbbs.org)¯¸ªø weiren ³]­p\n");
                prints("e-mail: [email protected]");
            }
            move(15,j);
        } while(z==1);

        if(mark[0]>mark[1]) {
            i=mark[0];
            mark[0]=mark[1];
            mark[1]=i;
        }
        for(i=1; i<18; i++) {
            move(i,0);
            clrtoeol();
        }
        print_Scard(guest_card[mark[0]],11,0);
        print_Scard(guest_card[mark[1]],11,4);
        j=0;
        for(i=0; i<7; i++) {
            if(i!=mark[0]&&i!=mark[1]) {
                print_Scard(guest_card[i],11,16+j*4);
                set[j]=guest_card[i];
                j++;
            }
        }                   /* ¦L¥Xª±®a¤À¦n¨â°ô«áªºµP */
        set[5]=5;
        if(diedragon(set,guest_card[mark[0]],guest_card[mark[1]])==1)
        {
            ;
            pressanykey("­ËÀs!");
            continue;
        }
        if(guest_card[mark[0]]/4==guest_card[mark[1]]/4)x=1;

        key=find_host(host_card);
        print_hostcard(host_card,key,log);
        i=bigsmall(host_card,guest_card,key,mark);
        switch(i) {
        case 0:
            win=2;
            color=41;
            color2=41;
            break; /* ª±®a duA duB ¬ÒĹ  */
        case 1:
            win=1;
            color=41;
            color2=47;
            break; /*      duA Ĺ duB ¿é */
        case 2:
            win=1;
            color=47;
            color2=41;
            break; /*      duA ¿é duB Ĺ */
        case 3:
            win=0;
            color=47;
            color2=47;
            break; /*      ¨â½ä¬Ò¿é */
        }
        game_log(SEVENCARD,"§ÚªºµP%s%s%s..¹q¸£%s..%s..%d",poker[guest_card[mark[0]]],
                 x==1?"­F":poker[guest_card[mark[1]]],kind[find_all(set)],log,
                 win?(win==1?"¥­¤â":"ŤF"):"¿é¤F",bet);
        move(15,4);
        prints("[1;%d;%dm   %s%s     ¢x  ¢x  [1;%d;%dm         %s         "
               ,color,  color==41?33:30
               ,poker[guest_card[mark[0]]],x==1?"­F":poker[guest_card[mark[1]]]
               ,color2, color2==41?33:30
               ,kind[find_all(set)]);
        i=bet*2-bet/100*tax;
        switch(win) {
        case 2:
            pressanykey("§AŤF %d !!.. :D",i-bet);
            inmoney(i);
            break;
        case 1:
            pressanykey("¥­¤â!!..");
            inmoney(bet);
            break;
        case 0:
            pressanykey("§A¿é¤F³á.. :))" );
            break;
        }
    }
}
Beispiel #7
0
/* Parse wsmouse events.  Both motion and button events are handled.  The
 * former move the mouse across the screen and the later create a new
 * selection or paste the buffer. */
void
selection_wsmouse_event(struct wscons_event evt)
{

	if (IS_MOTION_EVENT(evt.type)) {
		if (Selmouse.sm_selecting)
			selarea_hide();
		cursor_hide();

		switch (evt.type) {
		case WSCONS_EVENT_MOUSE_DELTA_X:
			if (Selmouse.sm_count_x >= Selmouse.sm_slowdown_x) {
				Selmouse.sm_count_x = 0;
				if (evt.value > 0)
					Selmouse.sm_x++;
				else if (Selmouse.sm_x != 0)
					Selmouse.sm_x--;
				if (Selmouse.sm_x > Selmouse.sm_max_x)
					Selmouse.sm_x = Selmouse.sm_max_x;
			} else
				Selmouse.sm_count_x++;
			break;

		case WSCONS_EVENT_MOUSE_DELTA_Y:
			if (Selmouse.sm_count_y >= Selmouse.sm_slowdown_y) {
				Selmouse.sm_count_y = 0;
				if (evt.value < 0)
					Selmouse.sm_y++;
				else if (Selmouse.sm_y != 0)
					Selmouse.sm_y--;
				if (Selmouse.sm_y > Selmouse.sm_max_y)
					Selmouse.sm_y = Selmouse.sm_max_y;
			} else
				Selmouse.sm_count_y++;
			break;

		case WSCONS_EVENT_MOUSE_DELTA_Z:
			break;

		default:
			log_warnx("unknown event");
		}

		if (Selmouse.sm_selecting)
			selarea_show();
		cursor_show();

	} else if (IS_BUTTON_EVENT(evt.type)) {
		switch (evt.type) {
		case WSCONS_EVENT_MOUSE_UP:
			if (evt.value == Selmouse.sm_but_select) {
				/* End selection */
				selarea_end();
				selarea_hide();
			}
			break;

		case WSCONS_EVENT_MOUSE_DOWN:
			if (evt.value == Selmouse.sm_but_select) {
				/* Start selection */
				selarea_start();
				cursor_hide();
				selarea_show();
			} else if (evt.value == Selmouse.sm_but_paste) {
				/* Paste selection */
				selarea_paste();
				break;
			}
			break;

		default:
			log_warnx("unknown button event");
		}
	}
}