Example #1
0
void initWins() {
    int maxX, i;


    // Get main window size
    maxX = getmaxx(stdscr);

    // Create windows
    cursesWins[0] = newwin(LINES - 4, COLS / 2, 2, 0);
    cursesWins[1] = newwin(LINES - 4, COLS / 2, 2, maxX - (COLS / 2));

    for (i = 0; i < 2; ++i) {
        if (cursesWins[i] == NULL) {
            fprintf(stderr, "Error: could not initialize window[%d]\n", i);
            exit(-1);
        }
        keypad(cursesWins[i], TRUE);

        // Create border around windows
        box(cursesWins[i], 0, 0);

        // Attach panel to window
        cursesPanels[i] = new_panel(cursesWins[i]);
        if (cursesPanels[i] == NULL) {
            fprintf(stderr, "Error: could not initialize panel[%d]\n", i);
            exit(-1);
        }
    }

    // Center and color window title
    wattron(cursesWins[0], A_STANDOUT);
    wattron(cursesWins[1], A_STANDOUT);
    mvwprintw(cursesWins[0], 1, (getmaxx(cursesWins[0]) / 2) - 2, "Files");
    mvwprintw(cursesWins[1], 1, (getmaxx(cursesWins[1]) / 2) - 5, "Directories");
    wattroff(cursesWins[0], A_STANDOUT);
    wattroff(cursesWins[1], A_STANDOUT);

    update_panels();
    doupdate();

    // Print commands
    attron(A_STANDOUT);
    mvprintw(LINES - 4, 0, "Menu commands:");
    chgat(-1, A_REVERSE, 0, NULL);
    mvprintw(LINES - 3, 0, "Tab: change menu  Arrows: highlight item  PgUp/PgDown: change menu page");
    chgat(-1, A_REVERSE, 0, NULL);
    mvprintw(LINES - 2, 0, "Highlighted item commands:");
    chgat(-1, A_REVERSE, 0, NULL);
    mvprintw(LINES - 1, 0, "e: edit file  r: run program  c: change to directory  q: quit");
    // Highlight entire line
    chgat(-1, A_REVERSE, 0, NULL);
    attroff(A_STANDOUT);

    refresh();
}
Example #2
0
static void
test_chgat(void)
{
    STATUS st;

    init_status(stdscr, &st);

    do {
	switch (st.ch) {
	case '.':		/* change from current position */
	    chgat(st.count, st.attr, st.pair, (void *) 0);
	    touch_if_needed(stdscr, st.y_val);
	    break;
	case ',':		/* change from beginning of window */
	    mvchgat(0, 0, st.count, st.attr, st.pair, (void *) 0);
	    touch_if_needed(stdscr, 0);
	    move(st.y_val, st.x_val);
	    break;
	case 'w':
	    do_subwindow(stdscr, &st, test_wchgat);
	    break;
	case 'q':
	    return;
	default:
	    update_status(stdscr, &st);
	    break;
	}
    } while ((st.ch = getch()) != ERR);
}
Example #3
0
/* Show details on screen */
void nhexScreenDetails(struct nhexBuff *nhexFile)
{
	char		sType[6];
	unsigned int	iPos;
	int		iChunkPos;
	int		ixHexPos, ixAscPos, ixCurPos;
	char		*p;

	if(nhexScreen.iChunks == -1) return;

	iPos=nhexFile->iOff + nhexFile->iyPos * nhexScreen.iChunks*8 + nhexFile->ixPos;
	iChunkPos=nhexFile->ixPos / 8;
	ixHexPos=11+nhexFile->ixPos * 3 + iChunkPos;
	ixAscPos=11+(nhexScreen.iChunks*8) * 3 + (nhexScreen.iChunks-1) + 2 + nhexFile->ixPos + iChunkPos;

	if(nhexFile->bPos)
	{
		strcpy(sType, "ASCII");
		ixCurPos=ixAscPos;
	}
	else
	{
		if (nhexFile->bHiLo)
		{
			strcpy(sType, "HEX-L");
			ixCurPos=ixHexPos+1;
		}
		else
		{
			strcpy(sType, "HEX-H");
			ixCurPos=ixHexPos;
		}
	}

	/* show filename, pos & area */
	move(nhexScreen.iRows+1, 0);
	clrtoeol();
	chgat(-1, A_REVERSE, 0, NULL);
	attron(A_REVERSE);
	if(nhexFile->iChangeCnt) printw("+ ");
	if(nhexFile->fp)
	{
		p=strrchr(nhexFile->sFileName,'/');
		if(p)
			p++;
		else
			p=nhexFile->sFileName;
		printw("%s", p);
	}
	mvprintw(nhexScreen.iRows+1, nhexScreen.iCols-6, "|%s",sType);
	mvprintw(nhexScreen.iRows+1, nhexScreen.iCols-26, "|%010u/%08X", iPos, iPos);
	mvprintw(nhexScreen.iRows+1, nhexScreen.iCols-31, "|%04i", nhexFile->iChangeCnt);
	attroff(A_REVERSE);

	/* show edit-position & set cursor */
	if(nhexFile->fp){
		nhexScreenShowByte(nhexFile, iPos, nhexFile->iyPos, ixHexPos, ixAscPos);
		move(nhexFile->iyPos + 1, ixCurPos);
	}
	else
	{
		mvprintw(nhexScreen.iRows/2-1, (nhexScreen.iCols-7)/2, "nHex-Ed");
		mvprintw(nhexScreen.iRows/2+1, (nhexScreen.iCols-23)/2, "Press <F12> for the menu");
	}

	refresh();

	return;
}