void backword( unsigned int *x ) { int i; i = *x + firstcol + 1; if ( i != 1 ) { /* first column ? */ if ( ( !ISBLANK( workline.middle[i] ) ) && ( !ISBLANK( workline.middle[i - 1] ) ) ) { while ( ( !ISBLANK( workline.middle[i] ) ) && ( i > 0 ) ) { i--; } } else { if ( ISBLANK( workline.middle[i - 1] ) ) { i--; } while ( ISBLANK( workline.middle[i] ) && ( i > 0 ) ) { i--; } while ( !ISBLANK( workline.middle[i] ) && ( i > 0 ) ) { i--; } } gocol( i, x ); if ( ( i == 0 ) && ( ISBLANK( workline.middle[1] ) ) ) { backword( x ); } } else { if ( curline->previous != sentinel ) { cursor_up( ); endline( x ); } } }
void cursor_left( unsigned *x ) { unsigned i = *x + firstcol; if ( i != 0 ) { /* Home of line ? */ gocol( i - 1, x ); } else { if ( curline->previous != sentinel ) { cursor_up( ); /* go to end of */ endline( x ); /* previous line */ } } }
void cursor_left( unsigned int *p_xCursorPos ) { unsigned int i = *p_xCursorPos + firstcol; if ( i != 0 ) { /* Home of line ? */ gocol( i - 1, p_xCursorPos ); } else { if ( curline->previous != sentinel ) { cursor_up( ); /* go to end of */ endline( p_xCursorPos ); /* previous line */ } } }
void movetotab(unsigned *x,unsigned y) { int i,count; if ((*x + firstcol) >= (leftmar - 1)) { i = *x + firstcol + 1; } else { i = leftmar - 1; } for(;(tab[i] != YES) && (i < (rightmar-1));i++); if (i < (rightmar - 1)) { count = i - (*x + firstcol); while (count-- != 0) { if (insertmode) insertblank(*x + firstcol + 1,' '); } gocol(i,x); refreshline(0,y); } }
void nextword( unsigned int *x, unsigned int y ) { int i, j; i = *x + firstcol + 1; j = i; while ( !ISBLANK( workline.middle[i] ) && ( i != MAXCOL ) ) { i++; } while ( ISBLANK( workline.middle[i] ) && ( i != MAXCOL ) ) { i++; } if ( i != MAXCOL ) { i--; gocol( i, x ); } else { endline( x ); if ( ( *x + firstcol + 1 ) <= j ) { cursor_down( y ); home( x ); if ( ISBLANK( workline.middle[1] ) ) { nextword( x, y ); } } } }
void endline( unsigned int *x ) { gocol( strlen( workline.middle ) - 1, x ); }
void goendblk( unsigned int *x ) { if ( haveblock( ) ) { goline( blkend.lineno ); gocol( blkend.column, x ); } }
void gobeginblk( unsigned int *x ) { if ( haveblock( ) ) { goline( blkbegin.lineno ); gocol( blkbegin.column, x ); } }
void autowrap( unsigned int *x, unsigned int *y ) { unsigned int i, j, already = NO, diff; char *temp1, *temp3, *cuthere, fontcode[9]; font_attr font = 0; struct line_node *templine; storeline( curline ); diff = strlen( workline.middle ) - ( *x + firstcol + 1 ); i = 0; j = 0; while ( curline->text[i] != '\0' ) { if ( curline->text[i] != WRAPBLANK ) { curline->text[j] = curline->text[i]; j++; already = YES; } else { if ( already == NO ) { curline->text[j] = curline->text[i]; j++; } } i++; } curline->text[j] = '\0'; temp1 = curline->text; for ( i = rightmar - 2; ( i > 0 ) && ( *temp1 != '\0' ); i-- ) { temp1++; while ( whatlevel( *temp1 ) != MIDDLE ) { temp1++; } } temp3 = temp1; for ( i = 10; ( i != 0 ) && ( *temp3 != '\0' ); i-- ) { temp3++; } cuthere = FINDCUT( curline->text, temp3, temp1 ); cuthere++; for ( temp1 = curline->text; temp1 != cuthere; temp1++ ) { if ( *temp1 < 32 ) { togglefont( &font, *temp1 ); } } findstrcode( fontcode, font ); templine = ( struct line_node * ) malloc( sizeof( struct line_node ) ); templine->text = ( char * ) malloc( leftmar + strlen( fontcode ) + strlen( cuthere ) ); for ( i = 0; i != ( leftmar - 1 ); i++ ) { templine->text[i] = WRAPBLANK; } templine->text[i] = '\0'; strcat( templine->text, fontcode ); strcat( templine->text, cuthere ); templine->graph = NULL; templine->wrap = ( curline->next )->wrap; *cuthere = '\0'; temp3 = ( char * ) malloc( strlen( curline->text ) + strlen( fontcode ) + 1 ); strcpy( temp3, curline->text ); strcat( temp3, fontcode ); free( curline->text ); curline->text = temp3; templine->next = curline->next; ( curline->next )->previous = templine; templine->previous = curline; curline->next = templine; curline->wrap = YES; loadtoline( curline->text ); justify_right( ); *y = findrow( ); cursor_down( *y ); firstcol = 0; gocol( strlen( workline.middle ) - 1 - diff, x ); pagecomplete = NO; }