Ejemplo n.º 1
0
NCURSES_SP_NAME(scr_set) (NCURSES_SP_DCLx const char *file)
{
    T((T_CALLED("scr_set(%p,%s)"), (void *) SP_PARM, _nc_visbuf(file)));

    if (NCURSES_SP_NAME(scr_init) (NCURSES_SP_ARGx file) == ERR) {
	returnCode(ERR);
    } else {
	delwin(NewScreen(SP_PARM));
	NewScreen(SP_PARM) = dupwin(curscr);
#if !USE_REENTRANT
	newscr = NewScreen(SP_PARM);
#endif
	returnCode(OK);
    }
}
Ejemplo n.º 2
0
wrefresh(WINDOW *win)
{
    int code;
#if NCURSES_SP_FUNCS
    SCREEN *SP_PARM = _nc_screen_of(win);
#endif

    T((T_CALLED("wrefresh(%p)"), (void *) win));

    if (win == 0) {
	code = ERR;
    } else if (win == CurScreen(SP_PARM)) {
	CurScreen(SP_PARM)->_clear = TRUE;
	code = NCURSES_SP_NAME(doupdate) (NCURSES_SP_ARG);
    } else if ((code = wnoutrefresh(win)) == OK) {
	if (win->_clear)
	    NewScreen(SP_PARM)->_clear = TRUE;
	code = NCURSES_SP_NAME(doupdate) (NCURSES_SP_ARG);
	/*
	 * Reset the clearok() flag in case it was set for the special
	 * case in hardscroll.c (if we don't reset it here, we'll get 2
	 * refreshes because the flag is copied from stdscr to newscr).
	 * Resetting the flag shouldn't do any harm, anyway.
	 */
	win->_clear = FALSE;
    }
    returnCode(code);
}
Ejemplo n.º 3
0
NCURSES_SP_NAME(scr_set) (NCURSES_SP_DCLx const char *file)
{
    int code = ERR;

    T((T_CALLED("scr_set(%p,%s)"), (void *) SP_PARM, _nc_visbuf(file)));

    if (NCURSES_SP_NAME(scr_init) (NCURSES_SP_ARGx file) == OK) {
	delwin(NewScreen(SP_PARM));
	NewScreen(SP_PARM) = dupwin(curscr);
#if !USE_REENTRANT
	newscr = NewScreen(SP_PARM);
#endif
	if (NewScreen(SP_PARM) != 0) {
	    code = OK;
	}
    }
    returnCode(code);
}
Ejemplo n.º 4
0
NCURSES_SP_NAME(scr_restore) (NCURSES_SP_DCLx const char *file)
{
    FILE *fp = 0;

    T((T_CALLED("scr_restore(%p,%s)"), (void *) SP_PARM, _nc_visbuf(file)));

    if (_nc_access(file, R_OK) < 0
	|| (fp = fopen(file, "rb")) == 0) {
	returnCode(ERR);
    } else {
	delwin(NewScreen(SP_PARM));
	NewScreen(SP_PARM) = getwin(fp);
#if !USE_REENTRANT
	newscr = NewScreen(SP_PARM);
#endif
	(void) fclose(fp);
	returnCode(OK);
    }
}
Ejemplo n.º 5
0
NCURSES_SP_NAME(scr_restore) (NCURSES_SP_DCLx const char *file)
{
    FILE *fp = 0;
    int code = ERR;

    T((T_CALLED("scr_restore(%p,%s)"), (void *) SP_PARM, _nc_visbuf(file)));

    if (_nc_access(file, R_OK) >= 0
	&& (fp = fopen(file, "rb")) != 0) {
	delwin(NewScreen(SP_PARM));
	NewScreen(SP_PARM) = getwin(fp);
#if !USE_REENTRANT
	newscr = NewScreen(SP_PARM);
#endif
	(void) fclose(fp);
	if (NewScreen(SP_PARM) != 0) {
	    code = OK;
	}
    }
    returnCode(code);
}
Ejemplo n.º 6
0
static Externalclosure menu_load( char *p1, char *p2)
{   Externalclosure result = emptyclosure;
    char *filename, *language;
    Node *tmpclosure;
    FILE *infile;

    NewScreen();
    if( p1 == NULL )
    {  filename = GetFileName( "input dump " );
       if( filename == NULL ) return( result );
    }
    else
    {  filename = heapstr( p1 );
    }
    if( p2 == NULL )
    {  language = GetLanguage();
       if( language == NULL ) return( result );
    }
    else
    {  language = Capitalise( heapstr( p2 ));
    }

    if(( infile = fopen( filename,"r")) == NULL)
    {  perror( "Error opening input file: " );
    }
    else
    {  tmpclosure = ExternalclosureClosure( theclosure);
       if( tmpclosure != NULL)
       {  free_tree( tmpclosure ); 

          /* free idstable & idslookup to be done later */

          ExternalclosureClosure(theclosure) = NULL;
          tmpclosure = NULL;
          printf( "Must clear head data.\n");
        }

        objtable = GetTable(language);

        if( objtable != NULL )
        {  printf( "\n%sLOADING %s.\n", FORMAT_LINE, filename);
           result = read_assmodes( infile, language);
        }
        else
        {  printf( "Language %s not known.\n", language );
        }
        fclose( infile );
    }
    free( language );
    free( filename );
    return( result );
}
Ejemplo n.º 7
0
static int menu_browse(void)
{  Node *closure = ExternalclosureClosure(theclosure);

   NewScreen();
   if( closure != NULL )
   {  cmodes_browser( closure, objtable);
      return( 0 );
   }
   else
   {  printf( "Must load dump file first" );
   }
   return( 1 );
}
Ejemplo n.º 8
0
static int menu_write( char *p1, char *p2, int pkd )
{   char *filename, *language;
    Node *tmpclosure;
    int result = 1;
    FILE *elafile;

    NewScreen();
    if (ExternalclosureClosure(theclosure) != NULL)
    {   if( p1 == NULL )
        {  filename = GetFileName( "output dump " );
           if( filename == NULL ) return( result );
        }
        else
        {  filename = heapstr( p1 );
        }
        if( p2 == NULL )
        {  language = GetLanguage();
           if( filename == NULL ) return( result );
        }
        else
        {  language = Capitalise( heapstr( p2 ));
        }

        if ((elafile = fopen( filename,"w")) == NULL)
        {  perror( "Error openin output file: " );
        }
        else
        {  printf( "\n\n%sWRITING %s.\n", FORMAT_LINE, filename );
           result = write_assmodes( theclosure, elafile, language, pkd);
        }
        fclose( elafile );
    }
    else
    {  printf( "Must load dump file first" );
    }
    free( language );
    free( filename );
    return( result );
}
Ejemplo n.º 9
0
set_term(SCREEN *screenp)
{
    SCREEN *oldSP;
    SCREEN *newSP;

    T((T_CALLED("set_term(%p)"), (void *) screenp));

    _nc_lock_global(curses);

    oldSP = CURRENT_SCREEN;
    _nc_set_screen(screenp);
    newSP = screenp;

    if (newSP != 0) {
	TINFO_SET_CURTERM(newSP, newSP->_term);
#if !USE_REENTRANT
	curscr = CurScreen(newSP);
	newscr = NewScreen(newSP);
	stdscr = StdScreen(newSP);
	COLORS = newSP->_color_count;
	COLOR_PAIRS = newSP->_pair_count;
#endif
    } else {
	TINFO_SET_CURTERM(oldSP, 0);
#if !USE_REENTRANT
	curscr = 0;
	newscr = 0;
	stdscr = 0;
	COLORS = 0;
	COLOR_PAIRS = 0;
#endif
    }

    _nc_unlock_global(curses);

    T((T_RETURN("%p"), (void *) oldSP));
    return (oldSP);
}
Ejemplo n.º 10
0
static int write_file( char *fname)
{   FILE *outfile;
    char *filename;
    int result = 1;

    NewScreen();
    if( fname == NULL )
    {  filename = GetFileName( "output " );
       if( filename == NULL ) return( result );
    }
    else
    {  filename = heapstr( fname );
    }
    if (( outfile = fopen(filename,"w")) == NULL)
    {  perror( "Error opening output file: " );
    }
    else
    {  result = menu_layout( outfile );
       fclose( outfile );
    }
    free( filename );
    return( result );
}
Ejemplo n.º 11
0
pnoutrefresh(WINDOW *win,
	     int pminrow,
	     int pmincol,
	     int sminrow,
	     int smincol,
	     int smaxrow,
	     int smaxcol)
{
    NCURSES_SIZE_T i, j;
    NCURSES_SIZE_T m, n;
    NCURSES_SIZE_T pmaxrow;
    NCURSES_SIZE_T pmaxcol;
    SCREEN *sp;

#if USE_SCROLL_HINTS
    const int my_len = 2;	/* parameterize the threshold for hardscroll */
    NCURSES_SIZE_T displaced;
    bool wide;
#endif

    T((T_CALLED("pnoutrefresh(%p, %d, %d, %d, %d, %d, %d)"),
       (void *) win, pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol));

    if (win == 0)
	returnCode(ERR);

    if (!(win->_flags & _ISPAD))
	returnCode(ERR);

    sp = _nc_screen_of(win);

    /* negative values are interpreted as zero */
    if (pminrow < 0)
	pminrow = 0;
    if (pmincol < 0)
	pmincol = 0;
    if (sminrow < 0)
	sminrow = 0;
    if (smincol < 0)
	smincol = 0;

    pmaxrow = pminrow + smaxrow - sminrow;
    pmaxcol = pmincol + smaxcol - smincol;

    T((" pminrow + smaxrow - sminrow %ld, win->_maxy %ld",
       (long) pmaxrow, (long) win->_maxy));
    T((" pmincol + smaxcol - smincol %ld, win->_maxx %ld",
       (long) pmaxcol, (long) win->_maxx));

    /*
     * Trim the caller's screen size back to the actual limits.
     */
    if (pmaxrow > win->_maxy) {
	smaxrow -= (pmaxrow - win->_maxy);
	pmaxrow = pminrow + smaxrow - sminrow;
    }
    if (pmaxcol > win->_maxx) {
	smaxcol -= (pmaxcol - win->_maxx);
	pmaxcol = pmincol + smaxcol - smincol;
    }

    if (smaxrow >= screen_lines(sp)
	|| smaxcol >= screen_columns(sp)
	|| sminrow > smaxrow
	|| smincol > smaxcol)
	returnCode(ERR);

    T(("pad being refreshed"));

#if USE_SCROLL_HINTS
    if (win->_pad._pad_y >= 0) {
	displaced = pminrow - win->_pad._pad_y
	    - (sminrow - win->_pad._pad_top);
	T(("pad being shifted by %d line(s)", displaced));
    } else
	displaced = 0;
#endif

    /*
     * For pure efficiency, we'd want to transfer scrolling information
     * from the pad to newscr whenever the window is wide enough that
     * its update will dominate the cost of the update for the horizontal
     * band of newscr that it occupies.  Unfortunately, this threshold
     * tends to be complex to estimate, and in any case scrolling the
     * whole band and rewriting the parts outside win's image would look
     * really ugly.  So.  What we do is consider the pad "wide" if it
     * either (a) occupies the whole width of newscr, or (b) occupies
     * all but at most one column on either vertical edge of the screen
     * (this caters to fussy people who put boxes around full-screen
     * windows).  Note that changing this formula will not break any code,
     * merely change the costs of various update cases.
     */
#if USE_SCROLL_HINTS
    wide = (smincol < my_len && smaxcol > (NewScreen(sp)->_maxx - my_len));
#endif

    for (i = pminrow, m = sminrow + win->_yoffset;
	 i <= pmaxrow && m <= NewScreen(sp)->_maxy;
	 i++, m++) {
	register struct ldat *nline = &NewScreen(sp)->_line[m];
	register struct ldat *oline = &win->_line[i];
	for (j = pmincol, n = smincol; j <= pmaxcol; j++, n++) {
	    NCURSES_CH_T ch = oline->text[j];
#if USE_WIDEC_SUPPORT
	    /*
	     * Special case for leftmost character of the displayed area.
	     * Only half of a double-width character may be visible.
	     */
	    if (j == pmincol
		&& j > 0
		&& isWidecExt(ch)) {
		SetChar(ch, L(' '), AttrOf(oline->text[j - 1]));
	    }
#endif
	    if (!CharEq(ch, nline->text[n])) {
		nline->text[n] = ch;
		CHANGED_CELL(nline, n);
	    }
	}

#if USE_SCROLL_HINTS
	if (wide) {
	    int nind = m + displaced;
	    if (oline->oldindex < 0
		|| nind < sminrow
		|| nind > smaxrow) {
		nind = _NEWINDEX;
	    } else if (displaced) {
		register struct ldat *pline = &CurScreen(sp)->_line[nind];
		for (j = 0; j <= my_len; j++) {
		    int k = NewScreen(sp)->_maxx - j;
		    if (pline->text[j] != nline->text[j]
			|| pline->text[k] != nline->text[k]) {
			nind = _NEWINDEX;
			break;
		    }
		}
	    }

	    nline->oldindex = nind;
	}
#endif /* USE_SCROLL_HINTS */
	oline->firstchar = oline->lastchar = _NOCHANGE;
	if_USE_SCROLL_HINTS(oline->oldindex = i);
    }

    /*
     * Clean up debris from scrolling or resizing the pad, so we do not
     * accidentally pick up the index value during the next call to this
     * procedure.  The only rows that should have an index value are those
     * that are displayed during this cycle.
     */
#if USE_SCROLL_HINTS
    for (i = pminrow - 1; (i >= 0) && (win->_line[i].oldindex >= 0); i--)
	win->_line[i].oldindex = _NEWINDEX;
    for (i = pmaxrow + 1; (i <= win->_maxy)
	 && (win->_line[i].oldindex >= 0); i++)
	win->_line[i].oldindex = _NEWINDEX;
#endif

    win->_begx = smincol;
    win->_begy = sminrow;

    if (win->_clear) {
	win->_clear = FALSE;
	NewScreen(sp)->_clear = TRUE;
    }

    /*
     * Use the pad's current position, if it will be visible.
     * If not, don't do anything; it's not an error.
     */
    if (win->_leaveok == FALSE
	&& win->_cury >= pminrow
	&& win->_curx >= pmincol
	&& win->_cury <= pmaxrow
	&& win->_curx <= pmaxcol) {
	NewScreen(sp)->_cury = win->_cury - pminrow + win->_begy + win->_yoffset;
	NewScreen(sp)->_curx = win->_curx - pmincol + win->_begx;
    }
    NewScreen(sp)->_leaveok = win->_leaveok;
    win->_flags &= ~_HASMOVED;

    /*
     * Update our cache of the line-numbers that we displayed from the pad.
     * We will use this on subsequent calls to this function to derive
     * values to stuff into 'oldindex[]' -- for scrolling optimization.
     */
    win->_pad._pad_y = pminrow;
    win->_pad._pad_x = pmincol;
    win->_pad._pad_top = sminrow;
    win->_pad._pad_left = smincol;
    win->_pad._pad_bottom = smaxrow;
    win->_pad._pad_right = smaxcol;

    returnCode(OK);
}
Ejemplo n.º 12
0
NCURSES_PUBLIC_VAR(newscr) (void)
{
    return CURRENT_SCREEN ? NewScreen(CURRENT_SCREEN) : 0;
}
Ejemplo n.º 13
0
delscreen(SCREEN *sp)
{
    int i;

    T((T_CALLED("delscreen(%p)"), (void *) sp));

    _nc_lock_global(curses);
    if (delink_screen(sp)) {
#ifdef USE_SP_RIPOFF
	ripoff_t *rop;
	if (safe_ripoff_sp && safe_ripoff_sp != safe_ripoff_stack) {
	    for (rop = safe_ripoff_stack;
		 rop != safe_ripoff_sp && (rop - safe_ripoff_stack) < N_RIPS;
		 rop++) {
		if (rop->win) {
		    (void) delwin(rop->win);
		    rop->win = 0;
		}
	    }
	}
#endif

	(void) _nc_freewin(CurScreen(sp));
	(void) _nc_freewin(NewScreen(sp));
	(void) _nc_freewin(StdScreen(sp));

	if (sp->_slk != 0) {
	    if (sp->_slk->ent != 0) {
		for (i = 0; i < sp->_slk->labcnt; ++i) {
		    FreeIfNeeded(sp->_slk->ent[i].ent_text);
		    FreeIfNeeded(sp->_slk->ent[i].form_text);
		}
		free(sp->_slk->ent);
	    }
	    free(sp->_slk);
	    sp->_slk = 0;
	}

	_nc_free_keytry(sp->_keytry);
	sp->_keytry = 0;

	_nc_free_keytry(sp->_key_ok);
	sp->_key_ok = 0;

	FreeIfNeeded(sp->_current_attr);

	FreeIfNeeded(sp->_color_table);
	FreeIfNeeded(sp->_color_pairs);

	FreeIfNeeded(sp->oldhash);
	FreeIfNeeded(sp->newhash);
	FreeIfNeeded(sp->hashtab);

	FreeIfNeeded(sp->_acs_map);
	FreeIfNeeded(sp->_screen_acs_map);

	NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG);
	NCURSES_SP_NAME(del_curterm) (NCURSES_SP_ARGx sp->_term);
	free(sp);

	/*
	 * If this was the current screen, reset everything that the
	 * application might try to use (except cur_term, which may have
	 * multiple references in different screens).
	 */
	if (sp == CURRENT_SCREEN) {
#if !USE_REENTRANT
	    curscr = 0;
	    newscr = 0;
	    stdscr = 0;
	    COLORS = 0;
	    COLOR_PAIRS = 0;
#endif
	    _nc_set_screen(0);
	}
    }
    _nc_unlock_global(curses);

    returnVoid;
}
Ejemplo n.º 14
0
static void menu(void)
{   int failed = 0, readoption = 1, alwaysstop = 0, showhidden = 0;
    char prmptbuf[80];
    char *tmpstr, *option, *version_id;
    char *terms = " \n";

    strcpy( buffer, schemamenu_init );
    tmpstr = strtok( buffer, " " );
    tmpstr = strtok( NULL, " " );
    tmpstr = strtok( NULL, " " );
    version_id = heapstr( tmpstr );

    while( readoption )
    {  NewScreen();
       failed = 0;

       printf( "%s    Schema Mapping Environment. V%s\n",
               FORMAT_LINE, version_id);
       printf( "%s    ---------------------------------\n\n", FORMAT_LINE);

       printf( "%sl ......... load file [filename [language]]\n",
               FORMAT_LINE);
       printf( "%sb ......... browse\n", FORMAT_LINE);
       printf( "%sudtoum .... UDINST_UMINST mapper\n", FORMAT_LINE);
       printf( "%setov ...... ELLA_VHDL mapper\n", FORMAT_LINE);
       printf( "%setol ...... ELLA_LAYOUT mapper\n", FORMAT_LINE);
       printf( "%svtol ...... VHDL_LAYOUT mapper\n", FORMAT_LINE);
       printf( "%slp ........ LAYOUT_PRINT\n", FORMAT_LINE);
       printf( "%slw ........ LAYOUT_WRITE [filename]\n", FORMAT_LINE);
       printf( "%swpk ....... write packed dump [filename [language]]\n",
               FORMAT_LINE);
       printf( "%swup ....... write unpacked dump [filename [language]]\n",
               FORMAT_LINE);
       printf( "%sq ......... quit\n", FORMAT_LINE);
       if( showhidden )
       {
          printf( "%sids ....... print ids table\n", FORMAT_LINE);
          printf( "%spause ..... toggle the pause state\n", FORMAT_LINE);
          printf( "%shidden .... toggle the hidden state\n", FORMAT_LINE);
          printf( "%sdiag ...... print diagnostics [filename] \n",
                  FORMAT_LINE);

       }

       sprintf( prmptbuf, "\n%s> ", FORMAT_LINE);
       while(( tmpstr = prompt( prmptbuf, buffer )) == NULL ||
               *tmpstr == NULL ){};

       option = strtok( tmpstr, terms );     
       Capitalise( option);

       if( equal(option, "L") )
       {  theclosure = menu_load( strtok( NULL, terms ), strtok( NULL, terms ));
          if( ExternalclosureClosure( theclosure) == NULL ) failed = 1;
       }
       else if ( equal(option, "B") )
       {  failed = menu_browse();
       }
       else if ( equal(option, "WPK") )
       {  failed = menu_write( strtok( NULL, terms ),
                               strtok( NULL, terms ), 1 ); 
       }
       else if ( equal(option, "WUP") )
       {  failed = menu_write( strtok( NULL, terms ),
                               strtok( NULL, terms ), 0 ); 
       }
       else if (equal(option, "UDTOUM"))
       {  Transformer *udinst_uminst;

          imgtable = ELLA_InitTable();
          udinst_uminst=
          Make_udinst_uminst( MakeNullTransformer( objtable, imgtable));
          update_closure( Transform( ExternalclosureClosure( theclosure),
                                      udinst_uminst));
          objtable = imgtable;
       }
       else if (equal(option, "ETOV"))
       {  Transformer *ella_vif;

          imgtable = VIF_InitTable();
          ella_vif = make_ella_vif( MakeNullTransformer( objtable, imgtable));
          update_closure( Transform( ExternalclosureClosure( theclosure),
                                     ella_vif));
          objtable = imgtable;
       }
       else if (equal(option, "ETOL"))
       {  Transformer *ella_layout;

          imgtable = LAY_InitTable();
          ella_layout = 
                   make_ella_layout( MakeNullTransformer( objtable, imgtable));
          update_closure( Transform( ExternalclosureClosure( theclosure),
                                     ella_layout));
               objtable = imgtable;
       }
       else if (equal(option, "VTOL"))
       {  Transformer *vif_layout;

          imgtable = LAY_InitTable();
          vif_layout = 
                   make_vif_layout( MakeNullTransformer( objtable, imgtable));
          update_closure( Transform( ExternalclosureClosure( theclosure),
                                     vif_layout));
          objtable = imgtable;
       }
       else if (equal(option, "LP"))
       {  menu_layout( stdout );
          failed = 1; /* We have not really failed, but need to hold the screen
                      */
       }
       else if (equal(option, "LW"))
       {  failed = write_file( strtok( NULL, terms ));
       }
       else if (equal(option, "Q"))
       {  readoption = 0;
          alwaysstop = 0;
       }
       else if ( equal(option, "IDS") )
       {  print_idstable();
          failed = 1; /* We have not really failed, but need to hold the screen
                      */
       }
       else if ( equal(option, "HIDDEN") )
       {  showhidden = 1 - showhidden;
       }
       else if ( equal(option, "PAUSE") )
       {  alwaysstop = 1 - alwaysstop;
       }
       else if ( equal(option, "DIAG") )
       {  tmpstr = strtok( NULL, terms );
          if( tmpstr == NULL )
          {  assemdiagfile = stdout;
             alwaysstop = 1;
          }
          else
          {  assemdiagfile = fopen( tmpstr, "w" );
          }
       }
       else
       {  printf( "Option %s not recognised.\n", option );
          failed = 1;
       }

       if( failed || alwaysstop )
       {  prompt( "Press RETURN to continue > ", buffer );
       }
    }
}
Ejemplo n.º 15
0
/* Main Function */
int main(void){
	
	enum states{
		setup,
		drawing,
		readusart,
	} currentstate = setup;

	unsigned char STRING1[]="YAY THIS";
	unsigned char STRING2[]="WORKS!!!";
	unsigned char STR1CMP[9];
	unsigned char STR2CMP[9];
	unsigned char x, i, j;
	unsigned char send[50];
				
	while(1){
	
		switch(currentstate){
			case setup:
				initialize();
				clearArray();
				PORTB = 0b10000000;
				PORTC |= 0b10000000;
				ht1632_initialize();
				PORTC |= 0b01000000;
				InitializeUART();
				PORTC |= 0b00100000;
				
				sprintf(send, "Initialized...\n");
				PORTC |= 0b00010000;
				SendStringUART(send);
				_delay_ms(200);
				PORTC = 0;
				strcpy(STRING1, "YAY THIS");
				strcpy(STRING2, "WORKS!!!");
				currentstate = drawing;
				break;
			case drawing:
				for(x=1;x<sizeof(STRING1);x++) {
					null_buffer();
					for(i=0;i<8;i++){
						for(j=0;j<8;j++){
							set_buffer(STRING1[x-1]);
							if (~buffer[i][j] & (1<<0)) {
                                ht1632_plot(j+(8*(x-1))-1,i,GREEN);
								PORTC = ~PORTC;
							} else {
								ht1632_plot(j+(8*(x-1))-1,i,BLACK);
								PORTC = ~PORTC;
							}
						}
					}
				}
				for(x=1;x<sizeof(STRING2);x++) {
					null_buffer();
					for(i=0;i<8;i++){
						for(j=0;j<8;j++){
							set_buffer(STRING2[x-1]);
							if (~buffer[i][j] & (1<<0)) {
                                ht1632_plot(j+(8*(x-1))-1,i+8,GREEN);
								PORTC = ~PORTC;
							} else {
								ht1632_plot(j+(8*(x-1))-1,i+8,BLACK);
								PORTC = ~PORTC;
							}
						}
					}
				}
				PORTC = 0;
				currentstate = readusart;
				break;
			case readusart:
				strcpy(STR1CMP, STRING1);
				strcpy(STR2CMP, STRING2);
				NewScreen(STRING1, STRING2);
				
				if((strcmp(STRING1, "RESETRES") == 0)){
					currentstate = setup;
				}else if((strcmp(STRING1, STR1CMP) != 0) | (strcmp(STRING2, STR2CMP) != 0)){
					currentstate = drawing;
				}
				
				break;
		}
	}
}
Ejemplo n.º 16
0
wnoutrefresh(WINDOW *win)
{
    int limit_x;
    int src_row, src_col;
    int begx;
    int begy;
    int dst_row, dst_col;
#if USE_SCROLL_HINTS
    bool wide;
#endif
#if NCURSES_SP_FUNCS
    SCREEN *SP_PARM = _nc_screen_of(win);
#endif

    T((T_CALLED("wnoutrefresh(%p)"), (void *) win));
#ifdef TRACE
    if (USE_TRACEF(TRACE_UPDATE)) {
	_tracedump("...win", win);
	_nc_unlock_global(tracef);
    }
#endif /* TRACE */

    /*
     * This function will break badly if we try to refresh a pad.
     */
    if ((win == 0)
	|| (win->_flags & _ISPAD))
	returnCode(ERR);

    /* put them here so "win == 0" won't break our code */
    begx = win->_begx;
    begy = win->_begy;

    NewScreen(SP_PARM)->_nc_bkgd = win->_nc_bkgd;
    WINDOW_ATTRS(NewScreen(SP_PARM)) = WINDOW_ATTRS(win);

    /* merge in change information from all subwindows of this window */
    wsyncdown(win);

#if USE_SCROLL_HINTS
    /*
     * For pure efficiency, we'd want to transfer scrolling information
     * from the window to newscr whenever the window is wide enough that
     * its update will dominate the cost of the update for the horizontal
     * band of newscr that it occupies.  Unfortunately, this threshold
     * tends to be complex to estimate, and in any case scrolling the
     * whole band and rewriting the parts outside win's image would look
     * really ugly.  So.  What we do is consider the window "wide" if it
     * either (a) occupies the whole width of newscr, or (b) occupies
     * all but at most one column on either vertical edge of the screen
     * (this caters to fussy people who put boxes around full-screen
     * windows).  Note that changing this formula will not break any code,
     * merely change the costs of various update cases.
     */
    wide = (begx <= 1 && win->_maxx >= (NewScreen(SP_PARM)->_maxx - 1));
#endif

    win->_flags &= ~_HASMOVED;

    /*
     * Microtweaking alert!  This double loop is one of the genuine
     * hot spots in the code.  Even gcc doesn't seem to do enough
     * common-subexpression chunking to make it really tense,
     * so we'll force the issue.
     */

    /* limit(dst_col) */
    limit_x = win->_maxx;
    /* limit(src_col) */
    if (limit_x > NewScreen(SP_PARM)->_maxx - begx)
	limit_x = NewScreen(SP_PARM)->_maxx - begx;

    for (src_row = 0, dst_row = begy + win->_yoffset;
	 src_row <= win->_maxy && dst_row <= NewScreen(SP_PARM)->_maxy;
	 src_row++, dst_row++) {
	struct ldat *nline = &(NewScreen(SP_PARM)->_line[dst_row]);
	struct ldat *oline = &win->_line[src_row];

	if (oline->firstchar != _NOCHANGE) {
	    int last_src = oline->lastchar;

	    if (last_src > limit_x)
		last_src = limit_x;

	    src_col = oline->firstchar;
	    dst_col = src_col + begx;

	    if_WIDEC({
		int j;

		/*
		 * Ensure that we will copy complete multi-column characters
		 * on the left-boundary.
		 */
		if (isWidecExt(oline->text[src_col])) {
		    j = 1 + dst_col - WidecExt(oline->text[src_col]);
		    if (j < 0)
			j = 0;
		    if (dst_col > j) {
			src_col -= (dst_col - j);
			dst_col = j;
		    }
		}

		/*
		 * Ensure that we will copy complete multi-column characters
		 * on the right-boundary.
		 */
		j = last_src;
		if (WidecExt(oline->text[j])) {
		    ++j;
		    while (j <= limit_x) {
			if (isWidecBase(oline->text[j])) {
			    break;
			} else {
			    last_src = j;
			}
			++j;
		    }
		}
	    });

	    if_WIDEC({
		static cchar_t blank = BLANK;
		int last_dst = begx + ((last_src < win->_maxx)
				       ? last_src
				       : win->_maxx);
		int fix_left = dst_col;
		int fix_right = last_dst;
		int j;

		/*
		 * Check for boundary cases where we may overwrite part of a
		 * multi-column character.  For those, wipe the remainder of
		 * the character to blanks.
		 */
		j = dst_col;
		if (isWidecExt(nline->text[j])) {
		    /*
		     * On the left, we only care about multi-column characters
		     * that extend into the changed region.
		     */
		    fix_left = 1 + j - WidecExt(nline->text[j]);
		    if (fix_left < 0)
			fix_left = 0;	/* only if cell is corrupt */
		}

		j = last_dst;
		if (WidecExt(nline->text[j]) != 0) {
		    /*
		     * On the right, any multi-column character is a problem,
		     * unless it happens to be contained in the change, and
		     * ending at the right boundary of the change.  The
		     * computation for 'fix_left' accounts for the left-side of
		     * this character.  Find the end of the character.
		     */
		    ++j;
		    while (j <= NewScreen(SP_PARM)->_maxx &&
			   isWidecExt(nline->text[j])) {
			fix_right = j++;
		    }
		}

		/*
		 * The analysis is simpler if we do the clearing afterwards.
		 * Do that now.
		 */
		if (fix_left < dst_col || fix_right > last_dst) {
		    for (j = fix_left; j <= fix_right; ++j) {
			nline->text[j] = blank;
			CHANGED_CELL(nline, j);
		    }
		}
	    });