Beispiel #1
0
slk_wset(int i, const wchar_t *astr, int format)
{
    int result = ERR;
    size_t arglen;
    const wchar_t *str;
    char *mystr;
    mbstate_t state;

    T((T_CALLED("slk_wset(%d, %s, %d)"), i, _nc_viswbuf(astr), format));

    init_mb(state);
    str = astr;
    if ((arglen = wcsrtombs(NULL, &str, 0, &state)) != (size_t) -1) {
	if ((mystr = (char *) _nc_doalloc(0, arglen + 1)) != 0) {
	    str = astr;
	    if (wcsrtombs(mystr, &str, arglen, &state) != (size_t) -1) {
		/* glibc documentation claims that the terminating L'\0'
		 * is written, but it is not...
		 */
		mystr[arglen] = 0;
		result = slk_set(i, mystr, format);
	    }
	    free(mystr);
	}
    }
    returnCode(result);
}
Beispiel #2
0
int 
slk_restore()
{
	int i, code = ERR;

#ifdef M_CURSES_TRACE
	__m_trace("slk_clear(void)");
#endif

	if (__m_screen->_slk._w != (WINDOW *) 0) {
		for (i = 0; i < 8; ++i) {
			if (__m_screen->_slk._labels[i] != (char *) 0) {
				(void) slk_set(
					i, __m_screen->_slk._labels[i],
					__m_screen->_slk._justify[i]
				);
			}
		}

		code = slk_refresh();
	} else if (label_on != (char *) 0) {
		(void) tputs(label_on, 1, __m_outc);
		(void) fflush(__m_screen->_of);
		code = OK;
	}
	
	return __m_return_code("slk_clear", code);
}
Beispiel #3
0
/******************************************************\
 * Description: Initialize function key menu interface*
\******************************************************/ 
void init_fkeys()
{
    slk_set(1, "Help",		1);			/* init menu tabs     */
    slk_set(2, "Save",		1);
    slk_set(3, "Open",	 	1);
    slk_set(4, "Goto",		1);
    slk_set(5, "Find", 		1);

    slk_set(7, "Hex Edit",	1);
    slk_set(8, "Quit",		1);
    slk_set(9, "Quit",		1);
    slk_noutrefresh();					/* refresh the screen */
}
Beispiel #4
0
static void slk_setup( const int slk_format)
{
    int i;
    static int old_format = 0xa;

    if( slk_format != old_format)
       slk_init( slk_format);
    old_format = slk_format;
    for( i = 0; labels[i]; i++)
       slk_set( i + 1, labels[i], 1);
    slk_refresh( );
}
Beispiel #5
0
/***
Set the label for a soft label key.
@function slk_set
@int labnum
@string label
@int fmt
@treturn bool `true`, if successful
@see slk_set(3x)
*/
static int
Pslk_set(lua_State *L)
{
	int labnum = checkint(L, 1);
	const char* label = luaL_checkstring(L, 2);
	int fmt = checkint(L, 3);
#if LCURSES_POSIX_COMPLIANT
	return pushokresult(slk_set(labnum, label, fmt));
#else
	return binding_notimplemented(L, "slk_set", "curses");
#endif
}
Beispiel #6
0
SCM
gucu_slk_set (SCM labnum, SCM label, SCM fmt)
{
  SCM_ASSERT (scm_is_integer (labnum), labnum, SCM_ARG1, "slk-set");
  SCM_ASSERT (scm_is_string (label), label, SCM_ARG2, "slk-set");
  SCM_ASSERT (scm_is_integer (fmt), fmt, SCM_ARG3, "slk-set");

  int c_labnum = scm_to_int (labnum);
  char *c_label = scm_to_locale_string (label);
  int c_fmt = scm_to_int (fmt);

  int ret = slk_set (c_labnum, c_label, c_fmt);
  RETURNTF (ret);
}
Beispiel #7
0
int main(void)
{
	slk_init(0);
	initscr();

	slk_set(1,"Help!",LEFT);
	slk_set(2,"File",LEFT);
	slk_set(3,"Print",LEFT);
	slk_set(4,"Text",CENTER);
	slk_set(5,"Edit",CENTER);
	slk_set(6,"Quick",RIGHT);
	slk_set(7,"Conf",RIGHT);
	slk_set(8,"Change",RIGHT);
	slk_refresh();
	getch();

	endwin();
	return 0;
}
Beispiel #8
0
int main(void)
{
	char labels[LCOUNT][19] = { "Help!", "File", "Print", "Text",
						  "Edit", "Quick", "Config", "System" };
	int x;

	slk_init(0);
	initscr();

	for(x=0;x<LCOUNT;x++)
		slk_set(x+1,labels[x],CENTER);
	slk_attron(A_BOLD);
	slk_refresh();
	getch();

	endwin();
	return 0;
}
Beispiel #9
0
int main()
{
	char label_text[LMAX][6] = { "Help", "File", "Edit", "Frmt",
						  "Find", "Block", "Ins", "Del",
						  "View", "Switch", "Win", "Help" };
	int label;
	
	slk_init(3);
	initscr();

	for(label=0;label<LMAX;label++)
		slk_set(label+1,label_text[label],CENTER);
	slk_refresh();

	getch();

	endwin();
	return 0;
}
Beispiel #10
0
int main(void)
{
    char labels[LCOUNT][19] = { "Help!", "File", "Print", "Text",
                                "Edit", "Quick", "Config", "System"
                              };
    int x;

    slk_init(0);
    initscr();
    start_color();
    init_pair(1,COLOR_BLUE,COLOR_WHITE);

    slk_color(1);
    for(x=0; x<LCOUNT; x++)
        slk_set(x+1,labels[x],CENTER);
    slk_refresh();
    getch();

    endwin();
    return 0;
}
Beispiel #11
0
int main()
{
	char label_text[LMAX][8] = { "S", "O", "F", "T",
								 "K", "E", "Y", "S" };
	int label;
	
	slk_init(1);
	initscr();

	for(label=0;label<LMAX;label++)
		slk_set(label+1,label_text[label],CENTER);
	slk_refresh();
	getch();

	slk_clear();
	getch();

	slk_restore();
	getch();

	endwin();
	return 0;
}
Beispiel #12
0
int main()
{
	char label_text[LMAX][20] = { "I", "AM", "SAM", "DO",
								 "NOT", "LIKE", "THAT", "SAY",
								 "WOULD", "COULD", "YOU",
								 "GREEN EGGS AND HAM" };
	int label,ch;
	
	slk_init(2);					/* 12 soft labels */
	initscr();
	noecho();						/* disable key echoing */
	keypad(stdscr,TRUE);			/* Turn on Fkey reading */
	
/* display the labels and instructions */
	for(label=0;label<LMAX;label++)
		slk_set(label+1,label_text[label],CENTER);
	slk_refresh();
	addstr("Use the Function Keys to type\n");
	addstr("Press '?' or '!' or '.' to end a line\n");
	addstr("Press Enter to quit\n\n");
	refresh();

/* Process input */
	while( (ch=getch()) != '\n')
	{
		switch(ch)
		{
				case '?':
				case '!':
				case '.':
					addch(ch);
					addch('\n');
					break;
				case KEY_F(1):
					printw("%s ",label_text[0]);
					break;
				case KEY_F(2):
					printw("%s ",label_text[1]);
					break;
				case KEY_F(3):
					printw("%s ",label_text[2]);
					break;
				case KEY_F(4):
					printw("%s ",label_text[3]);
					break;
				case KEY_F(5):
					printw("%s ",label_text[4]);
					break;
				case KEY_F(6):
					printw("%s ",label_text[5]);
					break;
				case KEY_F(7):
					printw("%s ",label_text[6]);
					break;
				case KEY_F(8):
					printw("%s ",label_text[7]);
					break;
				case KEY_F(9):
					printw("%s ",label_text[8]);
					break;
				case KEY_F(10):
					printw("%s ",label_text[9]);
					break;
				case KEY_F(11):
					printw("%s ",label_text[10]);
					break;
				case KEY_F(12):
					printw("%s ",label_text[11]);
					break;
				default:
					break;
		}
		refresh();
	}

	endwin();
	return 0;
}
Beispiel #13
0
int main(int argc, char *argv[])			/* main program       */
{

    int   x, retval = 1;			/* counters, etc.     */
    off_t val, len;					/* len need to be off_t*/

    windows = (WINS *) calloc(1, sizeof(WINS));	/* malloc windows     */
    head = llalloc();							/* malloc list space  */
    fpINfilename = NULL;			/* allocate in and    */
    fpOUTfilename = NULL;			/* out file name ptrs */
    printHex = TRUE;							/* address format     */
    USE_EBCDIC = FALSE;							/*use ascii by default*/

							/* get cmd line args  */
    len = parseArgs(argc, argv);
    MIN_ADDR_LENGTH = getMinimumAddressLength(len);

    use_env(TRUE);					/* use env values     */
    slk_init(0);					/* init menu bar      */
    init_screen();					/* init visuals       */
    init_colors();

    if ((COLS < MIN_COLS) || (LINES < MIN_LINES))	/* screen's too small */
    {
	endwin();
	fprintf(stderr,"\n\nThe screen size too small.\nThe minimum allowable");
	fprintf(stderr," screen size is %dx%d\n\n", MIN_COLS, MIN_LINES + 1);
	exit(-1);
    }
    
    slk_set(6, (printHex) ? "Hex Addr":"Dec Addr", 1);
    init_fkeys();					/* define menu bar    */
    

    while (retval)
    {
	free_windows(windows);
        
	/* calculate screen   */
	BASE                = (resize > 0 && resize < COLS) ? resize:((COLS-6-MIN_ADDR_LENGTH)/4);
	MAXY                = (LINES) - 3;
	hex_win_width       = BASE * 3;
	ascii_win_width     = BASE;
	hex_outline_width   = (BASE * 3) + 3 + MIN_ADDR_LENGTH;
	ascii_outline_width = BASE + 2;
            
	init_menu(windows);				/* init windows       */
	head = freeList(head);				/* free & init head   */
							/* print origin loc   */
	mvwprintw(windows->hex_outline, 0, 1, "%0*d", MIN_ADDR_LENGTH, 0);
    
	if (fpIN != NULL)				/* if no infile...    */
	{
            len = maxLoc(fpIN);				/* get last file loc  */
	    val = maxLines(len); 			/* max file lines     */
            for (x = 0; x <= MAXY && x<=val; x++)       /* output lines       */
		outline(fpIN, x);
	}

	wmove(windows->hex, 0, 0);			/* cursor to origin   */
    
	refreshall(windows);				/* refresh all wins   */
	doupdate();					/* update screen      */
        
	mvwaddch(windows->scrollbar, 1, 0, ACS_CKBOARD);/* clear scroller     */
							/* get user input     */
	retval = wacceptch(windows, len); 
    }
    
    free(fpINfilename);
    free(fpOUTfilename);
    freeList(head);
    
    screen_exit(0);					/* end visualizations */
    return retval;					/* return             */
}
Beispiel #14
0
int chkr_slk_set(int labnum,char *label,int fmt)
{
   if (label != NULL)
      stubs_chkr_check_str(label, CHKR_RO, "label");
   return(slk_set(labnum,label,fmt));
}
Beispiel #15
0
static void slk_test(void)
/* exercise the soft keys */
{
    int	c, fmt = 1;
    char buf[9];

    c = CTRL('l');
    do {
	switch(c)
	{
	case CTRL('l'):
	    erase();
	    attron(A_BOLD);
	    mvaddstr(0, 20, "Soft Key Exerciser");
	    attroff(A_BOLD);

	    move(2, 0);
	    P("Available commands are:");
	    P("");
	    P("^L         -- refresh screen");
	    P("a          -- activate or restore soft keys");
	    P("d          -- disable soft keys");
	    P("c          -- set centered format for labels");
	    P("l          -- set left-justified format for labels");
	    P("r          -- set right-justified format for labels");
	    P("[12345678] -- set label; labels are numbered 1 through 8");
	    P("e          -- erase stdscr (should not erase labels)");
	    P("s          -- test scrolling of shortened screen");
	    P("x, q       -- return to main menu");
	    P("");
	    P("Note: if activating the soft keys causes your terminal to");
	    P("scroll up one line, your terminal auto-scrolls when anything");
	    P("is written to the last screen position.  The ncurses code");
	    P("does not yet handle this gracefully.");
	    refresh();
	    /* fall through */

	case 'a':
	    slk_restore();
	    break;

	case 'e':
	    wclear(stdscr);
	    break;

	case 's':
	    move(20, 0);
	    while ((c = getch()) != 'Q')
		addch(c);
	    break;

	case 'd':
	    slk_clear();
	    break;

	case 'l':
	    fmt = 0;
	    break;

	case 'c':
	    fmt = 1;
	    break;

	case 'r':
	    fmt = 2;
	    break;

	case '1': case '2': case '3': case '4':
	case '5': case '6': case '7': case '8':
	    (void) mvaddstr(20, 0, "Please enter the label value: ");
	    wgetnstr(stdscr, buf, 8);
	    slk_set((c - '0'), buf, fmt);
	    slk_refresh();
	    break;

	case 'x':
	case 'q':
	    goto done;

	default:
	    beep();
	}
    } while
	((c = getch()) != EOF);

 done:
    erase();
    endwin();
}