$APPTYPE GUI $TYPECHECK ON $ESCAPECHARS ON ' - - - - - - - - - - - - - - - - - - - const and variable - - - - - - - - - - - - - - - - - - - - ' CONST ProgName$="Program ???????? Event ?? QRichEdit" CONST False = 0 CONST True = 1 '-- Control Alignments CONST alNone = 0 CONST alTop = 1 CONST alBottom = 2 CONST alLeft = 3 CONST alRight = 4 CONST alClient = 5 '-- Interface DIM Form AS QFORM DIM Box AS QRichEdit DIM PnBottom AS QPanel DIM DsBox AS QLISTBOX DIM ctrlspace AS QBUTTON '-- shift state CONST ssShift = 256 '-- valeur de travail Dim Motres as QMemorystream Dim Membre as QMemorystream Dim motcour as string ' - - - - - - - - - - - - - - - - - - - - valeur listbox - - - - - - - - - - - - - - - - - - - - ' sub listmotres DsBox.clear DsBox.AddItems ("ABS") DsBox.AddItems ("AS") DsBox.AddItems ("ASC") DsBox.AddItems ("ATN") DsBox.AddItems ("BIND") DsBox.AddItems ("Byte") DsBox.AddItems ("CALLFUNC") DsBox.AddItems ("CHDIR") DsBox.AddItems ("CHR$") DsBox.AddItems ("CLNG") DsBox.AddItems ("CONST") DsBox.AddItems ("COS") DsBox.AddItems ("DATE$") DsBox.AddItems ("DEC") DsBox.AddItems ("DELETE$") DsBox.AddItems ("DIM") DsBox.AddItems ("DIREXISTS") DsBox.AddItems ("DOEVENTS") DsBox.AddItems ("Double") DsBox.AddItems ("Dword") DsBox.AddItems ("END") DsBox.AddItems ("EXP") DsBox.AddItems ("FILEEXISTS") DsBox.AddItems ("HEX$") DsBox.AddItems ("INC") DsBox.AddItems ("INSERT$") DsBox.AddItems ("INSTR") DsBox.AddItems ("INT") DsBox.AddItems ("Integer") DsBox.AddItems ("KILL") DsBox.AddItems ("LBOUND") DsBox.AddItems ("LCASE$") DsBox.AddItems ("LEFT$") DsBox.AddItems ("LEN") DsBox.AddItems ("LOG") DsBox.AddItems ("Long") DsBox.AddItems ("LTRIM$") DsBox.AddItems ("MESSAGEDLG") DsBox.AddItems ("MID$") DsBox.AddItems ("MKDIR") DsBox.AddItems ("PLAYWAV") DsBox.AddItems ("POSTMESSAGE") DsBox.AddItems ("RANDOMIZE") DsBox.AddItems ("RENAME") DsBox.AddItems ("REPLACE$") DsBox.AddItems ("RIGHT$") DsBox.AddItems ("RMDIR") DsBox.AddItems ("RND") DsBox.AddItems ("ROUND") DsBox.AddItems ("RTRIM$") DsBox.AddItems ("RUN") DsBox.AddItems ("SENDMESSAGE") DsBox.AddItems ("SHELL") DsBox.AddItems ("Short") DsBox.AddItems ("SHOWMESSAGE") DsBox.AddItems ("SIN") DsBox.AddItems ("Single") DsBox.AddItems ("SPACE$") DsBox.AddItems ("SQR") DsBox.AddItems ("STR$") DsBox.AddItems ("STRING$") DsBox.AddItems ("SWAP") DsBox.AddItems ("TAN") DsBox.AddItems ("TIME$") DsBox.AddItems ("TIMER") DsBox.AddItems ("UBOUND") DsBox.AddItems ("UCASE$") DsBox.AddItems ("VAL") DsBox.AddItems ("Word") DsBox.ItemIndex=0 end sub ' - - - - - - - - - - - - - - - - - - - - EVENT - - - - - - - - - - - - - - - - - - - - ' SUB GoBack(Nombre AS integer, Remplac AS string) Box.SelStart=Box.SelStart - Nombre Box.SelLength = Nombre Box.Seltext = Remplac END SUB function test_char(ch1 as string, ch2 as string, def as integer) as integer 'Byte de marche pas :( ' on doit passé par la car le test "if Box.Seltext=chr$(j)" ne fonctionne pas >:( if ch1=ch2 then test_char=1 else test_char=def end if end function sub last_mot_sel(posi as integer) dim i as integer dim j as integer dim lok as integer 'letre ok i=posi DO i-- Box.SelStart=i Box.SelLength=1 lok=0 for j=48 to 57 'chifres lok=test_char(Box.Seltext, chr$(j),lok) next for j=65 to 90 'letre majuscules lok=test_char(Box.Seltext, chr$(j),lok) next for j=97 to 122 'letre minuscules lok=test_char(Box.Seltext, chr$(j),lok) next LOOP UNTIL (i <= 0 or lok=0) if lok=0 then i++ end if Box.SelStart=i Box.SelLength=posi-i END sub sub selist(mot as string) dim pointeur as integer dim i as integer dim j as integer dim ja as integer dim lenm as integer dim text1 as string dim text2 as string pointeur=0 i=0 j=-1 ja=DsBox.ItemCount-1 lenm=len(mot)-1 WHILE not((i > lenm) and (j>=ja)) if (j>=ja) then i++ j=0 else j++ end if text1=UCASE$(left$(mot,i)) text2=UCASE$(left$(DsBox.Item(j),i)) if (text1=text2) then pointeur=j j=ja end if wend DsBox.ItemIndex=pointeur end sub SUB CtrlSpaceClick 'completion du mot en cour last_mot_sel(Box.SelStart) box.Seltext=DsBox.Item(DsBox.ItemIndex) END SUB SUB boxKP(Key AS WORD, Shift AS INTEGER) 'redefinition de la complestion last_mot_sel(Box.SelStart) motcour= UCASE$(box.Seltext) Box.SelStart = Box.SelStart + Box.SelLength Box.SelLength=0 if shift=1 and key=32 then GoBack(1,"") CtrlSpaceClick() else selist(motcour) end if END SUB ' - - - - - - - - - - - - - - - - - - - - INTERFACE - - - - - - - - - - - - - - - - - - - - ' with Form .Width = 500:.Height = 320:.Center end with with Box:.Parent = form .Align = alClient .onKeyup = boxKP .WantTabs = True .Tag = 1 .ScrollBars=3 .wordwrap=0 end with with PnBottom:.Parent = form .Align = alBottom .Height = 60 end with with DsBox:.Parent = PnBottom .Align = alClient .Color=&HCCFFFF .ShowHint = True end with with ctrlspace:.Parent = PnBottom .Align = alRight .Width = 90 .Caption = "[Ctrl] + [Space]" .onClick = CtrlSpaceClick end with 'initialisation des valeurs listmotres Form.SHOWMODAL