int oznkeyhit(void) { static unsigned c; for(;;) { if(!ozkeyhit()) return 0; c=ozgetch(); switch(c) { case KEY_POWER: case KEY_MAIN: case KEY_TELEPHONE: case KEY_SCHEDULE: ozexitto(c); case KEY_MYPROGRAMS: exit(0); case KEY_BACKLIGHT: oztogglelight(); break; default: ozungetch(c); return 1; } } }
unsigned ozngetch(void) { static unsigned c; for(;;) { switch(c=ozgetch()) { case KEY_POWER: case KEY_MAIN: case KEY_TELEPHONE: case KEY_MEMO: case KEY_SCHEDULE: ozexitto(c); case KEY_MYPROGRAMS: exit(0); case KEY_BACKLIGHT: oztogglelight(); break; default: return c; } } }
char *selectname(void) { static fname files[9]; static byte refresh; static byte pos; static unsigned i; static unsigned i1; static unsigned k; static unsigned curpos; static unsigned cursorloc; register char *f; cursorloc=curpos=0; ozfont(FONT_OZ_NORMAL); f=ozgetnextfilename0(FIND_OWNED | FIND_RESET); if(f==NULL) nofiles(); do { background(); for(pos=i=0;i<9;i++,pos+=8) { if(i && NULL==(f=ozgetnextfilename0(FIND_OWNED))) break; strcpy(files[i],f); putformatted(0,pos,"|. $",i+1,f); /* ozputch(0,pos,i+'1'); ozputch(5,pos,'.'); ozputs(9,pos,f); */ } curpos+=9; if(cursorloc>=i) cursorloc=i-1; /* ozputs(0,72,"\x0A/\x0B:choose \x0D/1-9:load Del:del. C:clear bkmrks A:del. all"); */ if(NULL!=f) f=ozgetnextfilename0(FIND_OWNED); refresh=0; do { _ozfilledbox(0,8*cursorloc,150,8,XOR); k=ozgetchblank(); _ozfilledbox(0,8*cursorloc,150,8,XOR); switch(k) { case KEY_LOWER_ESC: case KEY_UPPER_ESC: exit(0); case KEY_MAIN: case KEY_TELEPHONE: case KEY_SCHEDULE: case KEY_MEMO: case KEY_MYPROGRAMS: ozexitto(k); case KEY_BACKLIGHT: oztogglelight(); break; case 'a': if(ozwarn("Are you sure you want to delete all?",yn)!= KEY_LOWER_ENTER) { refresh=1; f=ozgetnextfilename0(FIND_OWNED | FIND_RESET); cursorloc=curpos=0; break; } ozunlinkallowned(); exit(0); case KEY_BACKSPACE: case 'c': ozcls(); f=files[cursorloc]; ozputs(ozputs(0,0,k==KEY_BACKSPACE?"Deleting: ":"Clearing bookmarks for: "),0,f); if(ozwarn("Are you sure?",yn)==KEY_LOWER_ENTER) { if(k==KEY_BACKSPACE) unlink(f); if(!strncmp(f,directory,3)) { f[0]='b'; f[1]='m'; unlink(f); } } refresh=1; f=ozgetnextfilename0(FIND_OWNED | FIND_RESET); if(f==NULL) nofiles(); cursorloc=curpos=0; break; case KEY_LOWER_ENTER: case KEY_UPPER_ENTER: case KEY_RETURN: return files[cursorloc]; case KEY_UP: if(cursorloc) cursorloc--; else if(curpos>=18) { cursorloc=8; k=KEY_PAGEUP; } break; case KEY_DOWN: if(cursorloc<i-1) cursorloc++; else if(f!=NULL) { cursorloc=0; k=KEY_PAGEDOWN; } break; } switch(k) { case KEY_PAGEUP: if(curpos>=18) { curpos-=18; f=ozgetnextfilename0(FIND_OWNED | FIND_RESET); for(i1=0;i1<curpos;i1++) ozgetnextfilename0(FIND_OWNED); refresh=1; } else cursorloc=0; break; case KEY_PAGEDOWN: refresh=1; if(f==NULL) { cursorloc=i-1; refresh=0; } break; } if(k>='1' && k<'1'+i) refresh=1; } while(!refresh); } while(k<'1' || k>='1'+i); return files[k-'1']; }
//extern int __LIB__ ozeditline(byte _x0,byte y0,char *s0,byte slen,byte xlen) //int ozeditline(byte _x0,byte y0,char *s0,byte slen,byte xlen) int ozeditline(int _x0, int y0, char* s0, int slen, int xlen) { static char c; static byte l1, l2; static unsigned k; static byte i; register char* p; switch (ozgetfont()) { case FONT_PC_NORMAL: case FONT_OZ_NORMAL: height = 8; break; default: height = 13; break; } x = x0 = _x0; y = y0; if ((int)x0 + (int)xlen > 239 || (int)y + (int)height > 79) return OZEDITLINE_ERROR; xlen--; s = s0; pos = strlen(s0); if (pos >= slen) return OZEDITLINE_ERROR; ozputs(x0, y, s); setcursor(); xorcursor(); while (1) { switch (k = getch()) { case KEY_MAIN: case KEY_SCHEDULE: case KEY_MEMO: case KEY_TELEPHONE: case KEY_POWER: case KEY_MYPROGRAMS: ozexitto(k); case KEY_BACKLIGHT: oztogglelight(); break; case KEY_LEFT: if (pos > 0) { pos--; movecursor(); } break; case KEY_RIGHT: if (s[pos]) { pos++; movecursor(); } break; case KEY_LOWER_ESC: case KEY_UPPER_ESC: case 27: xorcursor(); return OZEDITLINE_CANCEL; case KEY_LOWER_ENTER: case KEY_UPPER_ENTER: case '\r': case '\n': xorcursor(); return strlen(s); case KEY_BACKSPACE: case KEY_BACKSPACE_16K: if (pos > 0) { pos--; p = s + pos; c = *p; while (*p) { *p = p[1]; p++; } xorcursor(); l1 = ozputs(x0, y, s); l2 = ozputch(l1, -1, c); for (i = l1; i < l2; i++) { _ozvline(i, y, height, WHITE); } ozputs(x0, y, s); setcursor(); xorcursor(); } break; default: if (k < 127 && ozputch(0, -1, k) + ozputs(0, -1, s) < xlen && (l1 = 1 + strlen(s)) < slen) { xorcursor(); for (i = l1; i > pos; i--) s[i] = s[i - 1]; if (s[pos] == 0) s[pos + 1] = 0; s[pos] = k; pos++; ozputs(x0, y, s); setcursor(); xorcursor(); } break; } } return OZEDITLINE_ERROR; }
void view(void) { static byte mod; static unsigned k; static unsigned long delta; static byte i; load_headers(); in_buf=0; ateof=0; atstart=1; scrollbar_pos=0xa000+29; if(last==0) last=header_length; goto_pos(last); mod=1; ozcls(); while(1) { if(mod) { if(!backandforth)position_save(); show(); unbar(); scrollbar(); backandforth=mod=0; } switch(k=ozgetchblank()) { case KEY_LEFT: case KEY_BACKSPACE: #ifdef DEBUG putformatted(0,0,"positionptr=| numpositions=| ", positionptr,numpositions); ozgetch(); #endif if(positionptr<=1) break; goto_pos(positions[(--positionptr)-1]); if(!positionptr) positionptr=1; backandforth=mod=1; #ifdef DEBUG putformatted(0,0,"positionptr=| numpositions=| ", positionptr,numpositions); ozgetch(); #endif break; case KEY_RIGHT: #ifdef DEBUG putformatted(0,0,"positionptr=| numpositions=| ", positionptr,numpositions); ozgetch(); #endif if(positionptr>=numpositions) break; goto_pos(positions[positionptr]); positionptr++; backandforth=mod=1; #ifdef DEBUG putformatted(0,0,"positionptr=| numpositions=| ", positionptr,numpositions); ozgetch(); #endif break; case 'm': /* mark position */ if(numbookmarks>=MAX_BOOKMARKS) { for(i=0;i<MAX_BOOKMARKS-1;i++) { bookmarks[i]=bookmarks[i+1]; } numbookmarks--; } bookmarkptr=numbookmarks; bookmarks[numbookmarks++]=screen_offset+buffer_offset; bookmarksmod=1; break; case 'b': if(numbookmarks) { goto_pos(bookmarks[bookmarkptr]); if(bookmarkptr) bookmarkptr--; else bookmarkptr=numbookmarks-1; mod=1; } break; case 'r': show_bar=!show_bar; bookmarksmod=1; unbar(); scrollbar(); break; case 'h': case KEY_UPPER_MENU: case KEY_LOWER_MENU: dohelp(); ozcls(); mod=1; break; case 'i': _ozfilledbox(0,0,WIDTH,line_height,0); delta=screen_offset+buffer_offset-header_length; putformatted(0,0,"$ : ^/^=|%",filename, delta,length-header_length, (unsigned int)(delta*100/(length-header_length)) ); _ozfilledbox(0,0,WIDTH,line_height,XOR); ozgetchblank(); mod=1; ozcls(); break; case 'c': if(numbookmarks && ozwarn("Delete all bookmarks?",yn)==KEY_LOWER_ENTER ) { bookmarksmod=1; numbookmarks=0; } mod=1; ozcls(); break; case '-': case KEY_PAGEUP: for(i=0;i<num_lines-1;i++) { checkshiftup(); backline(); } mod=1; break; case 's': if(myfont) break; line_height++; if(line_height==11) line_height=8; if(line_height!=9) num_lines=80/line_height; else num_lines=9; bookmarksmod=1; mod=1; ozcls(); break; case KEY_PAGEDOWN: case KEY_LOWER_ENTER: case KEY_UPPER_ENTER: case KEY_RETURN: case ' ': for(i=0;i<num_lines-1;i++) { checkshiftdown(); forwardline(); } mod=1; break; case KEY_UP: checkshiftup(); if(!backline()) break; unbar(); ozscrolldown(line_height*30); dcompline(filebuf+screen_offset); puttextline(0); position_save(); scrollbar(); break; case KEY_DOWN: checkshiftdown(); if(forwardline()) { mod=1; showbot=1; unbar(); ozscroll(line_height*30); } break; case KEY_LEFT_SHIFT | MASKSHIFT: case KEY_RIGHT_SHIFT | MASKSHIFT: switch(ozgetch() & 0xF0FF) { case '-': ozclick(!ozgetclick()); ozsavekeysettings(); break; case KEY_PAGEUP: case KEY_UP: tenpercent(-1); mod=1; break; case KEY_PAGEDOWN: case KEY_DOWN: tenpercent(1); mod=1; break; } break; case KEY_UP | MASKSHIFT: case KEY_PAGEUP | MASKSHIFT: tenpercent(-1); mod=1; break; case KEY_PAGEDOWN | MASKSHIFT: case KEY_DOWN | MASKSHIFT: tenpercent(1); mod=1; break; case KEY_2ND: switch(ozgetch() & 0xF0FF ) { case '-': ozclick(!ozgetclick()); ozsavekeysettings(); break; case KEY_PAGEUP: case KEY_UP: goto_pos(header_length); mod=1; break; case KEY_PAGEDOWN: case KEY_DOWN: goto_pos(length); mod=1; break; } break; case KEY_LOWER_ESC: case KEY_UPPER_ESC: case KEY_MYPROGRAMS: exit(0); case KEY_MAIN: case KEY_CALENDAR: case KEY_TELEPHONE: case KEY_MEMO: ozexitto(k); case KEY_BACKLIGHT: oztogglelight(); break; } } }