Donc voila un début de code pour le décodage et l’affichage du protocole VT100 (Ne gère pas grand chose pour le moment, mais suffisamment pour que cela soit présentable) et tout cela dans le but de faire un petit HyperTerminal (gratuit). J'avais déjà fait un début en VisualBasic 6 (voir ici http://koakdesign.info/?url=31&val=1, cliquez sur la miniature pour voir en grand).
Le code décode pas mal de chose dans le VT100.
Permet la sélection d’une zone (pour le copier, coller dans le futur).
Un double clique sur une lettre permet de retrouver le mot complet.
Donc voila en gros pour le moment...
Donc voila le code :
Code : Tout sélectionner
; +======================================================+
; | TOMTOMAX MAXI-BOX (Réalisation par KoakDesign) |
; +------------------------------------------------------+
; | COPYRIGHT(C)2007-2008, ALL RIGHT RESERVED KOAKDESIGN |
; +--------------+---------------------------------------+
; | Program type | PUREBASIC 4.51 |
; +--------------+---------------------------------------+
; | VER & REV | 0.0.1 |
; +--------------+---------------------------------------+
; | Program name | main.pb |
; +======================================================+
; +======================================================+
; | Original Version: 0.0.1 |
; +--------------+---------------------------------------+
; | Created by | |
; | Graphix by | |
; +--------------+---------------------------------------+
; | Comments: | |
; +--------------+ |
; | |
; | |
; | |
; +======================================================+
; +======================================================+
; | Système d'Exploitation |
; +--------------+---------------------------------------+
; | Window | Oui |
; | Linux | Non |
; | MacOS | Non |
; +======================================================+
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; +--------------------------------------------------------------------------+
; | |
; +--------------------------------------------------------------------------+
DisableASM
EnableExplicit
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; +--------------------------------------------------------------------------+
; | |
; +--------------------------------------------------------------------------+
;{ - CONSTANTES
#TERMINAL_RESX = 79
#TERMINAL_RESY = 24
#TERMINAL_MAXX = 80
#TERMINAL_MAXY = 25
;}
;{ - STRUCTURE.
Structure TERMINAL
l.i
h.i
tl.i
th.i
lCurX.l
lCurY.l
bcurser.b
lfont.SIZE
sFontName.s
lFontSize.l
iCanva.i
iImage.i[3]
EndStructure
Structure MODECHAR
lPosX.l
lPosY.l
lSavX.l
lSavY.l
lForeColor.l
lBackColor.l
lGetattributs.l
bXOff.b
bBold.b
bBlink.b
bItalic.b
bHidden.b
bUnderline.b
bReverseVideo.b
bFlagAutoJump.b
bSpecialGraph.b
bDoubleWidth.b
bDoubleHeight.b
bPBold.b
bPUnderline.b
bPBlink.b
bPReverseVideo.b
EndStructure
Structure SAVECHAR
lForeColor.l
lBackColor.l
bBold.b
bBlink.b
bItalic.b
bHidden.b
bUnderline.b
bReverseVideo.b
bFlagAutoJump.b
bSpecialGraph.b
bDoubleWidth.b
bDoubleHeight.b
EndStructure
;}
;{ - VARIABLE.
Global scrPosition.point
Global srcTerminal.TERMINAL
Global stcAttributes.MODECHAR
Global Dim scrTermColor.l(15)
Global Dim tabANSIBuffer.s{1}(#TERMINAL_MAXX, #TERMINAL_MAXY)
Global Dim tabAttributes.SAVECHAR(#TERMINAL_MAXX, #TERMINAL_MAXY)
Global FontID1.i
;}
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; +--------------------------------------------------------------------------+
; | |
; +--------------------------------------------------------------------------+
Procedure getTextWH(stext.s, ltype.l, lfontid.l)
; ROUTINE DONNANT LA TAILLE D'UN TEXTE EN PIXEL.
Define sz.SIZE
Define iImage.i = CreateImage(#PB_Any, 10, 10)
If iImage <> 0
If StartDrawing(ImageOutput(iImage))
DrawingMode(#PB_2DDrawing_Default)
DrawingFont(FontID(lfontid))
sz\cx = TextWidth (stext)
sz\cy = TextHeight(stext)
StopDrawing()
EndIf
FreeImage(iImage)
Select ltype
Case 0
ProcedureReturn sz\cx
Case 1
ProcedureReturn sz\cy
EndSelect
EndIf
EndProcedure
Procedure Terminal_Init()
;
Define lfont.SIZE
srcTerminal\lFontSize = 12
srcTerminal\sFontName = "Terminal"
;srcTerminal\sFontName = "Lucida Console"
FontID1 = LoadFont(#PB_Any, srcTerminal\sFontName, srcTerminal\lFontSize, #PB_Font_HighQuality)
SetGadgetFont(#PB_Default, FontID(FontID1))
srcTerminal\lfont\cx = getTextWH("A", 0, FontID1)
srcTerminal\lfont\cy = getTextWH("A", 1, FontID1)
srcTerminal\l = #TERMINAL_MAXX * srcTerminal\lfont\cx
srcTerminal\h = #TERMINAL_MAXY * srcTerminal\lfont\cy
srcTerminal\tl = #TERMINAL_MAXX
srcTerminal\th = #TERMINAL_MAXY
srcTerminal\bcurser = #True
scrTermColor(0) = $000000
scrTermColor(1) = $000080
scrTermColor(2) = $008000
scrTermColor(3) = $800000
scrTermColor(4) = $000080
scrTermColor(5) = $800080
scrTermColor(6) = $808000
scrTermColor(7) = $808080
scrTermColor(8) = $3c3c3c
scrTermColor(9) = $6060ff
scrTermColor(10) = $60ff60
scrTermColor(11) = $00ffe0
scrTermColor(12) = $ff4040
scrTermColor(13) = $ff40a0
scrTermColor(14) = $00ffff
scrTermColor(15) = $ffffff
If srcTerminal\iCanva <> 0
FreeGadget(GadgetID(srcTerminal\iCanva))
EndIf
srcTerminal\iCanva = CanvasGadget(#PB_Any, 0, 0, srcTerminal\l, srcTerminal\h, #PB_Canvas_Keyboard)
If StartDrawing(CanvasOutput(srcTerminal\iCanva))
DrawingMode(#PB_2DDrawing_Default)
DrawingFont(FontID(FontID1))
Box(0,0, srcTerminal\l, srcTerminal\h, $0)
StopDrawing()
EndIf
If srcTerminal\iImage[0] <> 0
FreeImage(srcTerminal\iImage[0])
EndIf
If srcTerminal\iImage[1] <> 0
FreeImage(srcTerminal\iImage[1])
EndIf
If srcTerminal\iImage[2] <> 0
FreeImage(srcTerminal\iImage[2])
EndIf
srcTerminal\iImage[0] = CreateImage(#PB_Any, srcTerminal\l, srcTerminal\h)
srcTerminal\iImage[1] = CreateImage(#PB_Any, srcTerminal\l, srcTerminal\h)
srcTerminal\iImage[2] = CreateImage(#PB_Any, srcTerminal\l, srcTerminal\h)
EndProcedure
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; +--------------------------------------------------------------------------+
; | |
; +--------------------------------------------------------------------------+
Procedure.b setAttributs(attributs.i, first.i = -1)
;
If first > -1 And stcAttributes\lGetattributs <> first
stcAttributes\lGetattributs = first
EndIf
Select attributs
Case 0
stcAttributes\bBold = #False
stcAttributes\bItalic = #False
stcAttributes\bUnderline = #False
stcAttributes\bBlink = #False
stcAttributes\bReverseVideo = #False
stcAttributes\bHidden = #False
stcAttributes\bSpecialGraph = #False
stcAttributes\lForeColor = 7
stcAttributes\lBackColor = 0
stcAttributes\lGetattributs = 0
Case 1
stcAttributes\bBold = #True
Case 2
stcAttributes\bBold = #False
Case 3
stcAttributes\bItalic = #True
Case 5
stcAttributes\bBlink = #True
Case 4
stcAttributes\bUnderline = #True
Case 7
stcAttributes\bReverseVideo = #True
Case 8
stcAttributes\bHidden = #True
Case 22
stcAttributes\bBold = #False
Case 23
stcAttributes\bItalic = #False
Case 24
stcAttributes\bUnderline = #False
Case 25
stcAttributes\bBlink = #False
Case 27
stcAttributes\bReverseVideo = #False
Case 28
stcAttributes\bHidden = #False
Case 30
Select stcAttributes\lGetattributs
Case 0
stcAttributes\lForeColor = 0
Case 1
stcAttributes\lForeColor = 8
EndSelect
Case 31
Select stcAttributes\lGetattributs
Case 0
stcAttributes\lForeColor = 4
Case 1
stcAttributes\lForeColor = 12
EndSelect
Case 32
Select stcAttributes\lGetattributs
Case 0
stcAttributes\lForeColor = 2
Case 1
stcAttributes\lForeColor = 10
EndSelect
Case 33
Select stcAttributes\lGetattributs
Case 0
stcAttributes\lForeColor = 6
Case 1
stcAttributes\lForeColor = 14
EndSelect
Case 34
Select stcAttributes\lGetattributs
Case 0
stcAttributes\lForeColor = 1
Case 1
stcAttributes\lForeColor = 9
EndSelect
Case 35
Select stcAttributes\lGetattributs
Case 0
stcAttributes\lForeColor = 5
Case 1
stcAttributes\lForeColor = 13
EndSelect
Case 36
Select stcAttributes\lGetattributs
Case 0
stcAttributes\lForeColor = 3
Case 1
stcAttributes\lForeColor = 11
EndSelect
Case 37
Select stcAttributes\lGetattributs
Case 0
stcAttributes\lForeColor = 7
Case 1
stcAttributes\lForeColor = 15
EndSelect
Case 40
Select stcAttributes\lGetattributs
Case 0
stcAttributes\lBackColor = 0
Case 1
stcAttributes\lBackColor = 8
EndSelect
Case 41
Select stcAttributes\lGetattributs
Case 0
stcAttributes\lBackColor = 4
Case 1
stcAttributes\lBackColor = 9
EndSelect
Case 42
Select stcAttributes\lGetattributs
Case 0
stcAttributes\lBackColor = 2
Case 1
stcAttributes\lBackColor = 10
EndSelect
Case 43
Select stcAttributes\lGetattributs
Case 0
stcAttributes\lBackColor = 3
Case 1
stcAttributes\lBackColor = 11
EndSelect
Case 44
Select stcAttributes\lGetattributs
Case 0
stcAttributes\lBackColor = 4
Case 1
stcAttributes\lBackColor = 12
EndSelect
Case 45
Select stcAttributes\lGetattributs
Case 0
stcAttributes\lBackColor = 5
Case 1
stcAttributes\lBackColor = 13
EndSelect
Case 46
Select stcAttributes\lGetattributs
Case 0
stcAttributes\lBackColor = 6
Case 1
stcAttributes\lBackColor = 14
EndSelect
Case 47
Select stcAttributes\lGetattributs
Case 0
stcAttributes\lBackColor = 7
Case 1
stcAttributes\lBackColor = 15
EndSelect
EndSelect
EndProcedure
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; +--------------------------------------------------------------------------+
; | |
; +--------------------------------------------------------------------------+
Procedure Draw_DeleteText()
;
Define x.l, y.l
If StartDrawing(ImageOutput(srcTerminal\iImage[0]))
Box(0,0, srcTerminal\l, srcTerminal\h, $0)
StopDrawing()
EndIf
If StartDrawing(ImageOutput(srcTerminal\iImage[1]))
Box(0,0, srcTerminal\l, srcTerminal\h, $0)
StopDrawing()
EndIf
;
; SUPPRESSION DU TABLEAU MEMOIRE.
;
For y = 0 To #TERMINAL_MAXY
For x = 0 To #TERMINAL_MAXX
tabANSIBuffer(x, y) = #NULL$
tabAttributes(x, y)\bBold = #False
tabAttributes(x, y)\bBlink = #False
tabAttributes(x, y)\bItalic = #False
tabAttributes(x, y)\bHidden = #False
tabAttributes(x, y)\lForeColor = 7
tabAttributes(x, y)\lBackColor = 0
Next x
Next y
EndProcedure
Procedure Draw_TerminalDecalY()
;
Define limage.i
If StartDrawing(ImageOutput(srcTerminal\iImage[0]))
If srcTerminal\iImage[0] <> 0
Box(srcTerminal\lCurX, srcTerminal\lCurY, srcTerminal\lfont\cx, srcTerminal\lfont\cy, $0)
limage = GrabDrawingImage(#PB_Any, 0, srcTerminal\lfont\cy, srcTerminal\l, srcTerminal\h - srcTerminal\lfont\cy)
DrawImage(ImageID(limage), 0, 0)
Box(0,srcTerminal\h - srcTerminal\lfont\cy, srcTerminal\l, srcTerminal\lfont\cy, $0)
EndIf
StopDrawing()
FreeImage(limage)
EndIf
If StartDrawing(ImageOutput(srcTerminal\iImage[1]))
If srcTerminal\iImage[1] <> 0
limage = GrabDrawingImage(#PB_Any, 0, srcTerminal\lfont\cy, srcTerminal\l, srcTerminal\h - srcTerminal\lfont\cy)
DrawImage(ImageID(limage), 0, 0)
Box(0,srcTerminal\h - srcTerminal\lfont\cy, srcTerminal\l, srcTerminal\lfont\cy, $0)
EndIf
StopDrawing()
FreeImage(limage)
EndIf
EndProcedure
Procedure Draw_ANSIText(stext.s)
;
If stext <> #NULL$
tabANSIBuffer(scrPosition\x, scrPosition\y) = stext
tabAttributes(scrPosition\x, scrPosition\y)\bBold = stcAttributes\bBold
tabAttributes(scrPosition\x, scrPosition\y)\bBlink = stcAttributes\bBlink
tabAttributes(scrPosition\x, scrPosition\y)\bItalic = stcAttributes\bItalic
tabAttributes(scrPosition\x, scrPosition\y)\bHidden = stcAttributes\bHidden
tabAttributes(scrPosition\x, scrPosition\y)\lForeColor = scrTermColor(stcAttributes\lForeColor)
tabAttributes(scrPosition\x, scrPosition\y)\lBackColor = scrTermColor(stcAttributes\lBackColor)
If StartDrawing(ImageOutput(srcTerminal\iImage[0]))
DrawingMode(#PB_2DDrawing_Default)
DrawingFont(FontID(FontID1))
If srcTerminal\bcurser = #True
If tabANSIBuffer(srcTerminal\lCurX / srcTerminal\lfont\cx, srcTerminal\lCurY / srcTerminal\lfont\cy) = #NULL$
Box(srcTerminal\lCurX, srcTerminal\lCurY, srcTerminal\lfont\cx, srcTerminal\lfont\cy, stcAttributes\lBackColor)
EndIf
If scrPosition\x < srcTerminal\tl
srcTerminal\lCurX = (scrPosition\x + 1) * srcTerminal\lfont\cx
srcTerminal\lCurY = scrPosition\y * srcTerminal\lfont\cy
If tabANSIBuffer(srcTerminal\lCurX / srcTerminal\lfont\cx, srcTerminal\lCurY / srcTerminal\lfont\cy) = #NULL$
Box(srcTerminal\lCurX, srcTerminal\lCurY, srcTerminal\lfont\cx, srcTerminal\lfont\cy, $ffffff)
EndIf
Else
srcTerminal\lCurX = 0
srcTerminal\lCurY = (scrPosition\y + 1) * srcTerminal\lfont\cy
If tabANSIBuffer(srcTerminal\lCurX / srcTerminal\lfont\cx, srcTerminal\lCurY / srcTerminal\lfont\cy) = #NULL$
Box(srcTerminal\lCurX, srcTerminal\lCurY, srcTerminal\lfont\cx, srcTerminal\lfont\cy, $ffffff)
EndIf
EndIf
EndIf
If stcAttributes\bReverseVideo = #False
DrawText(scrPosition\x * srcTerminal\lfont\cx, scrPosition\y * srcTerminal\lfont\cy, stext, scrTermColor(stcAttributes\lForeColor), scrTermColor(stcAttributes\lBackColor))
Else
DrawText(scrPosition\x * srcTerminal\lfont\cx, scrPosition\y * srcTerminal\lfont\cy, stext, scrTermColor(stcAttributes\lBackColor), scrTermColor(stcAttributes\lForeColor))
EndIf
StopDrawing()
EndIf
If StartDrawing(ImageOutput(srcTerminal\iImage[1]))
DrawingMode(#PB_2DDrawing_Default)
DrawingFont(FontID(FontID1))
If stcAttributes\bBlink = #False
If stcAttributes\bReverseVideo = #False
DrawText(scrPosition\x * srcTerminal\lfont\cx, scrPosition\y * srcTerminal\lfont\cy, stext, scrTermColor(stcAttributes\lForeColor), scrTermColor(stcAttributes\lBackColor))
Else
DrawText(scrPosition\x * srcTerminal\lfont\cx, scrPosition\y * srcTerminal\lfont\cy, stext, scrTermColor(stcAttributes\lBackColor), scrTermColor(stcAttributes\lForeColor))
EndIf
Else
If stcAttributes\bReverseVideo = #False
DrawText(scrPosition\x * srcTerminal\lfont\cx, scrPosition\y * srcTerminal\lfont\cy, " ", scrTermColor(stcAttributes\lForeColor), scrTermColor(stcAttributes\lBackColor))
Else
DrawText(scrPosition\x * srcTerminal\lfont\cx, scrPosition\y * srcTerminal\lfont\cy, " ", scrTermColor(stcAttributes\lBackColor), scrTermColor(stcAttributes\lForeColor))
EndIf
EndIf
StopDrawing()
EndIf
SetGadgetAttribute(srcTerminal\iCanva, #PB_Canvas_Image, ImageID(srcTerminal\iImage[0]))
EndIf
EndProcedure
Procedure Draw_SelectText(x.l, y.l, l.l, h.l)
;
Define i.l, j.l
Define sTemp.s
If l > srcTerminal\tl
l = srcTerminal\tl
EndIf
If h > srcTerminal\th
h = srcTerminal\th
EndIf
If StartDrawing(ImageOutput(srcTerminal\iImage[2]))
DrawingMode(#PB_2DDrawing_Default)
DrawingFont(FontID(FontID1))
DrawImage(ImageID(srcTerminal\iImage[0]), 0, 0)
If x <= l And y <= h
Box(x * srcTerminal\lfont\cx, y * srcTerminal\lfont\cy, ((l - x) + 1) * srcTerminal\lfont\cx, ((h - y) + 1) * srcTerminal\lfont\cy, $E0E0E0)
For j = y To h
For i = x To l
DrawText(i * srcTerminal\lfont\cx, j * srcTerminal\lfont\cy, tabANSIBuffer(i, j), $D28E58, $E0E0E0)
Next i
Next j
EndIf
StopDrawing()
SetGadgetAttribute(srcTerminal\iCanva, #PB_Canvas_Image, ImageID(srcTerminal\iImage[2]))
EndIf
EndProcedure
Procedure Draw_SelectCopy(x.l, y.l, l.l, h.l)
;
Define i.l, j.l
Define sTemp.s
If l > srcTerminal\tl
l = srcTerminal\tl
EndIf
If h > srcTerminal\th
h = srcTerminal\th
EndIf
If x <= l And y <= h
For j = y To h
sTemp = #NULL$
For i = x To l
If tabANSIBuffer(i, j) = #NULL$
sTemp + " "
Else
sTemp + tabANSIBuffer(i, j)
EndIf
Next i
Debug sTemp
Next j
EndIf
EndProcedure
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; +--------------------------------------------------------------------------+
; | |
; +--------------------------------------------------------------------------+
Procedure setTerminalPos()
;
Define x.l, y.l
If scrPosition\x < 0
scrPosition\x = 0
EndIf
If scrPosition\y < 0
scrPosition\y = 0
EndIf
If scrPosition\x => srcTerminal\tl
scrPosition\x = 0
scrPosition\y + 1
EndIf
If scrPosition\y => srcTerminal\th
Draw_TerminalDecalY()
scrPosition\x = 0
scrPosition\y = srcTerminal\th - 1
;
; DECALAGE DU TABLEAU MEMOIRE.
;
For y = 1 To #TERMINAL_MAXY
For x = 0 To #TERMINAL_MAXX
If y < #TERMINAL_MAXY
tabANSIBuffer(x, y - 1) = tabANSIBuffer(x, y)
tabAttributes(x, y - 1)\bBold = tabAttributes(x, y)\bBold
tabAttributes(x, y - 1)\bBlink = tabAttributes(x, y)\bBlink
tabAttributes(x, y - 1)\bItalic = tabAttributes(x, y)\bItalic
tabAttributes(x, y - 1)\bHidden = tabAttributes(x, y)\bHidden
tabAttributes(x, y - 1)\lForeColor = tabAttributes(x, y)\lForeColor
tabAttributes(x, y - 1)\lBackColor = tabAttributes(x, y)\lBackColor
Else
tabANSIBuffer(x, y - 1) = #NULL$
tabAttributes(x, y - 1)\bBold = #False
tabAttributes(x, y - 1)\bBlink = #False
tabAttributes(x, y - 1)\bItalic = #False
tabAttributes(x, y - 1)\bHidden = #False
tabAttributes(x, y - 1)\lForeColor = 7
tabAttributes(x, y - 1)\lBackColor = 0
EndIf
Next x
Next y
EndIf
EndProcedure
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; +--------------------------------------------------------------------------+
; | |
; +--------------------------------------------------------------------------+
Procedure.s Parser_ScnEnd(stext.s, len.i, lpos.l)
;
Define i.i
Define j.s
Define char.s = "0123456789;?="
For i=lpos To len Step 1
j + Mid(stext, i, 1)
If FindString(char, Mid(stext, i, 1)) = 0
Break
EndIf
Next i
ProcedureReturn j
EndProcedure
Procedure.s Parser_CharEnd(stext.s)
;
If Len(stext) > 1
ProcedureReturn Mid(stext, Len(stext), 1)
EndIf
ProcedureReturn stext
EndProcedure
Procedure Parser_VT100(stext.s)
;
Define i.i
Define j.i
Define k.i
Define l.i
Define car.s
Define fin.s
Define len.i
Define stemp.s{1}
len = Len(stext)
For i=1 To len Step 1
j = 0
car = #NULL$
fin = #NULL$
stemp = Mid(stext, i, 1)
If stemp <> #NULL$
If Asc(stemp) = 27
Select Mid(stext, i + 1, 1)
Case "#"
Select Mid(stext, i + 2, 1)
Case "3"
Case "4"
Case "5"
Case "6"
Case "8"
EndSelect
j = 1
Case "("
Select Mid(stext, i + 2, 1)
Case "0"
stcAttributes\bSpecialGraph = #True
Case "B"
stcAttributes\bSpecialGraph = #False
EndSelect
j = 1
Case ")"
Case "["
car = Parser_ScnEnd(stext, len, i + 2)
fin = Parser_CharEnd(car)
Select fin
Case "}"
If car = "}"
Else
Select Mid(car, 1, Len(car) - 1)
Case "0"
stcAttributes\bPBold = #False
stcAttributes\bPUnderline = #False
stcAttributes\bPBlink = #False
stcAttributes\bPReverseVideo = #False
Case "1"
stcAttributes\bPBold = #True
Case "4"
stcAttributes\bPUnderline = #True
Case "5"
stcAttributes\bPBlink = #True
Case "7"
stcAttributes\bPReverseVideo = #True
Case "254"
Debug "All attributes Off"
EndSelect
EndIf
Case "f"
If car = "f"
scrPosition\x = 0
scrPosition\y = 0
Else
k = CountString(car, ";")
If k = 0
scrPosition\x = Val(car) - 1
Else
scrPosition\x = Val(StringField(car, 1, ";")) - 1
scrPosition\y = Val(StringField(car, 0, ";")) - 1
EndIf
EndIf
Case "h"
If car = "h"
Else
Select Mid(car, 1, Len(car) - 1)
Case "?25"
srcTerminal\bcurser = #True
Case "?50"
srcTerminal\bcurser = #True
EndSelect
EndIf
Case "l"
If car = "l"
Else
Select Mid(car, 1, Len(car) - 1)
Case "?25"
srcTerminal\bcurser = #False
Case "?50"
srcTerminal\bcurser = #False
EndSelect
EndIf
Case "q"
If car = "q"
Debug "All Led Off"
Else
Select Mid(car, 1, Len(car) - 1)
Case "0"
Debug "All Led Off"
Case "1"
Debug "Led #1 On..."
Case "2"
Debug "Led #2 On..."
Case "3"
Debug "Led #3 On..."
Case "4"
Debug "Led #4 On..."
EndSelect
EndIf
Case "m"
If car = "m"
setAttributs(0)
Else
k = CountString(car, ";")
If k = 0
setAttributs(Val(Mid(car, 1, Len(car) - 1)))
Else
For l=1 To k + 1 Step 2
If l < k + 1
If Val(StringField(car, l, ";")) = 0 Or Val(StringField(car, l, ";")) = 1
setAttributs(Val(StringField(car, l + 1, ";")), Val(StringField(car, l + 0, ";")))
Else
setAttributs(Val(StringField(car, l + 0, ";")))
setAttributs(Val(StringField(car, l + 1, ";")))
EndIf
Else
setAttributs(Val(StringField(car, l, ";")))
EndIf
Next l
EndIf
EndIf
Case "s"
stcAttributes\lSavX = scrPosition\x
stcAttributes\lSavY = scrPosition\y
Case "u"
scrPosition\x = stcAttributes\lSavX
scrPosition\y = stcAttributes\lSavY
Case "y"
Case "A"
If car = "A"
scrPosition\y - 1
Else
scrPosition\y - Val(Mid(car, 1, Len(car) - 1))
EndIf
Case "B"
If car = "B"
scrPosition\y + 1
Else
scrPosition\y + Val(Mid(car, 1, Len(car) - 1))
EndIf
Case "C"
If car = "C"
scrPosition\x + 1
Else
scrPosition\x + Val(Mid(car, 1, Len(car) - 1))
EndIf
Case "D"
If car = "D"
scrPosition\x - 1
Else
scrPosition\x - Val(Mid(car, 1, Len(car) - 1))
EndIf
Case "E"
If car = "E"
scrPosition\y + 1
Else
scrPosition\y + Val(Mid(car, 1, Len(car) - 1))
EndIf
Case "H"
If car = "H"
scrPosition\x = 0
scrPosition\y = 0
Else
k = CountString(car, ";")
If k = 0
scrPosition\x + 1
scrPosition\y = Val(car) - 1
Else
scrPosition\x = Val(StringField(car, 2, ";")) - 1
scrPosition\y = Val(StringField(car, 1, ";")) - 1
EndIf
EndIf
Case "J"
If car = "J"
scrPosition\x = 0
scrPosition\y = 0
Draw_DeleteText()
Else
Select Mid(car, 1, 1)
Case "0"
Debug "Effacement de Pos au début"
Case "1"
Debug "Effacement de Pos a Fin"
Case "2"
scrPosition\x = 0
scrPosition\y = 0
Draw_DeleteText()
EndSelect
EndIf
Case "K"
If car = "K"
Else
Select Mid(car, 1, Len(car) - 1)
Case "0"
Case "1"
Case "2"
EndSelect
EndIf
Case "L"
If car = "L"
Debug "Insert 1 Lines"
Else
Debug "Insert " + Mid(car, 1, Len(car) - 1) + " Lines"
EndIf
EndSelect
j = Len(car)
Case "<"
j = 2
Case ">"
j = 2
Case "c"
scrPosition\y - 1
j = 2
Case "A"
scrPosition\y - 1
j = 2
Case "B"
scrPosition\y + 1
j = 2
Case "C"
scrPosition\x + 1
j = 2
Case "D"
scrPosition\x - 1
j = 2
Case "Z"
j = 2
Case ""
EndSelect
Else
Select Asc(stemp)
Case 4 ; FIN DE TRANSMISSION.
stemp = #NULL$
Case 7
Beep_(800, 150)
stemp = #NULL$
Case 8
scrPosition\x - 1
stemp = #NULL$
Case 10
scrPosition\y + 1
stemp = #NULL$
Case 11
scrPosition\y + 1
stemp = #NULL$
Case 12
scrPosition\y + 1
stemp = #NULL$
Case 13
scrPosition\x = 0
stemp = #NULL$
Case 17
stcAttributes\bXOff = #False
stemp = #NULL$
Case 18
stemp = #NULL$
Case 19
stcAttributes\bXOff = #True
stemp = #NULL$
Case 35
stemp = #NULL$
EndSelect
EndIf
If stemp <> #NULL$
If j = 0
If Asc(stemp) = 27
Debug stext
Debug car
EndIf
If stcAttributes\bSpecialGraph = #True
Select stemp
Case "b": stemp = Chr(9)
Case "c": stemp = Chr(12)
Case "d": stemp = Chr(13)
Case "e": stemp = Chr(10)
Case "j": stemp = Chr(217)
Case "k": stemp = Chr(191)
Case "l": stemp = Chr(218)
Case "m": stemp = Chr(192)
Case "q": stemp = Chr(196)
Case "t": stemp = Chr(195)
Case "u": stemp = Chr(180)
Case "x": stemp = Chr(179)
Case "{": stemp = Chr(227)
Case "~": stemp = Chr(249)
EndSelect
EndIf
setTerminalPos()
Draw_ANSIText(stemp)
scrPosition\x + 1
Else
i + (j + 1)
EndIf
EndIf
EndIf
Next i
EndProcedure
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; +--------------------------------------------------------------------------+
; | |
; +--------------------------------------------------------------------------+
Procedure.s SetFindWord(x.l, y.l)
; ROUTINE DE RECHERCHE DES MOTS DANS LE TABLEAU.
Define i.l
Define m.l = -1
Define n.l = -1
Define stemp.s
If x < 0
x = 0
EndIf
If x > srcTerminal\tl
x = srcTerminal\tl
EndIf
For i = 0 To srcTerminal\tl
If x - i > 0 And m = -1
If FindString("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ‚èéêëàáâäç&@.", tabANSIBuffer(x - i, y)) = 0 Or tabANSIBuffer(x, y) = " " Or tabANSIBuffer(x, y) = #NULL$
m = (x - i) + 1
EndIf
EndIf
If x + i <= srcTerminal\tl And n = -1
If FindString("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ‚èéêëàáâäç&@.", tabANSIBuffer(x + i, y)) = 0 Or tabANSIBuffer(x, y) = " " Or tabANSIBuffer(x, y) = #NULL$
n = (x + i) - 1
EndIf
EndIf
If m <> -1 And n <> -1
Break
EndIf
Next i
For i = m To n
If tabANSIBuffer(i, y) <> " " And tabANSIBuffer(i, y) <> #NULL$
stemp + tabANSIBuffer(i, y)
EndIf
Next i
If stemp <> #NULL$
ProcedureReturn stemp
EndIf
EndProcedure
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; +--------------------------------------------------------------------------+
; | |
; +--------------------------------------------------------------------------+
Define blnk.b
Define hWnd.i
Define event.i
Define evenp.i
Define eveng.i
Define eveng.i
Define bModeSave.b = #False
Dim saveCursor.point(1)
Define TimeOut.l = 400
Define Time.l = ElapsedMilliseconds()
hWnd = OpenWindow(#PB_Any, 0, 0, 960, 400, "", #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget | #PB_Window_ScreenCentered)
If hWnd <> 0
Terminal_Init()
Parser_VT100("[0m[2J(0[1;37m[1;0Hlqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk[3;0Hqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq[22;0Hqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq[24;0Hmqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj[2;1Hx[3;1Hx[4;1Hx[5;1Hx[06;01Hx[7;1Hx[8;1Hx[9;1Hx[10;1Hx[11;1Hx[12;1Hx[13;1Hx[14;1Hx[15;1Hx[16;1Hx[17;1Hx[18;1Hx[19;1Hx[20;1Hx[21;1Hx[22;1Hx[23;1Hx[2;80Hx[3;80Hx[4;80Hx[5;80Hx[6;80Hx[7;80Hx[8;80Hx[9;80Hx[10;80Hx[11;80Hx[12;80Hx[13;80Hx[14;80Hx[15;80Hx[16;80Hx[17;80Hx[18;80Hx[19;80Hx[20;80Hx[21;80Hx[22;80Hx[23;80Hx[3;0Ht[3;80Hu[22;0Ht[22;80Hu(B")
Parser_VT100("[02;28H[1;33mSYSCOM PRO VER: 3.0.0[0m")
Parser_VT100("[05;03H[1;37mVERIFICATION DES MISES A JOUR DE [0m[1;33mSYSCOM PRO[0m[1;37m VERSION 3.0.0[0m" + #CRLF$)
Parser_VT100("[07;03H[1;37mSYSCOM VERSION : [0m[1;33m?.?.?[0m" + #CRLF$)
Parser_VT100("[09;03H[1;37mMISE A JOUR : [0m[1;33m?????[0m" + #CRLF$)
Parser_VT100("[11;03H[1;37mIMPORTANCE : [0m[1;33m?????[0m" + #CRLF$)
Parser_VT100("[13;03H[1;37mEMAIL : [0m[1;33mmachin@truc.com[0m" + #CRLF$)
Define i.l
Define stemp.s
For i = 0 To 75
stemp = stemp + " "
Parser_VT100("[0m[23;" + Str(3 + i) + "H[1;37;0;41m ")
Next i
Parser_VT100("[0m[23;03H[1;37;0;41;5;7m MISE A JOUR NON DISPONIBLE (VERSION CORRECTE) [0m")
Define x.l, y.l
Define sTemp.s
For y = 0 To #TERMINAL_MAXY
sTemp = #NULL$
For x = 0 To #TERMINAL_MAXX
If tabANSIBuffer(x, y) = #NULL$
sTemp + " "
Else
sTemp + tabANSIBuffer(x, y)
EndIf
Next x
Debug RTrim(sTemp)
Next y
Repeat
event = WaitWindowEvent(50)
evenp = EventType()
eveng = EventGadget()
If event = #PB_Event_Gadget
If eveng = srcTerminal\iCanva
If evenp = #PB_EventType_LeftDoubleClick
Debug SetFindWord((GetGadgetAttribute(srcTerminal\iCanva, #PB_Canvas_MouseX) / srcTerminal\lfont\cx), (GetGadgetAttribute(srcTerminal\iCanva, #PB_Canvas_MouseY) / srcTerminal\lfont\cy))
EndIf
If evenp = #PB_EventType_LeftButtonDown Or (evenp = #PB_EventType_MouseMove And GetGadgetAttribute(srcTerminal\iCanva, #PB_Canvas_Buttons) & #PB_Canvas_LeftButton)
If bModeSave = #False
bModeSave = #True
saveCursor(1)\x = -1
saveCursor(1)\y = -1
saveCursor(0)\x = (GetGadgetAttribute(srcTerminal\iCanva, #PB_Canvas_MouseX) / srcTerminal\lfont\cx)
saveCursor(0)\y = (GetGadgetAttribute(srcTerminal\iCanva, #PB_Canvas_MouseY) / srcTerminal\lfont\cy)
Else
saveCursor(1)\x = (GetGadgetAttribute(srcTerminal\iCanva, #PB_Canvas_MouseX) / srcTerminal\lfont\cx)
saveCursor(1)\y = (GetGadgetAttribute(srcTerminal\iCanva, #PB_Canvas_MouseY) / srcTerminal\lfont\cy)
Draw_SelectText(saveCursor(0)\x, saveCursor(0)\y, saveCursor(1)\x, saveCursor(1)\y)
EndIf
Else
If bModeSave = #True
bModeSave = #False
If saveCursor(1)\x > -1 And saveCursor(1)\y > -1
Draw_SelectCopy(saveCursor(0)\x, saveCursor(0)\y, saveCursor(1)\x, saveCursor(1)\y)
Else
SetGadgetAttribute(srcTerminal\iCanva, #PB_Canvas_Image, ImageID(srcTerminal\iImage[0]))
EndIf
EndIf
EndIf
EndIf
EndIf
;If ElapsedMilliseconds() - Time > TimeOut
; blnk = (blnk + 1) % 2
; SetGadgetAttribute(srcTerminal\iCanva, #PB_Canvas_Image, ImageID(srcTerminal\iImage[blnk]))
; Time = ElapsedMilliseconds()
;EndIf
Until Event = #PB_Event_CloseWindow
EndIf
End
GallyHC
PS: c'est vraiment qu'un début
