void set_all_lineperpage(set_linespace_mode mode) { char *find_lineperinch(void); static char m1[] = "¨Ó¹Ç¹ºÃ÷ѴµèÍ˹éÒäÁè¾Í " "à¤Ã×èͧ¨Ðà»ÅÕè¹ãËéà»ç¹¨Ó¹Ç¹ÊÙ§ÊØ´à·èÒ·Õè¨ÐÂÍÁä´é"; static char m2[] = "¡´»ØèÁ ESC à¾×èÍ·Ó§Ò¹µèÍä»"; if (userlineperpage > find_max_userline_perpage()) { userlineperpage = find_max_userline_perpage(); if (mode == INTERACTIVE) { savepic(); framebox(10, 8, 10+thaistrlen(m1)+4, 11, REVERSEATTR); dispstrhgc(m1, 10+2, 9, REVERSEATTR); dispstrhgc(m2, 10+ (thaistrlen(m1)+4 - thaistrlen(m2)) / 2, 10, REVERSEATTR); while (ebioskey(0) != ESCKEY) ; retpic(); writemenu(0, 1, 0); /* show new userline per page */ } } lineperpage = find_line_perpage(); if (mode == INTERACTIVE) { savepic(); /*" "*/ dispprintf(19,12,0, "¨Ó¹Ç¹ºÃ÷ѴµèÍ¡ÃдÒÉ 1 ¹ÔéÇ ¤×Í : %s ºÃ÷Ѵ/¹ÔéÇ", find_lineperinch()); ebioskey(0); retpic(); } }
void manualwrap( unsigned int *x, unsigned int *y ) { int i; insert_ret( x ); curline->wrap = YES; *x = ( leftmar - 1 ) + ( *x - thaistrlen( curline->text ) ); justify_right( ); *y = findrow( ); cursor_down( *y ); for ( i = 1; i != leftmar; i++ ) { workline.middle[i] = WRAPBLANK; } }
int getstring(char textst[],unsigned x,unsigned y,unsigned maxlen,char attr,strtype mode) { int inkey,key,oldlen,temp; char keepchar; keepchar = '\0'; oldlen = strlen(textst); dispblank(x,y,maxlen,attr); dispstrhgc(textst,x,y,attr); waitkbd(x+thaistrlen(textst),y); switch(mode) { case THAIENG : inkey = readkbd(); break; case NUMBER : case ONEORTWO : case ENGLISH : inkey = bioskey(0); break; case ENGUPCASE : inkey = bioskey(0); key = inkey & 0xff; if ((key >= 'a') && (key <= 'z')) inkey = key - ('a' - 'A'); break; } switch (inkey) { case CNTRL_H : case BSKEY : case CNTRL_S : case LEKEY : case CNTRL_M : case RETKEY : break; default : key = inkey & 0xff; if (mode == NUMBER) { if ((key < '0') || (key > '9')) break; } if (mode == ONEORTWO) { if ((key != '1') && (key != '2')) break; } if ((inkey & 0xff) >= 32) { textst[0] = '\0'; dispblank(x,y,maxlen,attr); } break; } do { switch(inkey){ case CNTRL_M : case RETKEY : return(YES); case CNTRL_U : return(NO); /* Abort */ case ESCKEY : return(ESCKEY); case UPKEY : return(UPKEY); case DNKEY : return(DNKEY); case CNTRL_H : case BSKEY : case LEKEY : case CNTRL_S : temp = strlen(textst); if (temp != 0){ if (temp < oldlen) textst[temp] = keepchar; keepchar = textst[temp-1]; textst[temp-1] = '\0'; dispblank(x,y,maxlen,attr); dispstrhgc(textst,x,y,attr); } break; case RIKEY : case CNTRL_D : temp = strlen(textst); if ((temp < oldlen) && (temp < maxlen)){ textst[temp] = keepchar; keepchar = textst[temp+1]; textst[temp+1] = '\0'; dispblank(x,y,maxlen,attr); dispstrhgc(textst,x,y,attr); } break; case CNTRL_Y : if (strlen(textst) < oldlen) textst[strlen(textst)] = keepchar; keepchar = textst[0]; textst[0] = '\0'; dispblank(x,y,maxlen,attr); break; case CNTRL_R : if (strlen(textst) < oldlen){ textst[strlen(textst)] = keepchar; dispblank(x,y,maxlen,attr); dispstrhgc(textst,x,y,attr); } break; /* case F10KEY : thaimode = !thaimode; writelanguage(); break; */ default : inkey = (inkey & 0xff); if (mode == NUMBER) { if ((inkey < '0') || (inkey > '9')) break; } if (mode == ONEORTWO) { if ((inkey != '1') && (inkey != '2')) break; } if (inkey >= 32) { if (strlen(textst) < maxlen) { if (whatlevel(inkey) == MIDDLE) { textst[strlen(textst)+1] = '\0'; textst[strlen(textst)] = inkey; oldlen = strlen(textst); dispblank(x,y,maxlen,attr); dispstrhgc(textst,x,y,attr); } else { if ((strlen(textst) != 0) && (whatlevel(inkey) > whatlevel(textst[strlen(textst)-1])) && (inkey != HUNAKADMITO)) { textst[strlen(textst)+1] = '\0'; textst[strlen(textst)] = inkey; oldlen = strlen(textst); dispblank(x,y,maxlen,attr); dispstrhgc(textst,x,y,attr); } } } } break; } waitkbd(x+thaistrlen(textst),y); switch(mode) { case THAIENG : inkey = readkbd(); break; case NUMBER : case ONEORTWO : case ENGLISH : inkey = bioskey(0); break; case ENGUPCASE : inkey = bioskey(0); key = inkey & 0xff; if ((key >= 'a') && (key <= 'z')) inkey = key - ('a' - 'A'); break; } } while(1); }
/* ThaiWidth2Pixel (count,start_text), Height2Pixel (1), 0) */ int ThaiWidth2Pixel (int c, unsigned char *start) { return thaistrlen(start, start+c)*TermWin.fwidth; }
/* int ThaiCol2Pixel(c, &screen.text[roffset]); */ int ThaiCol2Pixel(int c, unsigned char *start) { return thaistrlen(start, start+c)*TermWin.fwidth + TermWin_internalBorder; }
void reform( void ) { struct line_node *templine, *firstline, *freeline; unsigned char *temp1, *temp2, *temp3, *cuthere; unsigned int i, j; font_attr font = 0; char fontcode[9]; storeline( curline ); firstline = curline; templine = firstline; /* start to concatenate all lines to one line only */ temp1 = ( char * ) malloc( 1 ); *temp1 = '\0'; while ( 1 ) { temp2 = ( char * ) malloc( strlen( templine->text ) + 1 ); i = 0; j = 0; while ( templine->text[i] != '\0' ) { if ( templine->text[i] != WRAPBLANK ) { temp2[j] = templine->text[i]; j++; } i++; } temp2[j] = '\0'; temp3 = ( char * ) malloc( strlen( temp1 ) + strlen( temp2 ) + 1 ); strcpy( temp3, temp1 ); strcat( temp3, temp2 ); free( temp1 ); free( temp2 ); if ( templine->wrap == NO ) break; temp1 = temp3; templine = templine->next; } /* now paragraph is in the one line only pointed by temp3 */ /* so we will compress two or more blanks to one blank only */ compress_blank( temp3 ); templine->previous = firstline->previous; ( templine->previous )->next = templine; free( templine->text ); templine->text = temp3; if ( curline == curpage ) { curpage = templine; } curline = templine; while ( firstline != templine ) { freeline = firstline; firstline = firstline->next; free( freeline->text ); if ( freeline->graph != NULL ) { free( freeline->graph ); } free( freeline ); } while ( thaistrlen( curline->text ) > ( rightmar - leftmar + 1 ) ) { i = rightmar - leftmar; /* + 1; */ temp1 = curline->text; while ( ( i != 0 ) && ( *temp1 != '\0' ) ) { for ( temp1++; whatlevel( *temp1 ) != MIDDLE; temp1++ ); i--; } temp3 = temp1; for ( i = 10; ( i != 0 ) && ( *temp3 != '\0' ); i-- ) { temp3++; } cuthere = FINDCUT( curline->text, temp3, temp1 ); cuthere++; font = 0; 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( strlen( fontcode ) + strlen( cuthere ) + 1 ); templine->wrap = NO; templine->graph = NULL; strcpy( templine->text, fontcode ); strcat( templine->text, cuthere ); *cuthere = '\0'; temp3 = ( char * ) malloc( leftmar + strlen( curline->text ) + strlen( fontcode ) ); i = 0; while ( i != ( leftmar - 1 ) ) { temp3[i] = WRAPBLANK; i++; } temp3[i] = '\0'; strcat( 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( ); storeline( curline ); curline = curline->next; } temp3 = ( char * ) malloc( strlen( curline->text ) + leftmar ); i = 0; while ( i != ( leftmar - 1 ) ) { temp3[i] = WRAPBLANK; i++; } temp3[i] = '\0'; strcat( temp3, curline->text ); free( curline->text ); curline->text = temp3; if ( curline->next != sentinel ) { curline = curline->next; } lineno = findlineno( curline ); loadtoline( curline->text ); while ( findrow( ) > ( wind.width - 1 ) ) { curpage = curpage->next; } changeflag = YES; pagecomplete = NO; blkbegin.lineno = 1; blkend.lineno = 1; blkbegin.column = 0; blkend.column = 0; }