예제 #1
0
void loading()
{
int i,j,x,y;

setbkcolor(6);

	x=getmaxx()/2;
	y=getmaxy()/2;
	for(j=30;j<200;j++)
	{
		delay(10);
		setcolor(j/20);
		arc(x,y,0,180,j-10);
	}
settextstyle(3,0,6);
outtextxy(150,250,"!..DOGDE IT..!");
settextstyle(4,0,4);
outtextxy(250,340,"LOADING");
for(i=100; i<600; i++)
{
bar(i,380,i,400);
delay(10);
}
}
예제 #2
0
int main()
{

int x,y,i;
	int g=DETECT,d;
       initgraph(&g,&d,"\tc\bgi");
       cleardevice();
       x=getmaxx()/2;
       y=getmaxy()/2;
       settextstyle(TRIPLEX_FONT, HORIZ_DIR, 3);
       setbkcolor(rand());
       setcolor(4);
       outtextxy(30,100,"Press");
       outtextxy(30,130,"any");
       outtextxy(30,160,"key");
       outtextxy(30,190, "to");
       outtextxy(30,220,"Quit");
       while (!kbhit())
       {
       setcolor(rand());
       for (int i=0;i<50;i++)
       circle(x,y,i );
       setcolor(rand());
       for (int j=70;j<120;j++)
       circle(x,y,j);
       setcolor(rand());
       for (int k=140;k<190;k++)
       circle(x,y,k);
       setcolor(rand());
       for (int l=210;l<230;l++)
       circle(x,y,l);
       delay(200);
       }
       getch();
       closegraph();
}
예제 #3
0
/*
 * Ask user for a window definition.
 */
static bool
getwindow(WINDOW *parent, PAIR * ul, PAIR * lr)
{
    int min_col = (parent == stdscr) ? COL_MIN : 0;
    int max_col = (parent == stdscr) ? COL_MAX : getmaxx(parent);
    int min_line = (parent == stdscr) ? LINE_MIN : 0;
    int max_line = (parent == stdscr) ? LINE_MAX : getmaxy(parent);
    PAIR *tmp;
    bool result = FALSE;

    head_line("Use arrows to move cursor, anything else to mark corner 1");
    if ((tmp = selectcell(parent, 0,
			  min_line, min_col,
			  max_line, max_col,
			  FALSE,
			  (bool *) 0)) != 0) {
	*ul = *tmp;
	MvWAddCh(parent, ul->y, ul->x, '*');

	head_line("Use arrows to move cursor, anything else to mark corner 2");
	if ((tmp = selectcell(parent, 0,
			      ul->y, ul->x,
			      max_line, max_col,
			      FALSE,
			      (bool *) 0)) != 0) {
	    *lr = *tmp;
	    MvWAddCh(parent, lr->y, lr->x, '*');
	    wmove(parent, lr->y, lr->x);
	    wsyncdown(parent);
	    wrefresh(parent);
	    result = (lr->y != ul->y && lr->x != ul->x);
	}
    }
    head_line("done");
    return result;
}
예제 #4
0
파일: cmdline.c 프로젝트: ackeack/workenv
void
redraw_cmdline(void)
{
	if(prev_mode == MENU_MODE)
	{
		menu_redraw();
	}
	else
	{
		update_screen(UT_FULL);
		if(prev_mode == SORT_MODE)
			redraw_sort_dialog();
		else if(prev_mode == ATTR_MODE)
			redraw_attr_dialog();
	}

	line_width = getmaxx(stdscr);
	curs_set(TRUE);
	update_cmdline_size();
	update_cmdline_text();

	if(input_stat.complete_continue && cfg.wild_menu)
		draw_wild_menu(-1);
}
예제 #5
0
void show_mutations_titlebar( WINDOW *window, std::string &menu_mode )
{
    werase( window );

    std::string caption = _( "MUTATIONS -" );
    int cap_offset = utf8_width( caption ) + 1;
    mvwprintz( window, 0,  0, c_blue, "%s", caption.c_str() );

    std::string desc;
    int desc_length = getmaxx( window ) - cap_offset;

    if( menu_mode == "reassigning" ) {
        desc = _( "Reassigning.\nSelect a mutation to reassign or press SPACE to cancel." );
    } else if( menu_mode == "activating" ) {
        desc = _( "<color_green>Activating</color>  <color_yellow>!</color> to examine, <color_yellow>=</color> to reassign." );
    } else if( menu_mode == "examining" ) {
        desc = _( "<color_ltblue>Examining</color>  <color_yellow>!</color> to activate, <color_yellow>=</color> to reassign." );
    }
    fold_and_print( window, 0, cap_offset, desc_length, c_white, desc );
    fold_and_print( window, 1, 0, desc_length, c_white,
                    _( "Might need to use ? to assign the keys." ) );

    wrefresh( window );
}
예제 #6
0
        virtual void select(int entnum, uimenu *menu) {
            if ( ! started ) {
                started = true;
                setup(menu);
            }
            if (entnum != lastent) {
                lastent = entnum;
                tmp = monster(GetMType(entnum));
                if (friendly) {
                    tmp.friendly = -1;
                }
            }

            werase(w_info);
            tmp.print_info(w_info);

            std::string header = string_format("#%d: %s", entnum, GetMType(entnum)->name.c_str());
            mvwprintz(w_info, 1, ( getmaxx(w_info) - header.size() ) / 2, c_cyan, "%s",
                      header.c_str());

            mvwprintz(w_info, getmaxy(w_info) - 3, 0, c_green, "%s", msg.c_str());
            msg = padding;
            mvwprintw(w_info, getmaxy(w_info) - 2, 0, _("[/] find, [f] friendly, [q]uit"));
        }
예제 #7
0
static void lua_paint_info(struct window *wnd, const struct state *st)
{
    struct lua_State *L = paint_state;
    int nx = st->cursor.x, ny = st->cursor.y;
    pnormalize(&nx, &ny, st->cursor.pl);
    lua_rawgeti(L, LUA_REGISTRYINDEX, paint_handle);
    lua_pushinteger(L, nx);
    lua_pushinteger(L, ny);
    if (lua_pcall(L, 2, 1, 0) != 0) {
        const char *error = lua_tostring(L, -1);
        log_error("paint function failed: %s\n", error);
        lua_pop(L, 1);
        tolua_error(L, TOLUA_CAST "event handler call failed", NULL);
    }
    else {
        const char *result = lua_tostring(L, -1);
        WINDOW *win = wnd->handle;
        int size = getmaxx(win) - 2;
        int line = 0, maxline = getmaxy(win) - 2;
        const char *str = result;
        wxborder(win);

        while (*str && line < maxline) {
            const char *end = strchr(str, '\n');
            if (!end)
                break;
            else {
                int bytes = (int)(end - str);
                if (bytes < size) bytes = size;
                mvwaddnstr(win, line++, 1, str, bytes);
                wclrtoeol(win);
                str = end + 1;
            }
        }
    }
}
예제 #8
0
/*
 * update the help text, which hijacks w_info's bottom border
 */
void editmap::uphelp (std::string txt1, std::string txt2, std::string title)
{

    if ( txt1 != "" ) {
        mvwprintw(w_help, 0, 0, "%s", padding.c_str() );
        mvwprintw(w_help, 1, 0, "%s", padding.c_str() );
        mvwprintw(w_help, ( txt2 != "" ? 0 : 1 ), 0, _(txt1.c_str()));
        if ( txt2 != "" ) {
            mvwprintw(w_help, 1, 0, _(txt2.c_str()));
        }
    }
    if ( title != "" ) {
        int hwidth = getmaxx(w_help);
        for ( int i = 0; i < hwidth; i++ ) { // catacurses/sdl/etc have no hline()
            mvwaddch(w_help, 2, i, LINE_OXOX);
        }
        int starttxt = int( (hwidth - title.size() - 4) / 2 );
        mvwprintw(w_help, 2, starttxt, "< ");
        wprintz(w_help, c_cyan, "%s", title.c_str() );
        wprintw(w_help, " >");
    }
    //mvwprintw(w_help, 0, 0, "%d,%d / %d,%d", target.x, target.y, origin.x, origin.y );
    wrefresh(w_help);
}
예제 #9
0
void setStatus(int_least16_t x, int_least16_t y, int_least16_t z, clock_t start, clock_t end, int_least16_t test) {

	// Daten zeichnen
	move( 10, 0);
	clrtoeol();
	printw("%d %d %d", x, y, z);

	move( 11, 0); clrtoeol();
	move( 12, 0); clrtoeol();
	move( 13, 0); clrtoeol();

	int maxx = getmaxx(stdscr);

	for(int i = 0; i < maxx; i++) {
		if(i > min(maxx/2, x/10 + maxx/2) && i < max(maxx/2, x/10 + maxx/2)) {
			move( 11, i);
			addch('x');
		}
		if(i > min(maxx/2, y/10 + maxx/2) && i < max(maxx/2, y/10 + maxx/2)) {
			move( 12, i);
			addch('y');
		}
		if(i > min(maxx/2, z/10 + maxx/2) && i < max(maxx/2, z/10 + maxx/2)) {
			move( 13, i);
			addch('z');
		}
	}
	
	double usec =  (double) (end-start) / CLOCKS_PER_SEC * 1000000.0;
	move(15, 0);
	printw("computation time for %d samples: %f. computation time for 1 sample: %f\n", test, usec, usec / test);
	printw("Number of samples per second: %ld\n", (long int)(1/usec * 1000L));
	printw("Test variable: %ld\n", test);
	
	refresh();
}
예제 #10
0
void shownumbers(int x1,int y1,int x2,int y2)
{
int k;
restrictmouseptr(0,400,getmaxx(),getmaxy());
setcolor(12);
settextstyle(0,0,0);
outtextxy(20,410,"Enter the number or click any of the following");
setcolor(RED);
	for(k=0;k<=9;k++)
	{
	settextstyle(0,0,1);
	setfillstyle(SOLID_FILL,CYAN);
	bar(x1,y1,x2,y2);
	rectangle(x1,y1,x2,y2);
	if(k==0)
	{
	outtextxy(x1+20,y1+20,"0");
	}
	if(k==1)
	{
	outtextxy(x1+20,y1+20,"1");
	}
	if(k==2)
	{
	outtextxy(x1+20,y1+20,"2");
	}
	if(k==3)
	{
	outtextxy(x1+20,y1+20,"3");
	}
	if(k==4)
	{
	outtextxy(x1+20,y1+20,"4");
	}
	if(k==5)
	{
	outtextxy(x1+20,y1+20,"5");
	}
	if(k==6)
	{
	outtextxy(x1+20,y1+20,"6");
	}
	if(k==7)
	{
	outtextxy(x1+20,y1+20,"7");
	}
	if(k==8)
	{
	outtextxy(x1+20,y1+20,"8");
	}
	if(k==9)
	{
	outtextxy(x1+20,y1+20,"9");
	}
	x1=x2;
	x2=x2+40;
	}
	setfillstyle(SOLID_FILL,8);
	setcolor(BLUE);
	bar(x1+100,y1+15,getmaxx()-10,y2);
	rectangle(x1+100,y1+15,getmaxx()-10,y2);
	rectangle(x1+102,y1+17,getmaxx()-12,y2-2);
	setcolor(BLUE);
	outtextxy(x1+130,y1+25,"C");
	setcolor(LIGHTCYAN);
	outtextxy(x1+138,y1+25,"ancel");
}
예제 #11
0
void main()
{

// VARIABLE DECLARATIONS

int i=0,j=0,a,front=-1,rear=-1;
char ch,ch1;
int item;

// FUNCTION PROTOTYPE DECLARATIONS

void show();
void slidebar(int *rear,int *front);
void showqueuesize();
void slidebar();
void cpoiters();
void drawq();
void moveptrs(int *rear,int *front);
void insertq(int *rear,char c);
void deleteq(int *front);
void qdelete(int q[],int rear,int front);
void hidequeueinfo();
void shownumbers(int x1,int y1,int x2,int y2);
int initmouse();
void getmousepos(int *button,int *x,int *y);
void showmouseptr();
void restrictmouseptr(int a,int b,int c,int d);
void exitbutton(int x1,int y1,int x2,int y2,int e_x,int e_y,int xit_x,int xit_y);
void zoomin();

// CHECKING THE GRAPHICS DRIVER

int gd=DETECT,gm,maxx,maxy,x,y,button;
initgraph(&gd,&gm,"c:\\TC");

// GET THE MAXIMUM X AND Y CO ORDINATES

	maxx=getmaxx();
	maxy=getmaxy();

// DRAW THE BORDER FOR THE WINDOW

	rectangle(0,0,maxx,maxy);

// SET THE AREA WITHIN THE SCREEN WHERE GRAPHICAL O/P DISPLAYED

	setviewport(1,1,maxx-1,maxy-1,1);

// WRITE THE HEADDING

	gotoxy(150,1);
	settextstyle(TRIPLEX_FONT,HORIZ_DIR,3);
	setcolor(WHITE);
	setbkcolor(216);
	settextjustify(0,2);
	outtextxy(220,2," LINEAR QUEUE ");
	setcolor(RED);
	settextstyle(8,HORIZ_DIR,3);
	outtextxy(40,35,"DEVELOPED IN 'C'  : IT'S A KVSM PRODUCT");
	settextstyle(0,HORIZ_DIR,0);

// INITIALIZE MOUSE,IF IT DOESN'T GET INITIALIZED CLOSE GRAPHICS MODE

	if (initmouse()==0)
	{
		closegraph();
		restorecrtmode();
		printf("\nMouse Driver not installed");
		exit(1);
	}

// IF MOUSE DRIVER INITIALISED THEN
// RESTRICT THE MOUSE POINTER WITHIN THE COORDINATES GIVEN GIVEN BELOW

	restrictmouseptr(1,57,maxx-1,maxy-1);

// SHOW THE MOUSE POINTER

	showmouseptr();

// SET THE TEXT COLOR TO WHITE

	setcolor(WHITE);
	line(0,70,getmaxx(),70);
	line(0,400,getmaxx(),400);

	setcolor(14);
	outtextxy(65,115,"QUEUE OPERATIONS                      QUEUE STATUS");
	outtextxy(140,440,"Press the Key that is Highlighted or use Mouse.");
	setcolor(CYAN);
	line(65,125,190,125);
	line(368,125,464,125);

// CALL THE SHOW FUNCTION TO DRAW THE VARIOUS BUTTONS

	show();

// DRAW THE QUEUE

	drawq();

// DRAW THE POINTERS THAT IS FRONT AND REAR

	moveptrs(&rear,&front);

// SET THE LABEL M THAT WILL BE USED LATER FOR UNCONDITIONAL JUMP

	m:

// GO ON CHECKING WHETHER A KEY IS PRESSED OR NOT

	while (i==0)
	       {
	       if (kbhit())
	       {
	       ch=getche();

	       // CHECK IF THE KEY PRESSED IS E OR e
	       switch(ch)
	       {
	       case 'e':
	       case 'E':

	       {
	       // CALL THE FUNCTION THAT WILL BE FOR EXIT
	       zoomin();
	       }
	       reset:
	       case 'R':
	       case 'r':
	       {
	       // CALL THE RESET QUEUE FUNCTION
	       hidequeueinfo();
	       // CALL THE PROGRESSBAR
	       slidebar(&rear,&front);
	       // AGAIN DRAW THE QUEUE
	       drawq();
	       restrictmouseptr(1,57,maxx-1,maxy-1);
	       goto m;
	       }
	       queueinfo:
	       case 'A' :
	       case 'a':
	       {
	       // CALL THE FUNCTION TO GIVE INFORMATION ABOUT QUEUE
	       hidequeueinfo();
	       showqueuesize();
	       goto m;
	       }
	       delet:
	       case 'D':
	       case 'd':
	       {
	       //  CALL THE DELETE QUEUE OPERATIONS
	       hidequeueinfo();
	       deleteq(&front);
	       // CHECK IF QUEUE IS EMPTY, IF SO PRINT THE MESSAGE
		       if(rear==-1 || front==5 ||rear<front)
			{
			// CLEAR THE INFO, THERE IN INFORMATION PART
			hidequeueinfo();
			// DISPLAY THE TEXT IN THE INFORMATION PART
			outtextxy(200,430,"Queue is empty, you can't delete");
			}
			else
			{
			front=front+1;
			moveptrs(&rear,&front);
			}
		goto m;
	       }
	       ins:
	       case 'I':
	       case 'i':
	       {
	       // HERE IS THE OPERATIONS FOR INSERTING AN ELEMENT
	       hidequeueinfo();
	       if(rear==4)
			{
			hidequeueinfo();
			outtextxy(200,430,"Queue is full, you can't insert");
			goto m;
			}

	       // SHOWS THE NUMBERS AND CANCEL BUTTON
	       shownumbers(20,430,60,470);
	       // CHECK FOR WHAT KEY PRESSED

	       n:

	       while(j==0)
	       {
		 if (kbhit())
		  {
		   ch1=getche();

			       if(front==-1)
			       {
			       front=front+1;
			       }
		   switch(ch1)
		   {
		   cancel:
		   case 'C':
		   case 'c':
		       {
		       hidequeueinfo();
		       restrictmouseptr(1,57,maxx-1,maxy-1);
		       goto m;
		       }
		   zero:
		   case '0':
		       {
			       insertq(&rear,'0');
			       rear=rear+1;
			       moveptrs(&rear,&front);
			       hidequeueinfo();
			       restrictmouseptr(1,57,maxx-1,maxy-1);
			       goto m;
		       }
		   one:
		   case '1':
		       {
			       insertq(&rear,'1');
			       rear=rear+1;
			       moveptrs(&rear,&front);
			       hidequeueinfo();
			       restrictmouseptr(1,57,maxx-1,maxy-1);
			       goto m;
		       }
		   two:
		   case '2':
		       {
			       insertq(&rear,'2');
			       rear=rear+1;
			       moveptrs(&rear,&front);
			       hidequeueinfo();
			       restrictmouseptr(1,57,maxx-1,maxy-1);
			       goto m;
		       }
		   three:
		  case '3':
		       {
			       insertq(&rear,'3');
			       rear=rear+1;
			       moveptrs(&rear,&front);
			       hidequeueinfo();
			       restrictmouseptr(1,57,maxx-1,maxy-1);
			       goto m;
		       }
		  four:
		   case '4':
		       {
			       insertq(&rear,'4');
			       rear=rear+1;
			       moveptrs(&rear,&front);
			       hidequeueinfo();
			       restrictmouseptr(1,57,maxx-1,maxy-1);
			       goto m;
		       }
		   five:
		   case '5':
		       {
			       insertq(&rear,'5');
			       rear=rear+1;
			       moveptrs(&rear,&front);
			       hidequeueinfo();
			       restrictmouseptr(1,57,maxx-1,maxy-1);
			       goto m;
		       }
		   six:
		   case '6':
		       {
			       insertq(&rear,'6');
			       rear=rear+1;
			       moveptrs(&rear,&front);
			       hidequeueinfo();
			       restrictmouseptr(1,57,maxx-1,maxy-1);
			       goto m;
		       }
		   seven:
		   case '7':
		       {
			       insertq(&rear,'7');
			       rear=rear+1;
			       moveptrs(&rear,&front);
			       hidequeueinfo();
			       restrictmouseptr(1,57,maxx-1,maxy-1);
			       goto m;
		       }
		  eight:
		   case '8':
		       {
			       insertq(&rear,'8');
			       rear=rear+1;
			       moveptrs(&rear,&front);
			       hidequeueinfo();
			       restrictmouseptr(1,57,maxx-1,maxy-1);
			       goto m;
		       }
		   nine:
		   case '9':
		       {
			       insertq(&rear,'9');
			       rear=rear+1;
			       moveptrs(&rear,&front);
			       hidequeueinfo();
			       restrictmouseptr(1,57,maxx-1,maxy-1);
			       goto m;
		       }
		   default :
				hidequeueinfo();
				outtextxy(200,430,"Invalid Key Pressed ! Press a valid key");
				delay(550);
				hidequeueinfo();
				shownumbers(20,430,60,470);
				goto n;
		   }
		}
		else
		{
		//write code here to press the 0-----9 and cancel
		       getmousepos(&button,&x,&y);
		       if((button & 1)==1)
		       {
			       if(front==-1)
			       {
			       front=front+1;
			       }
		       }
		       if( (x>500 && x<getmaxx()-10 && y>445 && y<470) && (button & 1)==1)
			{
			goto cancel;
			}
		       if( (x>20 && x<60 && y>430 && y<470) && (button & 1)==1)
			{
			goto zero;
			}
		       if( (x>60 && x<100 && y>430 && y<470) && (button & 1)==1)
			{
			goto one;
			}
		       if( (x>100 && x<140 && y>430 && y<470) && (button & 1)==1)
			{
			goto two;
			}
		       if( (x>140 && x<180 && y>430 && y<470) && (button & 1)==1)
			{
			goto three;
			}
		       if( (x>180 && x<220 && y>430 && y<470) && (button & 1)==1)
			{
			goto four;
			}
		       if( (x>220 && x<260 && y>430 && y<470) && (button & 1)==1)
			{
			goto five;
			}
		       if( (x>260 && x<300 && y>430 && y<470) && (button & 1)==1)
			{
			goto six;
			}
		       if( (x>300 && x<340 && y>430 && y<470) && (button & 1)==1)
			{
			goto seven;
			}
		       if( (x>340 && x<380 && y>430 && y<470) && (button & 1)==1)
			{
			goto eight;
			}
		       if( (x>380 && x<420 && y>430 && y<470) && (button & 1)==1)
			{
			goto nine;
			}
		}
	}
	}
	 default :
			hidequeueinfo();
			outtextxy(220,420,"Please Press a Valid Key");
			goto m;
	 }
	 }
	 // ELSE CONDITION FOR THE IF AFTER THE FIRST WHILE
	 else
	       {

		  getmousepos(&button,&x,&y);
		  if( (x>50 && x<200 && y<370 && y>350) && (button & 1)==1)
			{
			//exit button click
			zoomin();
			}
		  if( (x>50 && x<200 && y>150 && y<170) && (button & 1)==1)
			{
			//clicked the queueinfo button
			goto queueinfo;
			}
		  if( (x>50 && x<200 && y>200 && y<220) && (button & 1)==1)
			{
			//clicked the insert button
			goto ins;
			}

		  if( (x>50 && x<200 && y>250 && y<270) && (button & 1)==1)
			{
			//clicked the delete button
			delay(500);
			goto delet;
			}
		  if( (x>50 && x<200 && y>300 && y<320) && (button & 1)==1)
			{
			//clicked the reset button
			goto reset;
			}

		}


	}

getche();
}
예제 #12
0
int worldfactory::show_worldgen_tab_modselection(WINDOW *win, WORLDPTR world)
{
    // Use active_mod_order of the world,
    // saves us from writing 'world->active_mod_order' all the time.
    std::vector<std::string> &active_mod_order = world->active_mod_order;
    {
        std::vector<std::string> tmp_mod_order;
        // clear active_mod_order and re-add all the mods, his ensures
        // that changes (like changing dependencies) get updated
        tmp_mod_order.swap(active_mod_order);
        for( auto &elem : tmp_mod_order ) {
            mman_ui->try_add( elem, active_mod_order );
        }
    }

    input_context ctxt("MODMANAGER_DIALOG");
    ctxt.register_updown();
    ctxt.register_action("LEFT", _("Switch to other list"));
    ctxt.register_action("RIGHT", _("Switch to other list"));
    ctxt.register_action("HELP_KEYBINDINGS");
    ctxt.register_action("QUIT");
    ctxt.register_action("NEXT_TAB");
    ctxt.register_action("PREV_TAB");
    ctxt.register_action("CONFIRM", _("Activate / deactive mod"));
    ctxt.register_action("ADD_MOD");
    ctxt.register_action("REMOVE_MOD");
    ctxt.register_action("SAVE_DEFAULT_MODS");

    const int iOffsetX = (TERMX > FULL_SCREEN_WIDTH) ? (TERMX - FULL_SCREEN_WIDTH) / 2 : 0;
    const int iOffsetY = (TERMY > FULL_SCREEN_HEIGHT) ? (TERMY - FULL_SCREEN_HEIGHT) / 2 : 0;

    // lots of small windows so that each section can be drawn to independently of the others as necessary
    WINDOW *w_header1, *w_header2, *w_shift, *w_list, *w_active, *w_description;
    w_header1 = newwin(1, FULL_SCREEN_WIDTH / 2 - 5, 3 + iOffsetY, 1 + iOffsetX);
    w_header2 = newwin(1, FULL_SCREEN_WIDTH / 2 - 4, 3 + iOffsetY,
                       FULL_SCREEN_WIDTH / 2 + 3 + iOffsetX);
    w_shift   = newwin(13, 5, 3 + iOffsetY, FULL_SCREEN_WIDTH / 2 - 3 + iOffsetX);
    w_list    = newwin(11, FULL_SCREEN_WIDTH / 2 - 4, 5 + iOffsetY, iOffsetX);
    w_active  = newwin(11, FULL_SCREEN_WIDTH / 2 - 4, 5 + iOffsetY,
                       FULL_SCREEN_WIDTH / 2 + 2 + iOffsetX);
    w_description = newwin(4, FULL_SCREEN_WIDTH - 2, 19 + iOffsetY, 1 + iOffsetX);

    draw_modselection_borders(win, &ctxt);
    std::vector<std::string> headers;
    headers.push_back(_("Mod List"));
    headers.push_back(_("Mod Load Order"));
    std::vector<WINDOW *> header_windows;
    header_windows.push_back(w_header1);
    header_windows.push_back(w_header2);

    int tab_output = 0;
    int last_active_header = 0;
    size_t active_header = 0;
    size_t useable_mod_count = mman_ui->usable_mods.size();
    int startsel[2] = {0, 0};
    int cursel[2] = {0, 0};

    bool redraw_headers = true;
    bool redraw_shift = true;
    bool redraw_description = true;
    bool redraw_list = true;
    bool redraw_active = true;
    bool selection_changed = false;

    while (tab_output == 0) {
        if (redraw_headers) {
            for (size_t i = 0; i < headers.size(); ++i) {
                werase(header_windows[i]);
                const int header_x = (getmaxx(header_windows[i]) - headers[i].size()) / 2;
                mvwprintz(header_windows[i], 0, header_x , c_cyan, "%s", headers[i].c_str());

                if (active_header == i) {
                    mvwputch(header_windows[i], 0, header_x - 3, c_red, '<');
                    mvwputch(header_windows[i], 0, header_x + headers[i].size() + 2, c_red, '>');
                }
                wrefresh(header_windows[i]);
            }
            redraw_list = true;
            redraw_active = true;
            redraw_shift = true;
            redraw_headers = false;
        }
        if (selection_changed) {
            if (active_header == 0) {
                redraw_list = true;
            }
            if (active_header == 1) {
                redraw_shift = true;
                redraw_active = true;
            }
            selection_changed = false;
            redraw_description = true;
        }
        if (redraw_description) {
            werase(w_description);

            MOD_INFORMATION *selmod = NULL;
            if (mman_ui->usable_mods.empty()) {
                // Do nothing, leave selmod == NULL
            } else if (active_header == 0) {
                selmod = mman->mod_map[mman_ui->usable_mods[cursel[0]]];
            } else if (!active_mod_order.empty()) {
                selmod = mman->mod_map[active_mod_order[cursel[1]]];
            }

            if (selmod != NULL) {
                fold_and_print(w_description, 0, 1, getmaxx(w_description) - 1,
                               c_white, mman_ui->get_information(selmod));
            }
            redraw_description = false;
            wrefresh(w_description);
        }
        if (redraw_list) {
            draw_mod_list( w_list, startsel[0], cursel[0], mman_ui->usable_mods, active_header == 0, _("--NO AVAILABLE MODS--") );
        }
        if (redraw_active) {
            draw_mod_list( w_active, startsel[1], cursel[1], active_mod_order, active_header == 1, _("--NO ACTIVE MODS--") );
        }
        if (redraw_shift) {
            werase(w_shift);
            if (active_header == 1) {
                std::stringstream shift_display;
                // get shift information for whatever is visible in the active list
                for (size_t i = startsel[1], c = 0; i < active_mod_order.size() &&
                     (int)c < getmaxy(w_active); ++i, ++c) {
                    if (mman_ui->can_shift_up(i, active_mod_order)) {
                        shift_display << "<color_blue>+</color> ";
                    } else {
                        shift_display << "<color_dkgray>+</color> ";
                    }
                    if (mman_ui->can_shift_down(i, active_mod_order)) {
                        shift_display << "<color_blue>-</color>";
                    } else {
                        shift_display << "<color_dkgray>-</color>";
                    }
                    shift_display << "\n";
                }
                fold_and_print(w_shift, 2, 1, getmaxx(w_shift), c_white, shift_display.str());
            }
            redraw_shift = false;
            wrefresh(w_shift);
        }
        refresh();

        last_active_header = active_header;
        const int next_header = (active_header == 1) ? 0 : 1;
        const int prev_header = (active_header == 0) ? 1 : 0;

        int selection = (active_header == 0) ? cursel[0] : cursel[1];
        int last_selection = selection;
        unsigned int next_selection = selection + 1;
        int prev_selection = selection - 1;
        if (active_header == 0) {
            next_selection = (next_selection >= useable_mod_count) ? 0 : next_selection;
            prev_selection = (prev_selection < 0) ? useable_mod_count - 1 : prev_selection;
        } else {
            next_selection = (next_selection >= active_mod_order.size()) ? 0 : next_selection;
            prev_selection = (prev_selection < 0) ? active_mod_order.size() - 1 : prev_selection;
        }

        const std::string action = ctxt.handle_input();

        if (action == "DOWN") {
            selection = next_selection;
        } else if (action == "UP") {
            selection = prev_selection;
        } else if (action == "RIGHT") {
            active_header = next_header;
        } else if (action == "LEFT") {
            active_header = prev_header;
        } else if (action == "CONFIRM") {
            if (active_header == 0 && !mman_ui->usable_mods.empty()) {
#ifndef LUA
                if (mman->mod_map[mman_ui->usable_mods[cursel[0]]]->need_lua) {
                    popup(_("Can't add mod. This mod requires Lua support."));
                    redraw_active = true;
                    redraw_shift = true;
                    draw_modselection_borders(win, &ctxt);
                    continue;
                }
#endif
                // try-add
                mman_ui->try_add(mman_ui->usable_mods[cursel[0]], active_mod_order);
                redraw_active = true;
                redraw_shift = true;
            } else if (active_header == 1 && !active_mod_order.empty()) {
                // try-rem
                mman_ui->try_rem(cursel[1], active_mod_order);
                redraw_active = true;
                redraw_shift = true;
                if (active_mod_order.empty()) {
                    // switch back to other list, we can't change
                    // anything in the empty active mods list.
                    active_header = 0;
                }
            }
        } else if (action == "ADD_MOD") {
            if (active_header == 1 && active_mod_order.size() > 1) {
                mman_ui->try_shift('+', cursel[1], active_mod_order);
                redraw_active = true;
                redraw_shift = true;
            }
        } else if (action == "REMOVE_MOD") {
            if (active_header == 1 && active_mod_order.size() > 1) {
                mman_ui->try_shift('-', cursel[1], active_mod_order);
                redraw_active = true;
                redraw_shift = true;
            }
        } else if (action == "NEXT_TAB") {
            tab_output = 1;
        } else if (action == "PREV_TAB") {
            tab_output = -1;
        } else if (action == "SAVE_DEFAULT_MODS") {
            if(mman->set_default_mods(active_mod_order)) {
                popup(_("Saved list of active mods as default"));
                draw_modselection_borders(win, &ctxt);
                redraw_headers = true;
            }
        } else if (action == "HELP_KEYBINDINGS") {
            // Redraw all the things!
            redraw_headers = true;
            redraw_shift = true;
            redraw_description = true;
            redraw_list = true;
            redraw_active = true;
            draw_worldgen_tabs( win, 0 );
            draw_modselection_borders( win, &ctxt );
        } else if (action == "QUIT") {
            tab_output = -999;
        }
        // RESOLVE INPUTS
        if (last_active_header != (int)active_header) {
            redraw_headers = true;
            redraw_shift = true;
            redraw_description = true;
        }
        if (last_selection != selection) {
            if (active_header == 0) {
                redraw_list = true;
                cursel[0] = selection;
            } else {
                redraw_active = true;
                redraw_shift = true;
                cursel[1] = selection;
            }
            redraw_description = true;
        }
        if (active_mod_order.empty()) {
            redraw_active = true;
            cursel[1] = 0;
        }

        if (active_header == 1) {
            if (active_mod_order.empty()) {
                cursel[1] = 0;
            } else {
                if (cursel[1] < 0) {
                    cursel[1] = 0;
                } else if (cursel[1] >= (int)active_mod_order.size()) {
                    cursel[1] = active_mod_order.size() - 1;
                }
            }
        }
        // end RESOLVE INPUTS
    }
    werase(w_header1);
    werase(w_header2);
    werase(w_shift);
    werase(w_list);
    werase(w_active);
    werase(w_description);

    delwin(w_header1);
    delwin(w_header2);
    delwin(w_shift);
    delwin(w_list);
    delwin(w_active);
    delwin(w_description);
    return tab_output;
}
예제 #13
0
void WriteWords(struct words_info *words)
{
  unsigned char refresh, confirm, menu = 0, gotonext;
  unsigned char *input = NULL;
  unsigned int pos = 0, i, j, wrong;
  int key;
  struct words_p *p = words->p;
  if (words->order < 5)
    words->p = words->f;
  else
    words->order -= 10;
  do {
    p->tmp = 0; p = p->next;
  } while (p != words->p);
_restart:
  pos = 0; confirm = 0;
  free(input);
  input = calloc(sizeof(char), strlen(words->p->word) + 1);
  memset(input, ' ', strlen(words->p->word));
  curs_set(1);
_refresh:
  refresh = 1;
  clear();
  border('|', '|', '-', '-', '+', '+', '+', '+');
  _mvchgrectat(1, 1, getmaxy(stdscr) - 2, getmaxx(stdscr) - 2, 0, clr_wbkg, NULL);
  attron(COLOR_PAIR(clr_wttl)/* | A_BOLD*/);
  mvaddstr(1, (getmaxx(stdscr) - 16) / 2, "Words - 记默模式");
  attroff(COLOR_PAIR(clr_wttl)/* | A_BOLD*/);
  j = (getmaxy(stdscr) - 5) / 3;
  attron(COLOR_PAIR(clr_wmn));
  mvaddstr(2 + j, 4, words->p->mean);
  attroff(COLOR_PAIR(clr_wmn));
  move(getmaxy(stdscr) - j - 2, 4);
_input:
  move(getcury(stdscr), 4);
  for (i = 0, wrong = 0; i < strlen(words->p->word); i++)
    if (*(input + i) != *(words->p->word + i))
      wrong++, addch(*(input + i) | COLOR_PAIR(clr_winw) | A_BOLD);
    else
      addch(*(input + i) | COLOR_PAIR(clr_winr) | A_BOLD);
  if (!wrong)
    if (!refresh) goto _refresh; else goto _next;
  else if (confirm) goto _next;
  if (menu) {
    i = (getmaxx(stdscr) - 32) / 4;
    attron(COLOR_PAIR(menu == 1 ? clr_wmcu : clr_wmop) | A_BOLD);
    mvaddstr(2 + (getmaxy(stdscr) - 3) / 2, 1 + (getmaxx(stdscr) - 2 * i - 32) / 2, "[上一单词]");
    attroff(COLOR_PAIR(menu == 1 ? clr_wmcu : clr_wmop));
    attron(COLOR_PAIR(menu == 2 ? clr_wmcu : clr_wmop));
    mvaddstr(getcury(stdscr), getcurx(stdscr) + i, "[提示字母]");
    attroff(COLOR_PAIR(menu == 2 ? clr_wmcu : clr_wmop));
    attron(COLOR_PAIR(menu == 3 ? clr_wmcu : clr_wmop));
    mvaddstr(getcury(stdscr), getcurx(stdscr) + i, "[下一单词]");
    attroff(COLOR_PAIR(menu == 3 ? clr_wmcu : clr_wmop) | A_BOLD);
  }
  move(getmaxy(stdscr) - j - 2, 4 + pos);
  refresh();
  refresh = 0;
_getch:
  key = getch();
  if (menu)
    switch (key) {
    case KEY_LEFT:
      menu -= menu != 1;
      goto _refresh;
    case KEY_RIGHT:
      menu += menu != 3;
      goto _refresh;
    case KEY_DOWN:
    case 033:
      menu = 0;
    case KEY_RESIZE:
      goto _refresh;
    case '\n':
      switch (menu) {
      case 1:
        menu = 0; gotonext = 0;
        goto _goto;
      case 2:
        *(input + pos) = *(words->p->word + pos);
        pos += pos + 1 != strlen(words->p->word);
        goto _input;
      case 3:
        menu = 0; gotonext = 1;
        goto _goto;
      }
    default:
      goto _getch;
    }
  switch (key) {
  case KEY_RIGHT:
    pos += pos + 1 != strlen(words->p->word);
    goto _input;
  case KEY_UP:
    menu = 2;
    goto _refresh;
  case KEY_DOWN:
    goto _restart;
  case 033:
    curs_set(0);
    return;
  case '\t':
    *(input + pos) = *(words->p->word + pos);
    pos += pos + 1 != strlen(words->p->word);
    goto _input;
  case '\n':
    confirm = 1;
  case KEY_RESIZE:
    goto _refresh;
  case KEY_DC:
  case KEY_BACKSPACE:
  case 127:
    //*(input + pos/* - 1*/) = ' ';
  case KEY_LEFT:
    pos -= pos != 0;
    goto _input;
  default:
    if (key < 0 || key > 127) goto _getch;
    *(input + pos) = (char)key;
    if (pos + 1 < strlen(words->p->word))
      pos++;
    goto _input;
  };
_next:
  menu = 0;
  curs_set(0);
  attron(COLOR_PAIR(clr_wmsg) | A_BOLD);
  if (!wrong)
    mvaddstr(getmaxy(stdscr) - 2, (getmaxx(stdscr) - 29) / 2, "正确! 按任意键继续下一单词...");
  else
    mvaddstr(getmaxy(stdscr) - 2, (getmaxx(stdscr) - 35) / 2, "错误! [输入]下一单词/[返回]继续输入");
  attroff(COLOR_PAIR(clr_wmsg) | A_BOLD);
  refresh();
_getkey:
  switch (getch()) {
  case 033:
    if (wrong) {
      confirm = 0;
      curs_set(1);
      goto _refresh;
    } else break;
  case KEY_RESIZE:
    goto _refresh;
  case -1:
    goto _getkey;
  case '\n':
    if (wrong) break;
  default:
    if (wrong) goto _getkey;
  }
  if (words->order == 1)
    words->p = words->p->next;
  else if (words->order == -1)
    words->p = words->p->prev;
  if (words->p != words->f)
    goto _restart;
  free(input);
  return;
_goto:
  if (words->order == 1)
    words->p = (gotonext ? words->p->next : words->p->prev);
  else if (words->order == -1)
    words->p = (gotonext ? words->p->prev : words->p->next);
  if (gotonext) {
    if (words->p == words->f)
      words->p = words->f->prev;
  } else {
    if (words->p == words->f->prev)
      words->p = words->f;
  }
  goto _restart;
}
예제 #14
0
/*
 * Display a menu for choosing among a number of options
 */
int dialog_menu(const char *title, const char *prompt,
                const void *selected, int *s_scroll)
{
	int i, j, x, y, box_x, box_y;
	int height, width, menu_height;
	int key = 0, button = 0, scroll = 0, choice = 0;
	int first_item =  0, max_choice;
	WINDOW *dialog, *menu;

do_resize:
	height = getmaxy(stdscr);
	width = getmaxx(stdscr);
	if (height < 15 || width < 65)
		return -ERRDISPLAYTOOSMALL;

	height -= 4;
	width  -= 5;
	menu_height = height - 10;

	max_choice = MIN(menu_height, item_count());

	/* center dialog box on screen */
	x = (COLS - width) / 2;
	y = (LINES - height) / 2;

	draw_shadow(stdscr, y, x, height, width);

	dialog = newwin(height, width, y, x);
	keypad(dialog, TRUE);

	draw_box(dialog, 0, 0, height, width,
		 dlg.dialog.atr, dlg.border.atr);
	wattrset(dialog, dlg.border.atr);
	mvwaddch(dialog, height - 3, 0, ACS_LTEE);
	for (i = 0; i < width - 2; i++)
		waddch(dialog, ACS_HLINE);
	wattrset(dialog, dlg.dialog.atr);
	wbkgdset(dialog, dlg.dialog.atr & A_COLOR);
	waddch(dialog, ACS_RTEE);

	print_title(dialog, title, width);

	wattrset(dialog, dlg.dialog.atr);
	print_autowrap(dialog, prompt, width - 2, 1, 3);

	menu_width = width - 6;
	box_y = height - menu_height - 5;
	box_x = (width - menu_width) / 2 - 1;

	/* create new window for the menu */
	menu = subwin(dialog, menu_height, menu_width,
		      y + box_y + 1, x + box_x + 1);
	keypad(menu, TRUE);

	/* draw a box around the menu items */
	draw_box(dialog, box_y, box_x, menu_height + 2, menu_width + 2,
		 dlg.menubox_border.atr, dlg.menubox.atr);

	if (menu_width >= 80)
		item_x = (menu_width - 70) / 2;
	else
		item_x = 4;

	/* Set choice to default item */
	item_foreach()
		if (selected && (selected == item_data()))
			choice = item_n();
	/* get the saved scroll info */
	scroll = *s_scroll;
	if ((scroll <= choice) && (scroll + max_choice > choice) &&
	   (scroll >= 0) && (scroll + max_choice <= item_count())) {
		first_item = scroll;
		choice = choice - scroll;
	} else {
		scroll = 0;
	}
	if ((choice >= max_choice)) {
		if (choice >= item_count() - max_choice / 2)
			scroll = first_item = item_count() - max_choice;
		else
			scroll = first_item = choice - max_choice / 2;
		choice = choice - scroll;
	}

	/* Print the menu */
	for (i = 0; i < max_choice; i++) {
		print_item(first_item + i, i, i == choice);
	}

	wnoutrefresh(menu);

	print_arrows(dialog, item_count(), scroll,
		     box_y, box_x + item_x + 1, menu_height);

	print_buttons(dialog, height, width, 0);
	wmove(menu, choice, item_x + 1);
	wrefresh(menu);

	while (key != KEY_ESC) {
		key = wgetch(menu);

		if (key < 256 && isalpha(key))
			key = tolower(key);

		if (strchr("ynmh", key))
			i = max_choice;
		else {
			for (i = choice + 1; i < max_choice; i++) {
				item_set(scroll + i);
				j = first_alpha(item_str(), "YyNnMmHh");
				if (key == tolower(item_str()[j]))
					break;
			}
			if (i == max_choice)
				for (i = 0; i < max_choice; i++) {
					item_set(scroll + i);
					j = first_alpha(item_str(), "YyNnMmHh");
					if (key == tolower(item_str()[j]))
						break;
				}
		}

		if (i < max_choice ||
		    key == KEY_UP || key == KEY_DOWN ||
		    key == '-' || key == '+' ||
		    key == KEY_PPAGE || key == KEY_NPAGE) {
			/* Remove highligt of current item */
			print_item(scroll + choice, choice, FALSE);

			if (key == KEY_UP || key == '-') {
				if (choice < 2 && scroll) {
					/* Scroll menu down */
					do_scroll(menu, &scroll, -1);

					print_item(scroll, 0, FALSE);
				} else
					choice = MAX(choice - 1, 0);

			} else if (key == KEY_DOWN || key == '+') {
				print_item(scroll+choice, choice, FALSE);

				if ((choice > max_choice - 3) &&
				    (scroll + max_choice < item_count())) {
					/* Scroll menu up */
					do_scroll(menu, &scroll, 1);

					print_item(scroll+max_choice - 1,
						   max_choice - 1, FALSE);
				} else
					choice = MIN(choice + 1, max_choice - 1);

			} else if (key == KEY_PPAGE) {
				scrollok(menu, TRUE);
				for (i = 0; (i < max_choice); i++) {
					if (scroll > 0) {
						do_scroll(menu, &scroll, -1);
						print_item(scroll, 0, FALSE);
					} else {
						if (choice > 0)
							choice--;
					}
				}

			} else if (key == KEY_NPAGE) {
				for (i = 0; (i < max_choice); i++) {
					if (scroll + max_choice < item_count()) {
						do_scroll(menu, &scroll, 1);
						print_item(scroll+max_choice-1,
							   max_choice - 1, FALSE);
					} else {
						if (choice + 1 < max_choice)
							choice++;
					}
				}
			} else
				choice = i;

			print_item(scroll + choice, choice, TRUE);

			print_arrows(dialog, item_count(), scroll,
				     box_y, box_x + item_x + 1, menu_height);

			wnoutrefresh(dialog);
			wrefresh(menu);

			continue;	/* wait for another key press */
		}

		switch (key) {
		case KEY_LEFT:
		case TAB:
		case KEY_RIGHT:
			button = ((key == KEY_LEFT ? --button : ++button) < 0)
			    ? 2 : (button > 2 ? 0 : button);

			print_buttons(dialog, height, width, button);
			wrefresh(menu);
			break;
		case ' ':
		case 's':
		case 'y':
		case 'n':
		case 'm':
		case '/':
			/* save scroll info */
			*s_scroll = scroll;
			delwin(menu);
			delwin(dialog);
			item_set(scroll + choice);
			item_set_selected(1);
			switch (key) {
			case 's':
				return 3;
			case 'y':
				return 3;
			case 'n':
				return 4;
			case 'm':
				return 5;
			case ' ':
				return 6;
			case '/':
				return 7;
			}
			return 0;
		case 'h':
		case '?':
			button = 2;
		case '\n':
			*s_scroll = scroll;
			delwin(menu);
			delwin(dialog);
			item_set(scroll + choice);
			item_set_selected(1);
			return button;
		case 'e':
		case 'x':
			key = KEY_ESC;
			break;
		case KEY_ESC:
			key = on_key_esc(menu);
			break;
#ifdef NCURSES_VERSION
		case KEY_RESIZE:
			on_key_resize();
			delwin(menu);
			delwin(dialog);
			goto do_resize;
#endif
		}
	}
	delwin(menu);
	delwin(dialog);
	return key;		/* ESC pressed */
}
예제 #15
0
/*
 * Initializeaza toate spatiile de editare.
 */
void initialize_variable_spaces()
{
    set(1);
    setcolor(RED);
    outtextxy(0, 0, "Transl. cu:");
    idx = 1;
    outtextxy(10, 15, "x = ");
    variable_space(1);
    print_numbers();
    idx = 2;
    setcolor(RED);
    outtextxy(10, 30, "y = ");
    variable_space(1);
    print_numbers();

    set(2);
    setcolor(RED);
    outtextxy(0, 0, "Scalare cu:");
    idx = 3;
    outtextxy(10, 15, "x = ");
    variable_space(1);
    print_numbers();
    idx = 4;
    setcolor(RED);
    outtextxy(10, 30, "y = ");
    variable_space(1);
    print_numbers();

    set(3);
    setcolor(RED);
    outtextxy(0, 0, "Rotire cu:");
    idx = 5;
    outtextxy(10, 15, "р = ");
    variable_space(1);
    print_numbers();

    set(4);
    setcolor(RED);
    outtextxy(0, 0, "Coord. dr. aleatoare:");
    idx = 6;
    outtextxy(10, 15, "x = ");
    variable_space(1);
    print_numbers();
    idx = 7;
    setcolor(RED);
    outtextxy(10, 30, "y = ");
    variable_space(1);
    print_numbers();
    idx = 8;
    setcolor(RED);
    outtextxy(90, 15, "р = ");
    variable_space(1);
    print_numbers();

    idx = 1;
    variable_space(1);

    set(5);
    setcolor(RED);
    outtextxy(1, 5, "Comenzi:");
    outtextxy(1, 15, "+, -, t, s, r, c");
    outtextxy(1, 25, "x, y, o, d");
    outtextxy(1, 37, "ESC, sageti, TAB");

    setviewport(0, 0, getmaxx(), getmaxy(), 1);
    setcolor(RED);
    line(5, 3, 5, 47);
    line(105, 3, 105, 47);
    line(205, 3, 205, 47);
    line(305, 3, 305, 47);
    line(485, 3, 485, 47);
    line(635, 3, 635, 47);
    line(5, 2, 635, 2);
    line(5, 48, 635, 48);
}
예제 #16
0
파일: main.c 프로젝트: jenya-meow/Viselica
void game()
{
    unsigned int choice = 0;
    int hires = 0, y = 0, i, life = 13, flg = 0, donth = 0;
    char guess;
    char cens[20] = { '\0' };
    char alph[25] = { '\0' };
    clear();
    keypad(stdscr, true);
    curs_set(0);
    while (!flg) {
        unsigned i;
        clear();
        printw("Выберите тему:\n");
        for (i = 0; i < 5; i++) {
            if (i == choice)
                addch('>');
            else
                addch(' ');
            printw("%s\n", themes[i]);
        }
        attron(A_REVERSE);
        mvwprintw(stdscr, getmaxy(stdscr) - 1, 0,
                  "Нажмите ENTER для подтверждения, стрелки вверх/вниз для выбора");
        attroff(A_REVERSE);
        switch (getch()) {
            case KEY_UP:
                if (choice)
                    choice--;
                break;
            case KEY_DOWN:
                if (choice != 4)
                    choice++;
                break;
            case '\n':
                flg++;
                break;
        }
    }
    random_word(word, choice);
    while (strcmp(cens, word) && life > 0 && guess != 27) {
        if (getmaxx(stdscr) >= 130 && getmaxy(stdscr) >= 40) {
            hires = 1;
            y = LINES / 2 - 3;
        } else {
            hires = 0;
            y = 0;
        }
        clear();
        life = asteriks(word, cens, guess, life, donth);        //обработчик от Мариши
        mvprintw(y, 0, "Выбранная тема: %s\n", themes[choice]);
        mvprintw(y + 1, 0, "Ваше слово сейчас: %s\n", cens);
        jizi(life, hires);      //жизни от Дани
        attron(A_REVERSE);
        mvwprintw(stdscr, getmaxy(stdscr) - 1, 0,
                  "Нажмите ENTER для подтверждения, ESC для выхода");
        attroff(A_REVERSE);
        if (hires)
            risunok_hd(life + 1);   //рисунок от Дани
        else
            risunok(life + 1);      //рисунок от Дани
        guess = input(hires);   //ввод от Ксюни
        donth = check(guess, alph);
    }
    clear();
    printw("Загаданное слово было: %s\n", word);
    printw("Осталось жизней: %d\n", life);
    if ((life > 0) && (guess != 27)) 
        win();
    else
        lose();
    attron(A_REVERSE);
    mvwprintw(stdscr, getmaxy(stdscr) - 1, 0,
              "Нажмите любую клавишу для продолжения");
    attroff(A_REVERSE);
    cbreak();
    getch();
    clear();
    return;
}
예제 #17
0
int dialog_checklist(const char *title, const char *prompt, int height,
		     int width, int list_height)
{
	int i, x, y, box_x, box_y;
	int key = 0, button = 0, choice = 0, scroll = 0, max_choice;
	WINDOW *dialog, *list;

	/*                         */
	item_foreach() {
		if (item_is_tag('X'))
			choice = item_n();
		if (item_is_selected()) {
			choice = item_n();
			break;
		}
	}

do_resize:
	if (getmaxy(stdscr) < (height + 6))
		return -ERRDISPLAYTOOSMALL;
	if (getmaxx(stdscr) < (width + 6))
		return -ERRDISPLAYTOOSMALL;

	max_choice = MIN(list_height, item_count());

	/*                             */
	x = (COLS - width) / 2;
	y = (LINES - height) / 2;

	draw_shadow(stdscr, y, x, height, width);

	dialog = newwin(height, width, y, x);
	keypad(dialog, TRUE);

	draw_box(dialog, 0, 0, height, width,
		 dlg.dialog.atr, dlg.border.atr);
	wattrset(dialog, dlg.border.atr);
	mvwaddch(dialog, height - 3, 0, ACS_LTEE);
	for (i = 0; i < width - 2; i++)
		waddch(dialog, ACS_HLINE);
	wattrset(dialog, dlg.dialog.atr);
	waddch(dialog, ACS_RTEE);

	print_title(dialog, title, width);

	wattrset(dialog, dlg.dialog.atr);
	print_autowrap(dialog, prompt, width - 2, 1, 3);

	list_width = width - 6;
	box_y = height - list_height - 5;
	box_x = (width - list_width) / 2 - 1;

	/*                                */
	list = subwin(dialog, list_height, list_width, y + box_y + 1,
	              x + box_x + 1);

	keypad(list, TRUE);

	/*                                  */
	draw_box(dialog, box_y, box_x, list_height + 2, list_width + 2,
	         dlg.menubox_border.atr, dlg.menubox.atr);

	/*                                                          */
	check_x = 0;
	item_foreach()
		check_x = MAX(check_x, strlen(item_str()) + 4);
	check_x = MIN(check_x, list_width);

	check_x = (list_width - check_x) / 2;
	item_x = check_x + 4;

	if (choice >= list_height) {
		scroll = choice - list_height + 1;
		choice -= scroll;
	}

	/*                */
	for (i = 0; i < max_choice; i++) {
		item_set(scroll + i);
		print_item(list, i, i == choice);
	}

	print_arrows(dialog, choice, item_count(), scroll,
		     box_y, box_x + check_x + 5, list_height);

	print_buttons(dialog, height, width, 0);

	wnoutrefresh(dialog);
	wnoutrefresh(list);
	doupdate();

	while (key != KEY_ESC) {
		key = wgetch(dialog);

		for (i = 0; i < max_choice; i++) {
			item_set(i + scroll);
			if (toupper(key) == toupper(item_str()[0]))
				break;
		}

		if (i < max_choice || key == KEY_UP || key == KEY_DOWN ||
		    key == '+' || key == '-') {
			if (key == KEY_UP || key == '-') {
				if (!choice) {
					if (!scroll)
						continue;
					/*                  */
					if (list_height > 1) {
						/*                                 */
						item_set(scroll);
						print_item(list, 0, FALSE);
						scrollok(list, TRUE);
						wscrl(list, -1);
						scrollok(list, FALSE);
					}
					scroll--;
					item_set(scroll);
					print_item(list, 0, TRUE);
					print_arrows(dialog, choice, item_count(),
						     scroll, box_y, box_x + check_x + 5, list_height);

					wnoutrefresh(dialog);
					wrefresh(list);

					continue;	/*                            */
				} else
					i = choice - 1;
			} else if (key == KEY_DOWN || key == '+') {
				if (choice == max_choice - 1) {
					if (scroll + choice >= item_count() - 1)
						continue;
					/*                */
					if (list_height > 1) {
						/*                                                    */
						item_set(scroll + max_choice - 1);
						print_item(list,
							    max_choice - 1,
							    FALSE);
						scrollok(list, TRUE);
						wscrl(list, 1);
						scrollok(list, FALSE);
					}
					scroll++;
					item_set(scroll + max_choice - 1);
					print_item(list, max_choice - 1, TRUE);

					print_arrows(dialog, choice, item_count(),
						     scroll, box_y, box_x + check_x + 5, list_height);

					wnoutrefresh(dialog);
					wrefresh(list);

					continue;	/*                            */
				} else
					i = choice + 1;
			}
			if (i != choice) {
				/*                           */
				item_set(scroll + choice);
				print_item(list, choice, FALSE);
				/*                    */
				choice = i;
				item_set(scroll + choice);
				print_item(list, choice, TRUE);
				wnoutrefresh(dialog);
				wrefresh(list);
			}
			continue;	/*                            */
		}
		switch (key) {
		case 'H':
		case 'h':
		case '?':
			button = 1;
			/*              */
		case 'S':
		case 's':
		case ' ':
		case '\n':
			item_foreach()
				item_set_selected(0);
			item_set(scroll + choice);
			item_set_selected(1);
			delwin(list);
			delwin(dialog);
			return button;
		case TAB:
		case KEY_LEFT:
		case KEY_RIGHT:
			button = ((key == KEY_LEFT ? --button : ++button) < 0)
			    ? 1 : (button > 1 ? 0 : button);

			print_buttons(dialog, height, width, button);
			wrefresh(dialog);
			break;
		case 'X':
		case 'x':
			key = KEY_ESC;
			break;
		case KEY_ESC:
			key = on_key_esc(dialog);
			break;
		case KEY_RESIZE:
			delwin(list);
			delwin(dialog);
			on_key_resize();
			goto do_resize;
		}

		/*                           */
		doupdate();
	}
	delwin(list);
	delwin(dialog);
	return key;		/*             */
}
예제 #18
0
파일: FED.C 프로젝트: MegaGod/TW
void edit( int ch ) {
	struct viewporttype tmp;
	char key, *buff;

	take_char( ( char ) ch );
	backup_char( );
	getviewsettings( &tmp );
	setviewport( 400, 30, getmaxx( ), getmaxy( ), 1 );
	buff = ( char* ) malloc( imagesize( 0 + align, 0, X*( 2 + WIDTH_X ) + align, Y*( 2 + WIDTH_Y ) ) );
	getimage( 0 + align, 0, X*( 2 + WIDTH_X ) + align, Y*( 2 + WIDTH_Y ), buff );
	draw_char( );
	start_clock( EDIT_FONT );

	while ( ( key = get_pos( &pos_x, &pos_y, X - 1, Y - 1, 1, 1 ) ) != 3 ) {
		switch ( tolower( key ) ) {
		case 1:
			xor_dot( pos_x, pos_y );
			continue;

		case '8':
			pan_up( );
			draw_char( );
			break;

		case '2':
			pan_down( );
			draw_char( );
			break;

		case '4':
			pan_left( );
			draw_char( );
			break;

		case '6':
			pan_right( );
			draw_char( );
			break;

		case 'r':
			insert_row( pos_y );
			draw_char( );
			break;

		case 'c':
			insert_col( pos_x );
			draw_char( );
			break;

		case 'e':
			del_row( pos_y );
			draw_char( );
			break;

		case 'd':
			del_col( pos_x );
			draw_char( );
			break;

		case 'i':
			invert( );
			draw_char( );
			break;

		case 'm':
			mirror( );
			draw_char( );
			break;

		case '.':
			++draw_mode;
			switch ( draw_mode ) {
			case 0:
				break;
			case 1:
				put_dot( pos_x, pos_y );
				edit_font[pos_x][pos_y] = ~0;
				break;
			case 2:
				square( pos_x, pos_y );
				edit_font[pos_x][pos_y] = 0;
				break;
			case 3:
				draw_mode = 0;
			}
			continue;

		case 'u':
			undo( );
			draw_char( );
			goto exit;

		case '?':
			help( );
			break;

		default:
			if ( draw_mode == 1 ) {
				put_dot( pos_x, pos_y );
				edit_font[pos_x][pos_y] = ~0;
			}
			if ( draw_mode == 2 ) {
				square( pos_x, pos_y );
				edit_font[pos_x][pos_y] = 0;
			}

		}
	}
	update_char( ( char ) ch );
exit:
	putimage( 0 + align, 0, buff, COPY_PUT );
	free( buff );
	stop_clock( );
	dispblank( 50, 16, strlen( "Move mode" ), 0 );
	setviewport( tmp.left, tmp.top, tmp.right, tmp.bottom, tmp.clip );
	print_table( which_page( ch ) );
}
예제 #19
0
/*
 * Modifica valoarea valorilor in urma comenzii date de utilizator.
 */
void modify_variable(int way)
{
    switch (idx)
    {
    case 1:
        if ((transX < 200) && (way == 1))
            transX++;
        if ((transX > -200) && (way == 0))
            transX--;
        break;
    case 2:
        if ((transY < 200) && (way == 1))
            transY++;
        if ((transY > -200) && (way == 0))
            transY--;
        break;
    case 3:
        if ((scaleX < 4.96) && (way == 1))
            scaleX += 0.05;
        if ((scaleX > 0.05) && (way == 0))
            scaleX -= 0.05;
        break;
    case 4:
        if ((scaleY < 4.96) && (way == 1))
            scaleY += 0.05;
        if ((scaleY > 0.05) && (way == 0))
            scaleY -= 0.05;
        break;
    case 5:
        if ((rotA < 2*M_PI) && (way == 1))
            rotA += 0.1;
        if ((rotA > 0) && (way == 0))
            rotA -= 0.1;
        break;
    case 6:
        draw_line();
        if ((simX < getmaxx()-7) && (way == 1))
            simX += 5;
        if ((simX > 0) && (way == 0))
            simX -= 5;
        draw_line();
        break;
    case 7:
        draw_line();
        if ((simY < getmaxy()-57) && (way == 1))
            simY += 5;
        if ((simY > 0) && (way == 0))
            simY -= 5;
        draw_line();
        break;
    case 8:
        draw_line();
        if ((simA < 3.09) && (way == 1))
            simA += 0.1;
        if ((simA > 0) && (way == 0))
            simA -= 0.1;
        draw_line();
        break;
    }
    print_numbers();
}
예제 #20
0
int get_reply_to_post(infostruct user,char *reply, char *sno){
	WINDOW *send_reply;
	WINDOW *msgwind;
	char conf;
	int retval = 2;
	int x,y;
	char *header = "*** Send A Reply ***";
	int i = 0;
	char *screen_name;
	double message_id;
	char *message;
	screen_name = (char *)malloc(25 * sizeof(char));
	if(screen_name == NULL){
		return 1;
	}
	/* i dont need this here.. needed in the retweet */
	message = (char *)malloc(140 * sizeof(char));
	if(message == NULL){
		return 1;
	}

	echo();
	cbreak();
	send_reply = newwin(10,80,user.row/2, (user.col - 80)/2);
	keypad(send_reply,TRUE);
	msgwind = derwin(send_reply,5,50,4,5 + strlen("Enter reply: "));
	keypad(msgwind,TRUE);
	box(send_reply,0,0);
	wattron(send_reply,A_BOLD);
	mvwprintw(send_reply,2,(getmaxx(send_reply) -strlen(header))/2,"%s",header);
	wattroff(send_reply,A_BOLD);
	mvwprintw(send_reply,4,5,"%s","Reply to sno :");
	wrefresh(send_reply);
	wscanw(send_reply,"%s",sno);

	if((message_id = get_message_id(0,sno,&screen_name,&message)) == 1)
		return 1;
	mvwprintw(send_reply,4,5,"%s","Enter reply: ");
	noecho();
	wrefresh(send_reply);
	getyx(send_reply,y,x);
	touchwin(send_reply);
	mvwprintw(msgwind,0,0,"@%s " ,screen_name);
	wrefresh(msgwind);

	while (1){
		int k;

		if(i > (140 - (int)strlen(screen_name) -2))
			wattron(send_reply,COLOR_PAIR(2));
		mvwprintw(send_reply,8,76,"   ");
		mvwprintw(send_reply,8,76,"%i",140 - strlen(screen_name) - 2 -i);
		if(i > (140 - (int)strlen(screen_name) -2))
			wattroff(send_reply,COLOR_PAIR(2));

		wrefresh(send_reply);
		wrefresh(msgwind);

		k = wgetch(msgwind);
		if(k == '\n')
			break;

		if ((k == KEY_BACKSPACE) && i > 0){
			getyx(msgwind,y,x);
			/* if on 1st of line 2, please go back to the last of line 1*/
			if((i + strlen(screen_name) + 2) == 50){
				mvwaddch(msgwind,y-1,49,' ');
				wmove(msgwind,y-1,49);
			}
			else if((i + strlen(screen_name) + 2) == 100){
				mvwaddch(msgwind,y-1,49,' ');
				wmove(msgwind,y-1,49);
			}
			else if((i + strlen(screen_name) + 2 ) == 150){
				mvwaddch(msgwind,y-1,49,' ');
				wmove(msgwind,y-1,49);
			}
			else {
				mvwaddch(msgwind,y,x -1,' ');
				wmove(msgwind,y,x-1);
			}
				
			i = i-1;
			
			
		}
		else {
			/* if its at 0 and i press a bcakspace, i dont want anything to happen, without the if, it was printing ^G etc */
			if(k != KEY_BACKSPACE){
				reply[i] = k;
				waddch(msgwind,reply[i]);
				i++;
			}
		}

	}

	reply[i+1] = '\0';
	wrefresh(send_reply);
	echo();
		

	getyx(send_reply,y,x);
	mvwprintw(send_reply,getmaxy(send_reply)- 2,5,"%s","Send? [y/N]");
	wrefresh(send_reply);
	do {
		conf = wgetch(send_reply);
		if(conf == 'Y' || conf == 'y')
			retval = 0;
		else if (conf == 'N' || conf == 'n')
			retval = 1;
	}while(conf != 'y' && conf != 'Y' && conf != 'N' && conf != 'n');
	
	noecho();
	refresh();
	delwin(send_reply);
	return retval;
}
예제 #21
0
/* Returns increment for curr_y. */
static int
show_file_type(FileView *view, int curr_y)
{
	const dir_entry_t *entry;
	int x;
	int old_curr_y = curr_y;
	x = getmaxx(menu_win);

	entry = &view->dir_entry[view->list_pos];

	mvwaddstr(menu_win, curr_y, 2, "Type: ");
	if(entry->type == FT_LINK)
	{
		char full_path[PATH_MAX];
		char linkto[PATH_MAX + NAME_MAX];

		get_current_full_path(view, sizeof(full_path), full_path);

		mvwaddstr(menu_win, curr_y, 8, "Link");
		curr_y += 2;
		mvwaddstr(menu_win, curr_y, 2, "Link To: ");

		if(get_link_target(full_path, linkto, sizeof(linkto)) == 0)
		{
			mvwaddnstr(menu_win, curr_y, 11, linkto, x - 11);

			if(!path_exists(linkto, DEREF))
			{
				mvwaddstr(menu_win, curr_y - 2, 12, " (BROKEN)");
			}
		}
		else
		{
			mvwaddstr(menu_win, curr_y, 11, "Couldn't Resolve Link");
		}
	}
	else if(entry->type == FT_EXEC || entry->type == FT_REG)
	{
#ifdef HAVE_FILE_PROG
		char full_path[PATH_MAX];
		FILE *pipe;
		char command[1024];
		char buf[NAME_MAX];

		get_current_full_path(view, sizeof(full_path), full_path);

		/* Use the file command to get file information. */
		snprintf(command, sizeof(command), "file \"%s\" -b", full_path);

		if((pipe = popen(command, "r")) == NULL)
		{
			mvwaddstr(menu_win, curr_y, 8, "Unable to open pipe to read file");
			return 2;
		}

		if(fgets(buf, sizeof(buf), pipe) != buf)
			strcpy(buf, "Pipe read error");

		pclose(pipe);

		mvwaddnstr(menu_win, curr_y, 8, buf, x - 9);
		if(x > 9 && strlen(buf) > (size_t)(x - 9))
		{
			mvwaddnstr(menu_win, curr_y + 1, 8, buf + x - 9, x - 9);
		}
#else /* #ifdef HAVE_FILE_PROG */
		if(entry->type == FT_EXEC)
			mvwaddstr(menu_win, curr_y, 8, "Executable");
		else
			mvwaddstr(menu_win, curr_y, 8, "Regular File");
#endif /* #ifdef HAVE_FILE_PROG */
	}
	else if(entry->type == FT_DIR)
	{
		mvwaddstr(menu_win, curr_y, 8, "Directory");
	}
#ifndef _WIN32
	else if(entry->type == FT_CHAR_DEV || entry->type == FT_BLOCK_DEV)
	{
		const char *const type = (entry->type == FT_CHAR_DEV)
		                       ? "Character Device"
		                       : "Block Device";
		char full_path[PATH_MAX];
		struct stat st;

		mvwaddstr(menu_win, curr_y, 8, type);

		get_current_full_path(view, sizeof(full_path), full_path);
		if(os_stat(full_path, &st) == 0)
		{
			char info[64];

			snprintf(info, sizeof(info), "Device Id: 0x%x:0x%x", major(st.st_rdev),
					minor(st.st_rdev));

			curr_y += 2;
			mvwaddstr(menu_win, curr_y, 2, info);
		}
	}
	else if(entry->type == FT_SOCK)
	{
		mvwaddstr(menu_win, curr_y, 8, "Socket");
	}
#endif
	else if(entry->type == FT_FIFO)
	{
		mvwaddstr(menu_win, curr_y, 8, "Fifo Pipe");
	}
	else
	{
		mvwaddstr(menu_win, curr_y, 8, "Unknown");
	}
	curr_y += 2;

	return curr_y - old_curr_y;
}
예제 #22
0
파일: turtle.c 프로젝트: z88dk/z88dk
void home(){
    turtle_x=getmaxx()/2.0;
    turtle_y=getmaxy()/2.0;

    turtle_r=0.0;
}
예제 #23
0
/*
 * Display text from a file in a dialog box, like in a "tail -f".
 */
int
dialog_tailbox(const char *title, const char *file, int height, int width, int bg_task)
{
    /* *INDENT-OFF* */
    static DLG_KEYS_BINDING binding[] = {
	HELPKEY_BINDINGS,
	ENTERKEY_BINDINGS,
	DLG_KEYS_DATA( DLGK_BEGIN,      '0' ),
	DLG_KEYS_DATA( DLGK_BEGIN,      KEY_BEG ),
	DLG_KEYS_DATA( DLGK_GRID_LEFT,  'H' ),
	DLG_KEYS_DATA( DLGK_GRID_LEFT,  'h' ),
	DLG_KEYS_DATA( DLGK_GRID_LEFT,  KEY_LEFT ),
	DLG_KEYS_DATA( DLGK_GRID_RIGHT, 'L' ),
	DLG_KEYS_DATA( DLGK_GRID_RIGHT, 'l' ),
	DLG_KEYS_DATA( DLGK_GRID_RIGHT, KEY_RIGHT ),
	END_KEYS_BINDING
    };
    /* *INDENT-ON* */

#ifdef KEY_RESIZE
    int old_height = height;
    int old_width = width;
#endif
    int fkey;
    int x, y, result, thigh;
    WINDOW *dialog, *text;
    const char **buttons = 0;
    MY_OBJ *obj;
    FILE *fd;
    int min_width = 12;

    /* Open input file for reading */
    if ((fd = fopen(file, "rb")) == NULL)
	dlg_exiterr("Can't open input file in dialog_tailbox().");

#ifdef KEY_RESIZE
  retry:
#endif
    dlg_auto_sizefile(title, file, &height, &width, 2, min_width);
    dlg_print_size(height, width);
    dlg_ctl_size(height, width);

    x = dlg_box_x_ordinate(width);
    y = dlg_box_y_ordinate(height);
    thigh = height - ((2 * MARGIN) + (bg_task ? 0 : 2));

    dialog = dlg_new_window(height, width, y, x);

    dlg_mouse_setbase(x, y);

    /* Create window for text region, used for scrolling text */
    text = dlg_sub_window(dialog,
			  thigh,
			  width - (2 * MARGIN),
			  y + MARGIN,
			  x + MARGIN);

    dlg_draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr);
    dlg_draw_bottom_box(dialog);
    dlg_draw_title(dialog, title);
    dlg_draw_helpline(dialog, FALSE);

    if (!bg_task) {
	buttons = dlg_exit_label();
	dlg_button_layout(buttons, &min_width);
	dlg_draw_buttons(dialog, height - (2 * MARGIN), 0, buttons, FALSE,
			 FALSE, width);
    }

    (void) wmove(dialog, thigh, (MARGIN + 1));
    (void) wnoutrefresh(dialog);

    obj = dlg_calloc(MY_OBJ, 1);
    assert_ptr(obj, "dialog_tailbox");

    obj->obj.input = fd;
    obj->obj.win = dialog;
    obj->obj.handle_getc = handle_my_getc;
    obj->obj.handle_input = bg_task ? handle_input : 0;
    obj->obj.keep_bg = bg_task && dialog_vars.cant_kill;
    obj->obj.bg_task = bg_task;
    obj->text = text;
    obj->buttons = buttons;
    dlg_add_callback(&(obj->obj));

    dlg_register_window(dialog, "tailbox", binding);
    dlg_register_buttons(dialog, "tailbox", buttons);

    /* Print last page of text */
    dlg_attr_clear(text, thigh, getmaxx(text), dialog_attr);
    repaint_text(obj);

    if (bg_task) {
	result = DLG_EXIT_OK;
    } else {
	int ch;
	do {
	    ch = dlg_getc(dialog, &fkey);
#ifdef KEY_RESIZE
	    if (fkey && ch == KEY_RESIZE) {
		/* reset data */
		height = old_height;
		width = old_width;
		/* repaint */
		dlg_clear();
		dlg_del_window(dialog);
		refresh();
		dlg_mouse_free_regions();
		dlg_button_layout(buttons, &min_width);
		goto retry;
	    }
#endif
	}
	while (handle_my_getc(&(obj->obj), ch, fkey, &result));
    }
    dlg_mouse_free_regions();
    return result;
}
예제 #24
0
파일: textbox.c 프로젝트: 0mp/freebsd
/*
 * Display a dialog box and get the search term from user.
 */
static int
get_search_term(WINDOW *dialog, char *input, int height, int width)
{
    /* *INDENT-OFF* */
    static DLG_KEYS_BINDING binding[] = {
	INPUTSTR_BINDINGS,
	HELPKEY_BINDINGS,
	ENTERKEY_BINDINGS,
	END_KEYS_BINDING
    };
    /* *INDENT-ON* */

    int old_x, old_y;
    int box_x, box_y;
    int box_height, box_width;
    int offset = 0;
    int key = 0;
    int fkey = 0;
    bool first = TRUE;
    int result = DLG_EXIT_UNKNOWN;
    const char *caption = _("Search");
    int len_caption = dlg_count_columns(caption);
    const int *indx;
    int limit;
    WINDOW *widget;

    getbegyx(dialog, old_y, old_x);

    box_height = 1 + (2 * MARGIN);
    box_width = len_caption + (2 * (MARGIN + 2));
    box_width = MAX(box_width, 30);
    box_width = MIN(box_width, getmaxx(dialog) - 2 * MARGIN);
    len_caption = MIN(len_caption, box_width - (2 * (MARGIN + 1)));

    box_x = (width - box_width) / 2;
    box_y = (height - box_height) / 2;
    widget = dlg_new_modal_window(dialog,
				  box_height, box_width,
				  old_y + box_y, old_x + box_x);
    keypad(widget, TRUE);
    dlg_register_window(widget, "searchbox", binding);

    dlg_draw_box2(widget, 0, 0, box_height, box_width,
		  searchbox_attr,
		  searchbox_border_attr,
		  searchbox_border2_attr);
    (void) wattrset(widget, searchbox_title_attr);
    (void) wmove(widget, 0, (box_width - len_caption) / 2);

    indx = dlg_index_wchars(caption);
    limit = dlg_limit_columns(caption, len_caption, 0);
    (void) waddnstr(widget, caption + indx[0], indx[limit] - indx[0]);

    box_width -= 2;
    offset = dlg_count_columns(input);

    while (result == DLG_EXIT_UNKNOWN) {
	if (!first) {
	    key = dlg_getc(widget, &fkey);
	    if (fkey) {
		switch (fkey) {
#ifdef KEY_RESIZE
		case KEY_RESIZE:
		    result = DLG_EXIT_CANCEL;
		    continue;
#endif
		case DLGK_ENTER:
		    result = DLG_EXIT_OK;
		    continue;
		}
	    } else if (key == ESC) {
		result = DLG_EXIT_ESC;
		continue;
	    } else if (key == ERR) {
		napms(50);
		continue;
	    }
	}
	if (dlg_edit_string(input, &offset, key, fkey, first)) {
	    dlg_show_string(widget, input, offset, searchbox_attr,
			    1, 1, box_width, FALSE, first);
	    first = FALSE;
	}
    }
    dlg_del_window(widget);
    return result;
}
예제 #25
0
int main()
{
 int i, x, y, tx, ty, sx, sy, angle=10, xmax, ymax, xmid, ymid, op;
 int gd,gm;
 float p1[10]= { 50,50,
     100,50,
     100,100,
     50,100,
     50,50,
 };
 int pi[10];
 float b[3][3]={ 1,0,0,
     0,1,0,
     0,0,1
 };
 int c[1][1];
 float a[1][1];
 printf("\nSelect the transformation : ");
 printf("\n1 : Translation");
 printf("\n2 : Rotation");
 printf("\n3 : Scaling");
 printf("\n4 : Rotation about arbitrary point");
 printf( "\nEnter the option : ");
 scanf("%d",&op);
 switch(op)
 {
  case 1: printf("\nEnter x translation : ");
  scanf("%d",&tx);
  printf("\nEnter y translation : ");
  scanf("%d",&ty);
  
  b[0][0] = 1;
  b[0][1] = 0;
  b[0][2] = 0;
  
  b[1][0] = 0;
  b[1][1] = 1;
  b[1][2] = 0;
  
  b[2][0] = tx;
  b[2][1] = ty;
  b[2][2] = 1;
  
  break;
  case 2: printf("\nEnter Rotation angle : ");
  scanf("%d",&angle);
  b[0][0] =cos(angle*3.142/180);
  b[0][1] =sin(angle*3.142/180);
  b[0][2] = 0;
  
  b[1][0] =-sin(angle*3.142/180);
  b[1][1] = cos(angle*3.142/180);
  b[1][2] = 0;
  
  b[2][0] = 0;
  b[2][1] = 0;
  b[2][2] = 1;
  
  break;
  case 3: printf("\nEnter x scaling : ");
  scanf("%d",&sx);
  printf("\nEnter y scaling : ");
  scanf("%d",&sy);
  
  b[0][0] = sx;
  b[0][1] = 0;
  b[0][2] = 0;
  
  b[1][0] = 0;
  b[1][1] = sy;
  b[1][2] = 0;
  
  b[2][0] = 0;
  b[2][1] = 0;
  b[2][2] = 1;
  
  break;
  case 4: printf("\nEnter x coordinate of arbitrary point : ");
  scanf("%d",&x);
  printf("\nEnter y coordinate of arbitrary point : ");
  scanf("%d",&y);
  printf("\nEnter Rotation angle : ");
  scanf("%d",&angle);
  
  tx = x;
  ty = y;
  
  b[0][0] =cos(angle*3.142/180);
  b[0][1] =sin(angle*3.142/180);
  b[0][2] = 0;
  
  b[1][0] =-sin(angle*3.142/180);
  b[1][1] = cos(angle*3.142/180);
  b[1][2] = 0;
  
  b[2][0] = -tx* cos(angle*3.142/180) + ty*sin(angle*3.142/180)+tx;
  b[2][1] = -tx* sin(angle*3.142/180) - ty*cos(angle*3.142/180)+ty;
  b[2][2] = 1;
     
 }
 detectgraph(&gd,&gm);
 initgraph(&gd,&gm,"C:\\Turboc3\\BGI"); // Initialize graphics
 xmax = getmaxx(); // Get maximum x coordinate
 ymax = getmaxy(); // Get maximum y coordinate
 xmid = xmax/2; // Get the center x coordinate
 ymid = ymax/2; // Get the center y coordinate
 
 setcolor(1);
 line(xmid,0,xmid,ymax); // Draw y coordinate
 line(0, ymid, xmax, ymid); // Draw x coordinate
 
 setcolor(4);
 for (i=0; i<8;i=i+2)
 {
  line(p1[i]+xmid,ymid-p1[i+1],xmid+p1[i+2],ymid-p1[i+3]);
 }
 for(i=0;i<9;i=i+2)
 { 
  a[0][0]=p1[i];
  a[0][1]=p1[i+1];
  c[0][0] = a[0][0]*b[0][0]+a[0][1]*b[1][0]+b[2][0];
  c[0][1] = a[0][0]*b[0][1]+a[0][1]*b[1][1]+b[2][1];
  pi[i]=c[0][0];
  pi[i+1]=c[0][1];
 }
 setcolor(15);
 for (i=0; i<8;i=i+2)
 {
  line(xmid+pi[i],ymid-pi[i+1],xmid+pi[i+2],ymid-pi[i+3]);
 }
 getch();
 closegraph();
 return 0;
}
예제 #26
0
void
redraw_attr_dialog(void)
{
	const char *title;
	int x, y;
	size_t title_len;
	int need_ellipsis;

	werase(change_win);
	if(file_is_dir)
		wresize(change_win, 22, 30);
	else
		wresize(change_win, 20, 30);

	mvwaddstr(change_win, 3, 2, "Owner [ ] Read");
	if(perms[0])
		mvwaddch(change_win, 3, 9, (perms[0] < 0) ? 'X' : '*');
	mvwaddstr(change_win, 4, 6, "  [ ] Write");

	if(perms[1])
		mvwaddch(change_win, 4, 9, (perms[1] < 0) ? 'X' : '*');
	mvwaddstr(change_win, 5, 6, "  [ ] Execute");

	if(perms[2])
		mvwaddch(change_win, 5, 9, (perms[2] < 0) ? 'X' : '*');

	mvwaddstr(change_win, 6, 6, "  [ ] SetUID");
	if(perms[3])
		mvwaddch(change_win, 6, 9, (perms[3] < 0) ? 'X' : '*');

	mvwaddstr(change_win, 8, 2, "Group [ ] Read");
	if(perms[4])
		mvwaddch(change_win, 8, 9, (perms[4] < 0) ? 'X' : '*');

	mvwaddstr(change_win, 9, 6, "  [ ] Write");
	if(perms[5])
		mvwaddch(change_win, 9, 9, (perms[5] < 0) ? 'X' : '*');

	mvwaddstr(change_win, 10, 6, "  [ ] Execute");
	if(perms[6])
		mvwaddch(change_win, 10, 9, (perms[6] < 0) ? 'X' : '*');

	mvwaddstr(change_win, 11, 6, "  [ ] SetGID");
	if(perms[7])
		mvwaddch(change_win, 11, 9, (perms[7] < 0) ? 'X' : '*');

	mvwaddstr(change_win, 13, 2, "Other [ ] Read");
	if(perms[8])
		mvwaddch(change_win, 13, 9, (perms[8] < 0) ? 'X' : '*');

	mvwaddstr(change_win, 14, 6, "  [ ] Write");
	if(perms[9])
		mvwaddch(change_win, 14, 9, (perms[9] < 0) ? 'X' : '*');

	mvwaddstr(change_win, 15, 6, "  [ ] Execute");
	if(perms[10])
		mvwaddch(change_win, 15, 9, (perms[10] < 0) ? 'X' : '*');

	mvwaddstr(change_win, 16, 6, "  [ ] Sticky");
	if(perms[11])
		mvwaddch(change_win, 16, 9, (perms[11] < 0) ? 'X' : '*');

	if(file_is_dir)
		mvwaddstr(change_win, 18, 6, "  [ ] Set Recursively");

	getmaxyx(stdscr, y, x);
	mvwin(change_win, (y - (20 + (file_is_dir != 0)*2))/2, (x - 30)/2);
	box(change_win, ACS_VLINE, ACS_HLINE);

	x = getmaxx(change_win);
	title = get_title();
	title_len = strlen(title);
	need_ellipsis = (title_len > (size_t)x - 2);

	if(need_ellipsis)
	{
		x -= 3;
		title_len = x;
	}
	mvwaddnstr(change_win, 0, (getmaxx(change_win) - title_len)/2, title, x - 2);
	if(need_ellipsis)
	{
		waddstr(change_win, "...");
	}

	curs_set(TRUE);
	wmove(change_win, curr, col);
	wrefresh(change_win);
}
예제 #27
0
void hidequeueinfo()
{
setfillstyle(SOLID_FILL,BLACK);
bar(3,410,getmaxx(),getmaxy());
}
예제 #28
0
파일: ui.c 프로젝트: nwaldispuehl/goaccess
/* render general statistics */
void
display_general (WINDOW * win, char *ifile, GLog * logger)
{
  char *bw, *size, *log_file;
  char *failed, *not_found, *process, *ref, *req;
  char *static_files, *now, *visitors, *exclude_ip;

  int x_field = 2, x_value = 0;
  size_t n, i, j, max_field = 0, max_value = 0, mod_val, y;

  typedef struct Field_
  {
    const char *field;
    char *value;                /* char due to log, bw, log_file */
    int color;
  } Field;

  Field fields[] = {
    {T_REQUESTS, NULL, COL_CYAN},
    {T_UNIQUE_VIS, NULL, COL_CYAN},
    {T_REFERRER, NULL, COL_CYAN},
    {T_LOG, NULL, COL_CYAN},
    {T_F_REQUESTS, NULL, COL_CYAN},
    {T_UNIQUE_FIL, NULL, COL_CYAN},
    {T_UNIQUE404, NULL, COL_CYAN},
    {T_BW, NULL, COL_CYAN},
    {T_GEN_TIME, NULL, COL_CYAN},
    {T_EXCLUDE_IP, NULL, COL_CYAN},
    {T_STATIC_FIL, NULL, COL_CYAN},
    {T_LOG_PATH, NULL, COL_YELLOW}
  };

  werase (win);
  draw_header (win, T_HEAD, " %s", 0, 0, getmaxx (stdscr), 1, 0);

  if (!logger->piping && ifile != NULL) {
    size = filesize_str (file_size (ifile));
    log_file = alloc_string (ifile);
  } else {
    size = alloc_string ("N/A");
    log_file = alloc_string ("STDIN");
  }
  bw = filesize_str ((float) logger->resp_size);

  /* *INDENT-OFF* */
  failed       = int_to_str (logger->invalid);
  not_found    = int_to_str (get_ht_size (ht_not_found_requests));
  process      = int_to_str (logger->process);
  ref          = int_to_str (get_ht_size (ht_referrers));
  req          = int_to_str (get_ht_size(ht_requests));
  static_files = int_to_str (get_ht_size(ht_requests_static));
  now          = int_to_str (((long long) end_proc - start_proc));
  visitors     = int_to_str (get_ht_size(ht_unique_visitors));
  exclude_ip    = int_to_str (logger->exclude_ip);

  fields[0].value = process;
  fields[1].value = visitors;
  fields[2].value = ref;
  fields[3].value = size;
  fields[4].value = failed;
  fields[5].value = req;
  fields[6].value = not_found;
  fields[7].value = bw;
  fields[8].value = now;
  fields[9].value = exclude_ip;
  fields[10].value = static_files;
  fields[11].value = log_file;

  n = ARRAY_SIZE (fields);

  /* *INDENT-ON* */
  for (i = 0, y = 2; i < n; i++) {
    mod_val = i % 4;
    if (i > 0 && mod_val == 0) {
      max_field = 0;
      max_value = 0;
      x_field = 2;
      x_value = 2;
      y++;
    }

    x_field += max_field;
    mvwprintw (win, y, x_field, "%s", fields[i].field);

    max_field = 0;
    for (j = 0; j < n; j++) {
      size_t len = strlen (fields[j].field);
      if (j % 4 == mod_val && len > max_field)
        max_field = len;
    }

    max_value = 0;
    for (j = 0; j < n; j++) {
      size_t len = strlen (fields[j].value);
      if (j % 4 == mod_val && len > max_value)
        max_value = len;
    }
    x_value = max_field + x_field + 1;
    max_field += max_value + 2;

    wattron (win, A_BOLD | COLOR_PAIR (fields[i].color));
    mvwprintw (win, y, x_value, "%s", fields[i].value);
    wattroff (win, A_BOLD | COLOR_PAIR (fields[i].color));
  }
  for (i = 0; i < n; i++) {
    free (fields[i].value);
  }
}
예제 #29
0
void cpoiters()
{
setfillstyle(SOLID_FILL,BLACK);
bar(250,211,getmaxx()-20,280);
}
예제 #30
0
int screen_width( void ) {
    return override_screen == NULL ? getmaxx( stdscr ) : override_screen->width;
}