diff options
author | FreeArtMan <dos21h@gmail.com> | 2015-01-08 21:21:23 +0900 |
---|---|---|
committer | FreeArtMan <dos21h@gmail.com> | 2015-01-08 21:21:23 +0900 |
commit | ad222a30782ebacacd0f5388f01b65fa61e12697 (patch) | |
tree | 861e83d3214929fe7d58a0d79dcb0e069bb32b16 /libterm/print_utils.c | |
parent | 3d489fe502178d2d4e58eb8d5736be2fbda38077 (diff) | |
download | microbbs-ad222a30782ebacacd0f5388f01b65fa61e12697.tar.gz microbbs-ad222a30782ebacacd0f5388f01b65fa61e12697.zip |
Fixed positioning for captcha, motd, mainmenu, sysinfo
Diffstat (limited to 'libterm/print_utils.c')
-rw-r--r-- | libterm/print_utils.c | 122 |
1 files changed, 0 insertions, 122 deletions
diff --git a/libterm/print_utils.c b/libterm/print_utils.c deleted file mode 100644 index 9d4bac0..0000000 --- a/libterm/print_utils.c +++ /dev/null @@ -1,122 +0,0 @@ -#include "print_utils.h" - -int term_fprint( screen_mode_e mode, FILE *f ) -{ - int ret=-1; - if (f == NULL) - return -1; - - switch ( mode ) - { - case SCREEN_MODE_80x24: - { - /* - const int m_x=80,m_y=24; - int x=0,y=0; - int fret=1; - char c; - while ((fret = fread(&c,1,1,f)) == 1) - { - if ( c != '\n' ) - { - if ( (x < m_x) && (y < m_y) ) - { - putc( c ); - } - x+=1; - } else if ( c == '\n' ) - { - x = 0; - y += 1; - } - } - */ - } - break; - default: - printf("Unknown screen mode\n"); - } - - return ret; -} - - -//print data to terminal starting from x,y -//return 0x0000yyyy0000xxxx, current stopped position -int term_print( term_screen *ts, const char *buf, size_t size, - int init_x, int init_y ) -{ - int posx=0, posy=0; - int ret=-1; - if ( buf == NULL ) - { - return -1; - } - - if ( size <= 0 ) - { - return -1; - } - - //calculate position - //fix for diff modes also needed - if ( ts->term_col > 80) - { - posx = (ts->term_col-80)/2; - } - if (ts->term_row > 24) - { - posy = (ts->term_row-24)/2; - } - - switch ( ts->mode ) - { - case SCREEN_MODE_80x24: - { - int m_x=80, m_y=24; - int x=init_x, y=init_y; - char c; - int i,j; - - - if (( init_x == 0 ) && (init_y == 0)) - { - for (i=0; i<posx;i++) - printf(" "); - } - - //draw image according to mode - for (i=0; i<size; i++) - { - c = buf[i]; - if ( c == '\n' ) - { - printf("\n"); - //set - for (j=0; j<posx; j++) - printf(" "); - x = 0; - y += 1; - //printf("asdasdsad\n"); - } else if ( c != '\n' ) - { - if ( (x < m_x ) && (y < m_y) ) - { - printf("%c",c); - } - x += 1; - } - } - ret = x&0x0000ffff | ((y&0x0000ffff)<<16); - //printf( "%08x\n", ret ); - } - break; - default: - printf("Unknown mode\n"); - } - - return ret; -} - - - |