Changeset 899
- Timestamp:
- 06/04/10 08:48:34 (3 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
-
core/gui.c (modified) (1 diff)
-
core/luascript.c (modified) (2 diffs)
-
core/script.c (modified) (8 diffs)
-
include/script.h (modified) (3 diffs)
-
lib/ubasic/camera_functions.c (modified) (1 diff)
-
lib/ubasic/tokenizer.c (modified) (1 diff)
-
lib/ubasic/tokenizer.h (modified) (1 diff)
-
lib/ubasic/ubasic.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/core/gui.c
r888 r899 2163 2163 --show_script_console; 2164 2164 md_draw_grid(); 2165 script_console_draw( );2165 script_console_draw(auto_redraw); 2166 2166 } 2167 2167 } -
trunk/core/luascript.c
r865 r899 67 67 } 68 68 69 static int luaCB_set_console_layout( lua_State* L ) 70 { 71 script_console_set_layout(luaL_checknumber( L, 1 ),luaL_checknumber( L, 2 ),luaL_checknumber( L, 3 ),luaL_checknumber( L, 4 )); 72 return 0; 73 } 74 75 static int luaCB_set_console_autoredraw( lua_State* L ) 76 { 77 script_console_set_autoredraw(luaL_checknumber( L, 1 )); 78 return 0; 79 } 80 81 static int luaCB_console_redraw( lua_State* L ) 82 { 83 script_console_redraw(); 84 return 0; 85 } 69 86 static int luaCB_get_av96( lua_State* L ) 70 87 { … … 1288 1305 FUNC(sleep); 1289 1306 FUNC(cls); 1307 FUNC(set_console_layout); 1308 FUNC(set_console_autoredraw); 1309 FUNC(console_redraw); 1290 1310 1291 1311 lua_pushlightuserdata( L, kbd_sched_click ); -
trunk/core/script.c
r871 r899 10 10 //------------------------------------------------------------------- 11 11 12 #define SCRIPT_CONSOLE_NUM_LINES 5 13 #define SCRIPT_CONSOLE_LINE_LENGTH 25 14 #define SCRIPT_CONSOLE_X 0 15 #define SCRIPT_CONSOLE_Y (14-SCRIPT_CONSOLE_NUM_LINES) 12 #define SCRIPT_MAX_CONSOLE_LINES 14 13 #define SCRIPT_MAX_LINE_LENGTH 45 16 14 17 15 //------------------------------------------------------------------- … … 19 17 char cfg_name[100] = "\0"; 20 18 char cfg_set_name[100] = "\0"; 19 int script_console_num_lines, script_console_line_length, script_console_x, script_console_y, auto_redraw=1; 21 20 22 21 static const char *ubasic_script_default = … … 76 75 static char script_params_update[SCRIPT_NUM_PARAMS]; 77 76 static int script_loaded_params[SCRIPT_NUM_PARAMS]; 78 static char script_console_buf[SCRIPT_CONSOLE_NUM_LINES][SCRIPT_CONSOLE_LINE_LENGTH+1]; 77 //static char script_console_buf[script_console_num_lines][script_console_line_length+1]; 78 static char **script_console_buf; 79 79 static int script_con_start_line=0; // oldest valid line in console 80 80 static int script_con_num_lines=0; // number of valid lines … … 322 322 struct stat st; 323 323 324 auto_redraw=1; 325 script_console_num_lines=5; 326 script_console_line_length=25; 327 script_console_y=SCRIPT_MAX_CONSOLE_LINES-script_console_num_lines; 328 script_console_x=0; 329 script_console_buf=malloc(script_console_num_lines*sizeof(char*)); 330 for (i=0;i<script_console_num_lines;i++){ 331 script_console_buf[i]=malloc(script_console_line_length*sizeof(char)+1); 332 } 333 script_con_start_line=0; 334 script_con_num_lines=0; 335 324 336 // save_params_values(0); 325 337 … … 394 406 register int i; 395 407 396 for (i=0; i< SCRIPT_CONSOLE_NUM_LINES; ++i) {408 for (i=0; i<script_console_num_lines; ++i) { 397 409 script_console_buf[i][0]=0; 398 410 } 399 411 script_con_num_lines=script_con_start_line=0; 400 draw_restore();412 if(auto_redraw) draw_restore(); 401 413 } 402 414 403 415 //------------------------------------------------------------------- 404 416 static inline int script_con_line_index(int i) { 405 return i%SCRIPT_CONSOLE_NUM_LINES; 406 } 407 408 void script_console_draw() { 409 int i,c,l; 417 return i%script_console_num_lines; 418 } 419 420 void script_console_draw(int drawing) { 421 int i,c,l; 422 if(drawing){ 410 423 for(c = 0; c < script_con_num_lines; ++c) { 411 i=script_con_line_index(script_con_start_line+c); 412 l=strlen(script_console_buf[i]); 413 draw_txt_string(SCRIPT_CONSOLE_X, SCRIPT_CONSOLE_Y+SCRIPT_CONSOLE_NUM_LINES-script_con_num_lines+c, script_console_buf[i], MAKE_COLOR(COLOR_BG, COLOR_FG)); 414 for (; l<SCRIPT_CONSOLE_LINE_LENGTH; ++l) 415 draw_txt_char(SCRIPT_CONSOLE_X+l, SCRIPT_CONSOLE_Y+SCRIPT_CONSOLE_NUM_LINES-script_con_num_lines+c, ' ', MAKE_COLOR(COLOR_BG, COLOR_FG)); 416 } 424 i=script_con_line_index(script_con_start_line+c); 425 l=strlen(script_console_buf[i]); 426 draw_txt_string(script_console_x, script_console_y+script_console_num_lines-script_con_num_lines+c, script_console_buf[i], MAKE_COLOR(COLOR_BG, COLOR_FG)); 427 for (; l<script_console_line_length; ++l) 428 draw_txt_char(script_console_x+l, script_console_y+script_console_num_lines-script_con_num_lines+c, ' ', MAKE_COLOR(COLOR_BG, COLOR_FG)); 429 } 430 } 417 431 } 418 432 … … 464 478 //------------------------------------------------------------------- 465 479 void script_console_start_line() { 466 if ( SCRIPT_CONSOLE_NUM_LINES==script_con_num_lines) {480 if (script_console_num_lines==script_con_num_lines) { 467 481 script_con_start_line=script_con_line_index(script_con_start_line+1); 468 482 } … … 481 495 cur = script_console_buf[script_con_line_index(script_con_start_line+script_con_num_lines-1)]; 482 496 curlen = strlen(cur); 483 left = SCRIPT_CONSOLE_LINE_LENGTH-curlen;497 left = script_console_line_length-curlen; 484 498 if(strlen(str) > left) { 485 499 strncpy(cur+curlen,str,left); 486 cur[ SCRIPT_CONSOLE_LINE_LENGTH]=0;500 cur[script_console_line_length]=0; 487 501 script_console_start_line(); 488 502 str+=left; … … 504 518 write(print_screen_d, &nl, 1); 505 519 } 506 script_console_draw(); 507 } 508 //------------------------------------------------------------------- 509 //------------------------------------------------------------------- 510 //------------------------------------------------------------------- 520 script_console_draw(auto_redraw); 521 } 522 //------------------------------------------------------------------- 523 void script_console_set_layout(int x1, int y1, int x2, int y2) { //untere linke Ecke(x1,y1), obere reche Ecke(x2,y2) - lower left corner (x1,y1), upper right corner(x2,y2) 524 int i,len,newLinesCount,newLineLength,newNumLines,lineDelta,idx; 525 char **tmp; 526 if(x1>=0 && x1<x2 && x1<=SCRIPT_MAX_LINE_LENGTH && y1>=0 && y1<y2 && y1<=SCRIPT_MAX_CONSOLE_LINES && x2<=SCRIPT_MAX_LINE_LENGTH && y2<=SCRIPT_MAX_CONSOLE_LINES) { 527 //In neuen Puffer kopieren - copy to new buffer 528 newLineLength=x2-x1; 529 newLinesCount=y2-y1; 530 if(newLineLength!=script_console_line_length || newLinesCount!=script_console_num_lines) { 531 lineDelta=script_con_num_lines-newLinesCount; 532 if(lineDelta<0) lineDelta=0; 533 newNumLines=0; 534 tmp=malloc(newLinesCount*sizeof(char*)); //realloc Nachbildung - realloc emulation 535 for(i=0;i<newLinesCount;i++){ 536 tmp[i]=malloc(newLineLength*sizeof(char)+1); 537 if(i<script_con_num_lines){ 538 newNumLines++; 539 idx=script_con_line_index(script_con_start_line+i+lineDelta); 540 len=strlen(script_console_buf[idx]); 541 if(len>newLineLength) len=newLineLength; 542 strncpy(tmp[i],script_console_buf[idx],len); 543 tmp[i][len]=0x0; 544 } else tmp[i][0]=0x0; 545 } 546 //Speicher freigeben - free memory 547 for(i=0;i<script_console_num_lines;i++) { 548 free(script_console_buf[i]); 549 } 550 free(script_console_buf); 551 //neue Werte setzten - set new values 552 script_console_buf=tmp; 553 script_con_start_line=0; 554 script_con_num_lines=newNumLines; 555 script_console_num_lines=newLinesCount; 556 script_console_line_length=newLineLength; 557 } 558 script_console_x=x1; 559 script_console_y=SCRIPT_MAX_CONSOLE_LINES-y2; 560 if(auto_redraw) draw_restore(); 561 } 562 } 563 //------------------------------------------------------------------- 564 void script_console_set_autoredraw(int value){ 565 auto_redraw=value; 566 } 567 //------------------------------------------------------------------- 568 void script_console_redraw(){ 569 draw_restore(); 570 script_console_draw(1); 571 } 572 //------------------------------------------------------------------- -
trunk/include/script.h
r515 r899 13 13 extern char script_params[SCRIPT_NUM_PARAMS][28]; 14 14 extern int script_param_order[SCRIPT_NUM_PARAMS]; 15 extern int auto_redraw; 15 16 16 17 //------------------------------------------------------------------- … … 18 19 extern void script_console_clear(); 19 20 extern void script_console_add_line(const char *str); 20 extern void script_console_draw( );21 extern void script_console_draw(int drawing); 21 22 extern void script_print_screen_init(); 22 23 extern void script_print_screen_end(); … … 24 25 extern int load_params_values(const char *fn, int update_vars, int read_param_set); 25 26 extern void save_params_values(int unconditional); 27 extern void script_console_set_layout(int x1, int y1, int x2, int y2); 28 extern void script_console_set_autoredraw(int value); 29 extern void script_console_redraw(); 26 30 //------------------------------------------------------------------- 27 31 #endif -
trunk/lib/ubasic/camera_functions.c
r847 r899 133 133 } 134 134 135 void script_console_set_layout(int x1, int y1, int x2, int y2) { 136 printf(">>> set console layout to %d %d %d %d\n", x1,y1,x2,y2); 137 } 138 139 void script_console_set_autoredraw(int value) { 140 printf(">>> set console auto_redraw to %d\n", x1); 141 } 142 143 void script_console_redraw() { 144 printf("*** console redraw ***\n"); 145 } 146 135 147 void script_console_clear() { 136 148 printf("*** clear console ***\n"); -
trunk/lib/ubasic/tokenizer.c
r854 r899 98 98 //{"shot", TOKENIZER_SHOOT}, // for compatibility 99 99 {"shoot", TOKENIZER_SHOOT}, 100 {"set_console_layout", TOKENIZER_SET_CONSOLE_LAYOUT}, 101 {"set_console_autoredraw", TOKENIZER_SET_CONSOLE_AUTOREDRAW}, 102 {"console_redraw", TOKENIZER_CONSOLE_REDRAW}, 100 103 {"sleep", TOKENIZER_SLEEP}, 101 104 -
trunk/lib/ubasic/tokenizer.h
r847 r899 91 91 TOKENIZER_RELEASE, 92 92 TOKENIZER_SHOOT, 93 TOKENIZER_SET_CONSOLE_LAYOUT, 94 TOKENIZER_SET_CONSOLE_AUTOREDRAW, 95 TOKENIZER_CONSOLE_REDRAW, 93 96 TOKENIZER_GET_TV96, 94 97 TOKENIZER_GET_USER_TV96, -
trunk/lib/ubasic/ubasic.c
r883 r899 362 362 #elif CAM_PROPSET == 3 363 363 r = 3; 364 #elif CAM_PROPSET == 3 365 r = 3; 364 366 #endif 365 367 break; … … 1465 1467 accept_cr(); 1466 1468 } 1467 1469 /*---------------------------------------------------------------------------*/ 1470 static void set_console_layout(void) 1471 { 1472 int x1,y1,x2,y2; 1473 accept(TOKENIZER_SET_CONSOLE_LAYOUT); 1474 x1 = expr(); 1475 y1 = expr(); 1476 x2 = expr(); 1477 y2 = expr(); 1478 script_console_set_layout(x1,y1,x2,y2); 1479 accept_cr(); 1480 } 1481 /*---------------------------------------------------------------------------*/ 1482 static void set_console_autoredraw(void) 1483 { 1484 accept(TOKENIZER_SET_CONSOLE_AUTOREDRAW); 1485 script_console_set_autoredraw(expr()); 1486 accept_cr(); 1487 } 1488 /*---------------------------------------------------------------------------*/ 1489 static void console_redraw(void) 1490 { 1491 accept(TOKENIZER_CONSOLE_REDRAW); 1492 script_console_redraw(); 1493 accept_cr(); 1494 } 1468 1495 /*---------------------------------------------------------------------------*/ 1469 1496
Note: See TracChangeset
for help on using the changeset viewer.