Hi everybody,
Here is a little program I wrote to see if it was possible to get rid of the crappy 80x25 console screen.
It is a little rough and the technique I used reflect my old Dos upbringing but it is very eazy to follow the logic.
For exemple, as I have a pair of twin 22 LCD I like to use long code lines instead of going vertical with more lines.
What is missing so far is the Mouse in the window and a few other windows options.
I tried Console Tools plus Graphics and it work fine but it is so slow that you must have a Gamer's Machine to use it properly.
Any suggestions for improving that code will be welcomed.
Here is a little program I wrote to see if it was possible to get rid of the crappy 80x25 console screen.
It is a little rough and the technique I used reflect my old Dos upbringing but it is very eazy to follow the logic.
For exemple, as I have a pair of twin 22 LCD I like to use long code lines instead of going vertical with more lines.
What is missing so far is the Mouse in the window and a few other windows options.
I tried Console Tools plus Graphics and it work fine but it is so slow that you must have a Gamer's Machine to use it properly.
Any suggestions for improving that code will be welcomed.
Code:
'A better demo of console input with graphic output using a one line console stuck below the graphic window 'The purpose is to get rid of the 80x25 console look but keep using PBCC 'Will work well even on old slow computers #COMPILE EXE #DIM NONE DEFLNG a-z FUNCTION PBMAIN () AS LONG MOUSE 7,DOUBLE,DOWN: MOUSE ON ' Activate Mouse (to be used later when I add more code) x=1: y=1 ' Start position in Graphic Window REDIM txt$(999) ' Text to be displayed or modified DIM texte AS FIELD ' Text buffer for Disk IO DESKTOP GET CLIENT TO pixw,pixh ' Find desktop size in pixels minus tray CONSOLE SET SCREEN 1,80 ' Console with only one line for input CONSOLE SET VIEW 1,80 ' Can be modified as needed COLOR 14,12: CLS ' Console color Yellow with Red Background CONSOLE GET SIZE TO Conw,Conh ' Find Console size in pixels ( Bigger is better ) need at least 1024x768 x0=pixw-conw: IF x0<0 THEN x0=0 ' Position x0 console align right x1=x0 ' Position x1 window align with console y1=0 ' Position y1 window align up x2=conw ' Position x2 windows align right w!=12: IF pixw<1280 THEN w!=9 ' Use 12 points if desktop is big enough (we want 90 columns) h!=24: IF pixh<1024-conh THEN h!=18 ' Use 24 pixels enough for 32 lines (we will find real text height later) y2=h!*32 ' Position y2 far right like our one line console GRAPHIC WINDOW "Console input et graphic output" ,x1,y1,x2,y2 TO hwin GRAPHIC ATTACH hwin,0,REDRAW ' Used to speed up graphics SLEEP 25 ' Bizarre but needed as sometime the window will be blank if no Sleep used ? GRAPHIC CLEAR %BLACK,%GREEN GRAPHIC COLOR %GREEN,%BLACK GRAPHIC GET PIXEL (2,2) TO fond ' Find Background color if other colors used instead of black GRAPHIC FONT "Lucida Console",w!,1 ' Use Courier New for Win 98 GRAPHIC WIDTH 1 GRAPHIC CHR SIZE TO cw!,ch! ' Find real size of our graphic font y0=y2+conh/2 ' Find our window bottom CONSOLE SET LOC x0,y0 ' Align console just below window MaxVid=31 ' Lines used in our window MaxCar=90 ' Width per lines MaxLgn=999 ' Lines allowed in text ReadTxt:REM read our test file OPEN "c:\test.txt" FOR INPUT AS #1: z=0 IF ERR>0 THEN ERR=0: GOTO CloseTxt ' First time with no text file WHILE EOF(1)=0: z=z+1:LINE INPUT#1,txt$(z): WEND: CLOSE #1 CloseTxt:REM end of read Heading:REM Make a one line box with text that could be placed anywhere GRAPHIC BOX (cw!*5,1)-(conw-cw!*5,ch!+2),5,%RED,%YELLOW GRAPHIC FONT "times new roman",w!-2,1 GRAPHIC SET POS (cw!*6,2) GRAPHIC COLOR %BLACK,%YELLOW GRAPHIC PRINT "This is a Console Note Pad with 999 lines availables. Use arrow to move around. Esc to END. Console Windows properties to ajust Font and Console size" ShowText:REM show first 31 lines in our graphic window GRAPHIC FONT "Lucida Console",w!,1: GRAPHIC COLOR %GREEN,%BLACK FOR t=1 TO 40: GRAPHIC SET POS((x*w!),(t*h!)): GRAPHIC PRINT txt$(t): NEXT: GRAPHIC REDRAW t=1: COLOR 14,12: LOCATE 1,1: z$=txt$(t): GOSUB AccentDos: PRINT z$: x=LEN(txt$(t))+1 k!=LEN(txt$(t))*cw!+cw!: GOSUB Curseur ConsoleInput: REM show yellow text with red background in console input at bottom and corresponding line in graphic window GRAPHIC COLOR %YELLOW,%RED: GRAPHIC SET POS((1*w!),(y*h!)): GRAPHIC PRINT txt$(t)+" ": GRAPHIC REDRAW GOSUB Curseur ' Make a simple non blinking cursor for now LOCATE 1,x: CONSOLE SET FOCUS: ink$=WAITKEY$: ink%=0: IF ink$=CHR$(27) THEN EndConsole IF LEN(ink$)>1 THEN ink%=ASC(RIGHT$(ink$,1)):ink$="": GOSUB accents GRAPHIC COLOR %GREEN,fond: GRAPHIC SET POS((1*w!),(y*h!)): GRAPHIC PRINT txt$(t)+" " : GRAPHIC REDRAW ScrollUp:REM Scroll window up if cursor is at bottom or PageUp is pressed IF ink%=73 OR (ink$=CHR$(13) AND t>MaxVid-1) OR (ink%=80 AND t>Maxvid-1) THEN IF t>=MaxLgn THEN BEEP: GOTO ConsoleInput ELSE t=t+1: v=MaxVid GRAPHIC COPY hwin,0,(0,h!*2)-(conw,h!*(MaxVid+1)) TO (0,h!) GRAPHIC SET POS((1*w!),(v*h!)): GRAPHIC PRINT txt$(t+v-1)+STRING$(Maxcar-LEN(txt$(t+v-1))," "): GRAPHIC REDRAW LOCATE 1,1: z$=txt$(t): GOSUB AccentDos: PRINT z$;TAB(80): x=LEN(txt$(t))+1: k!=x*cw!: GOTO consoleinput END IF ScrollDown:REM Scroll window down if cursor is at top or PageDown is pressed IF ink%=81 OR (ink%=72 AND t>y AND y=1) THEN IF t=y THEN BEEP: GOTO ConsoleInput ELSE t=t-1: v=MaxVid GRAPHIC COPY hwin,0,(0,h!*1)-(conw,h!*(MaxVid)) TO (0,h!*2) GRAPHIC SET POS((1*w!),(y*h!)): GRAPHIC PRINT txt$(t)+STRING$(Maxcar-LEN(txt$(t))," "): GRAPHIC REDRAW LOCATE 1,1: z$=txt$(t): GOSUB AccentDos: PRINT z$;TAB(80): x=LEN(txt$(t)): k!=x*cw!: GOTO consoleinput END IF MoveDown:REM Move cursor down if Cr or Arrow down pressed IF ink$=CHR$(13) OR ink%=80 THEN IF y<32 THEN y=y+1:t=t+1 ELSE BEEP: GOTO ConsoleInput LOCATE 1,1: z$=txt$(t): GOSUB AccentDos: PRINT z$;TAB(80): x=LEN(txt$(t))+1: k!=x*cw!: GOTO ConsoleInput END IF MoveUp:REM Move cursor up if Up Arrow pressed IF ink%=72 THEN IF y>1 THEN y=y-1:t=t-1 ELSE BEEP: GOTO ConsoleInput LOCATE 1,1: z$=txt$(t): GOSUB AccentDos: PRINT z$;TAB(80): x=LEN(txt$(t))+1: k!=x*cw!: GOTO consoleinput END IF BackSpace:REM Move cursor left and erase everything right of it IF ink$=CHR$(8) AND x>1 THEN IF x>1 THEN x=x-1 ELSE BEEP: GOTO ConsoleInput txt$(t)=LEFT$(txt$(t),x-1) GRAPHIC SET POS((1*w!),(y*h!)): GRAPHIC PRINT txt$(t)+STRING$(MaxCar-LEN(txt$(t))," "): GRAPHIC REDRAW LOCATE 1,1: z$=txt$(t): GOSUB AccentDos: PRINT z$;TAB(80): k!=x*cw!: GOTO consoleinput END IF MoveLeft:REM Move left if left arrow pressed IF ink%=75 THEN IF x>1 THEN x=x-1 ELSE BEEP: GOTO ConsoleInput GRAPHIC SET POS((1*w!),(y*h!)): GRAPHIC PRINT txt$(t)+STRING$(Maxcar-LEN(txt$(t))," "): GRAPHIC REDRAW LOCATE 1,1: z$=txt$(t): GOSUB AccentDos: PRINT z$;TAB(80): k!=x*cw!: GOSUB Curseur: GOTO consoleinput END IF MoveHome:REM Move to left side of line IF ink%=71 THEN IF x>1 THEN x=1 ELSE BEEP: GOTO ConsoleInput GRAPHIC SET POS((1*w!),(y*h!)): GRAPHIC PRINT txt$(t)+STRING$(Maxcar-LEN(txt$(t))," "): GRAPHIC REDRAW LOCATE 1,1: z$=txt$(t): GOSUB AccentDos: PRINT z$;TAB(80): k!=x*cw!: GOSUB Curseur: GOTO consoleinput END IF MoveRight:REM Move right if right arrow pressed IF ink%=77 THEN IF x <= LEN(txt$(t)) THEN x=x+1 ELSE BEEP: GOTO ConsoleInput GRAPHIC SET POS((1*w!),(y*h!)): GRAPHIC PRINT txt$(t)+STRING$(MaxCar-LEN(txt$(t))," "): GRAPHIC REDRAW LOCATE 1,1: z$=txt$(t): GOSUB AccentDos: PRINT z$;TAB(80): k!=x*cw!: GOSUB Curseur: GOTO consoleinput END IF MoveEnd:REM move right side of line IF ink%=79 THEN IF x<LEN(txt$(t)) THEN x=LEN(txt$(t))+1 ELSE BEEP: GOTO ConsoleInput GRAPHIC SET POS((1*w!),(y*h!)): GRAPHIC PRINT txt$(t)+STRING$(Maxcar-LEN(txt$(t))," "): GRAPHIC REDRAW LOCATE 1,1: z$=txt$(t): GOSUB AccentDos: PRINT z$;TAB(80): k!=x*cw!: GOSUB Curseur: GOTO consoleinput END IF DeleteOne:REM Delete one caracter and compress line left IF ink%=83 THEN IF x=>LEN(txt$(t)) THEN BEEP: z$="": GOTO ConsoleInput z$=LEFT$(txt$(y),x-1)+RIGHT$(txt$(y),LEN(txt$(y))-x): txt$(y)=z$ GRAPHIC SET POS((1*w!),(y*h!)): GRAPHIC PRINT txt$(y)+STRING$(MaxCar-LEN(txt$(y))," "): GRAPHIC REDRAW LOCATE 1,1: z$=txt$(y): GOSUB AccentDos: PRINT z$;TAB(80): GOTO consoleinput END IF InsertOne:REM Insert one space ane move line right IF ink%=82 THEN IF LEN(txt$(t))>=MaxCar THEN BEEP: z$="": GOTO ConsoleInput z$=LEFT$(txt$(t),x-1)+" "+RIGHT$(txt$(t),LEN(txt$(t))-x+1): txt$(t)=z$ GRAPHIC SET POS((1*w!),(y*h!)): GRAPHIC PRINT txt$(t)+STRING$(MaxCar-LEN(txt$(t))," "): GRAPHIC REDRAW LOCATE 1,1: z$=txt$(t): GOSUB AccentDos: PRINT z$;TAB(80): GOTO consoleinput END IF OutputConsole: REM Print caracter at both console and window z$=LEFT$(txt$(t),x-1)+ink$+MID$(txt$(t),x+1): txt$(t)=z$ GRAPHIC SET POS((x*w!),(y*h!)): GRAPHIC PRINT ink$ IF x<MaxCar THEN x=x+1 ELSE BEEP: GOTO ConsoleInput PRINT dos$: k!=x*cw! GOTO consoleinput EndConsole: REM End of demo and save new text OPEN "c:\test.txt" FOR OUTPUT AS #1 FOR x=1 TO MaxLgn: PRINT#1,txt$(x): NEXT: CLOSE #1 END '--------------------------------------------------------------------------------------------------------- Accents:REM Map French Accents with F1 to F10 key (ink$=Windows codes) (dos$=Dos codes) dos$=ink$ IF ink%=59 THEN ink$="à": dos$="…" ' F1 IF ink%=60 THEN ink$="â": dos$="ƒ" ' F2 IF ink%=61 THEN ink$="ç": dos$="‡" ' F3 IF ink%=62 THEN ink$="ô": dos$="“" ' F4 IF ink%=63 THEN ink$="é": dos$="‚" ' F5 IF ink%=64 THEN ink$="è": dos$="Š" ' F6 IF ink%=65 THEN ink$="ê": dos$="ˆ" ' F7 IF ink%=66 THEN ink$="ë": dos$="‰" ' F8 IF ink%=67 THEN ink$="î": dos$="Œ" ' F9 IF ink%=68 THEN ink$="û": dos$="–" ' F10 RETURN AccentDos: REM Convert French Accents from Windows to Dos for console FOR z% = 1 TO LEN(z$) i% = ASC(MID$(z$, z%, 1)) IF i% = 233 THEN MID$(z$, z%, 1) = CHR$(130) '‚ IF i% = 226 THEN MID$(z$, z%, 1) = CHR$(131) 'ƒ IF i% = 224 THEN MID$(z$, z%, 1) = CHR$(133) '… IF i% = 231 THEN MID$(z$, z%, 1) = CHR$(135) '‡ IF i% = 234 THEN MID$(z$, z%, 1) = CHR$(136) 'ˆ IF i% = 235 THEN MID$(z$, z%, 1) = CHR$(137) '‰ IF i% = 232 THEN MID$(z$, z%, 1) = CHR$(138) 'Š IF i% = 238 THEN MID$(z$, z%, 1) = CHR$(140) 'Œ IF i% = 244 THEN MID$(z$, z%, 1) = CHR$(147) '“ IF i% = 251 THEN MID$(z$, z%, 1) = CHR$(150) '– IF i% = 201THEN MID$(z$, z%, 1) = CHR$(144) ' NEXT RETURN Curseur:REM Simple non blinking cursor GRAPHIC BOX (k!,y*h!+h!-7)-(k!+cw!,y*h!+h!-4),0,%WHITE,%WHITE: SLEEP 5: GRAPHIC REDRAW RETURN END FUNCTION
Comment