| 1 | REBOL [
|
|---|
| 2 | AUTHORS: "Shadwolf (strike again)"
|
|---|
| 3 | AppName: "RTE-line"
|
|---|
| 4 | PURPOSE: {Apr�s m�re r�flection et comme R3 est toujours pas d'actualit� j'ai d�cid� de travailler
|
|---|
| 5 | de mon cot� � la r�alisation d'une Widget pour rebol/view VID2.0
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 | Voici ce que je compte impl�menter
|
|---|
| 10 |
|
|---|
| 11 | une ligne a un nombre de 80 charactere
|
|---|
| 12 | On affiche la ligne dans une face toute simple et on utilisera face/effect/draw pour realiser l'affichage
|
|---|
| 13 | On utilisera les events clavier et sourie pour inserer le texte.
|
|---|
| 14 | Le formatage du texte se fera pardes bouton externe et une ligne nous indiquera quel est le mode courant.
|
|---|
| 15 |
|
|---|
| 16 | La saisie des evenements claviers renseignera un "objet" qui aura les donn�es suivantes:
|
|---|
| 17 | position, char_ASCII, fnt_couleur
|
|---|
| 18 | Le curseur se d�placera au clavier ou a l'aide de la sourie.
|
|---|
| 19 |
|
|---|
| 20 | D�placements du curseur au clavier:
|
|---|
| 21 | A partir de le position courant du curseur on ira chercher la position du caract�re le plus proche de cette position
|
|---|
| 22 | ainsi le curseur se d�placera au bon endroit quelque soit la taille du caract�re pr�c�dent
|
|---|
| 23 |
|
|---|
| 24 | D�placement du curseur � la sourie:
|
|---|
| 25 | quand on cliquera sur une position relative et dans notre table index�e (ou la position sert d'indexe)
|
|---|
| 26 | la position la plus proche et on placera le curseur a cette position
|
|---|
| 27 |
|
|---|
| 28 | La table serra tri�e par sort/all
|
|---|
| 29 |
|
|---|
| 30 | table de ash (enfin table des caract�res saisies index�e en fontion de leur position
|
|---|
| 31 |
|
|---|
| 32 | [ [0x0 "a" red bold 12]
|
|---|
| 33 | [0x5 "b" green underline 25]
|
|---|
| 34 | [0x30 "c" yellow normal 25]
|
|---|
| 35 | ]
|
|---|
| 36 |
|
|---|
| 37 | Cette table sera trait� par un moteur de dessin draw/AGG
|
|---|
| 38 |
|
|---|
| 39 | On poura aussi y adjoindre un autre moteur pour les besoin de sauvegarde typ�e.. (MDP etc...)
|
|---|
| 40 |
|
|---|
| 41 | Insertion de nouveaux caract�res dans un texte deja existant:
|
|---|
| 42 |
|
|---|
| 43 | Lors de la saisie du nouveau caract�re on d�tecte si a la position actuelle du curseur il ya deja un caract�re
|
|---|
| 44 | Si tel est le cas on parcours la liste et on applique une incr�mentation des valeur de position dans la liste a partir
|
|---|
| 45 | de la position trouv�e.
|
|---|
| 46 | Comme chaque caract�re est g�r� de fa�on propre ca aura pour effet de d�caler tout le bloc
|
|---|
| 47 |
|
|---|
| 48 | une autre impl�mentation possible ce serrait les objet li�s un peu dans le genre d'une liste chain�e de struct! en C
|
|---|
| 49 | comme c'est plus dificile a mettre en place je testerai ca dans une �volution
|
|---|
| 50 |
|
|---|
| 51 | La hauteur de la ligne doit d�pendre de la taille du texte le plus haut.
|
|---|
| 52 | Le text plus petit doit etre dessendu en bas de la ligne.
|
|---|
| 53 |
|
|---|
| 54 | La touche entr�e ne fait rien elle servira dans la version multiline.
|
|---|
| 55 |
|
|---|
| 56 | A FAire:
|
|---|
| 57 | - magentisation vers le bas de la widget du text de plus petite taille
|
|---|
| 58 | - selection de text avec les actions correspondante
|
|---|
| 59 | - Am�lioration globale du code.(virer les switch et trouver une bonne �quation pour calculer la taille des caract�res)
|
|---|
| 60 | - Am�liorer la repr�sentation des donn�es en vue d'un traitement de plus grande donn�es.
|
|---|
| 61 |
|
|---|
| 62 | NOUVEAU 27/01/2010:
|
|---|
| 63 |
|
|---|
| 64 |
|
|---|
| 65 |
|
|---|
| 66 | OK on va tester les id�e propos�e par DIDEC qui mettent en oeuvre caret to offset
|
|---|
| 67 | et une speudo face servant a faire les teste
|
|---|
| 68 |
|
|---|
| 69 |
|
|---|
| 70 | Toute l'algorithmie de d�placement du faux curseur et de positionnement des �l�ment est a chang�e.
|
|---|
| 71 |
|
|---|
| 72 | }
|
|---|
| 73 |
|
|---|
| 74 | ]
|
|---|
| 75 |
|
|---|
| 76 | ;test face for char size evaluation
|
|---|
| 77 | font1: make face/font [size: 20 align: 'left valign: 'top offset: 0x0]
|
|---|
| 78 | ff: make face [font: font1 size: 1000x1000 para: make face/para [origin: 0x0 margin: 0x0] edge: make face/edge [size: 0x0]]
|
|---|
| 79 |
|
|---|
| 80 | stylize/master [
|
|---|
| 81 |
|
|---|
| 82 |
|
|---|
| 83 |
|
|---|
| 84 | rte: box with [
|
|---|
| 85 | ; face ou l'on affiche les choses
|
|---|
| 86 | color: gray
|
|---|
| 87 | ascii-char-tab: make [] ; table ou on stoquera tout ce que l'on va dessiner
|
|---|
| 88 |
|
|---|
| 89 | char-sz: 12
|
|---|
| 90 | font-st: none
|
|---|
| 91 | stored-curs-position: none
|
|---|
| 92 | current-text-offset: 5x0
|
|---|
| 93 | cursor-text-offset: 5x0
|
|---|
| 94 | max-text-offset: 0x0
|
|---|
| 95 | text-color: black
|
|---|
| 96 | tmp-ascii-char: none
|
|---|
| 97 | pane: []
|
|---|
| 98 | draw-text: none
|
|---|
| 99 | rm-char-sz: none
|
|---|
| 100 | found_existing_coord: false
|
|---|
| 101 | end-offset: none
|
|---|
| 102 | tmp: none tmp2: none
|
|---|
| 103 | f-name: none
|
|---|
| 104 | set-font-style: func [ font-s [word!] sz-tt [integer!] ] [
|
|---|
| 105 | if char-sz <> sz-tt [
|
|---|
| 106 | if char-sz < sz-tt [
|
|---|
| 107 | size/y: sz-tt + 15
|
|---|
| 108 | self/pane/1/size/y: size/y
|
|---|
| 109 | show self
|
|---|
| 110 | ]
|
|---|
| 111 | char-sz: sz-tt
|
|---|
| 112 | ]
|
|---|
| 113 | font-st: font-s
|
|---|
| 114 | ;insert tail buffer/:line-index compose/deep [[ [ space: 2x0 size: (char-sz) style: [(font-s)] color: (text-color)] (cursor-text-offset - 6x0) "" ]]
|
|---|
| 115 | ]
|
|---|
| 116 | feel: make feel [
|
|---|
| 117 | detect: func [f event] [
|
|---|
| 118 | ;probe event/type
|
|---|
| 119 | ;probe event/offset
|
|---|
| 120 |
|
|---|
| 121 | if event/type == 'down [
|
|---|
| 122 | if not empty? f/ascii-char-tab [
|
|---|
| 123 | f/tmp: event/offset - f/offset
|
|---|
| 124 | foreach item f/ascii-char-tab [
|
|---|
| 125 | if item/1/x < f/tmp/x [
|
|---|
| 126 | either item/1/x = first first last f/ascii-char-tab [
|
|---|
| 127 | f/stored-curs-position: item/1
|
|---|
| 128 | f/stored-curs-position/x: item/1/x + (( item/3 / 2) - 1)
|
|---|
| 129 | ][
|
|---|
| 130 | f/stored-curs-position: item/1
|
|---|
| 131 |
|
|---|
| 132 | ]
|
|---|
| 133 | ]
|
|---|
| 134 | ]
|
|---|
| 135 | f/pane/1/offset: f/stored-curs-position
|
|---|
| 136 | f/cursor-text-offset: f/stored-curs-position
|
|---|
| 137 | show f
|
|---|
| 138 | ]
|
|---|
| 139 | ]
|
|---|
| 140 | event
|
|---|
| 141 | ]
|
|---|
| 142 | engage: func [f a e] [
|
|---|
| 143 | switch a [
|
|---|
| 144 | key [
|
|---|
| 145 | ; probe e/key
|
|---|
| 146 | switch/default e/key [
|
|---|
| 147 | #"^M" [ ; touche entrer
|
|---|
| 148 | ; pas impl�menter pour l'instant
|
|---|
| 149 | ]
|
|---|
| 150 | #"^[" [ ;touche escape ne fait rien
|
|---|
| 151 | ]
|
|---|
| 152 | right [ ;touche fleche droite
|
|---|
| 153 | if not empty? f/ascii-char-tab [
|
|---|
| 154 | f/end-offset: first last f/ascii-char-tab
|
|---|
| 155 | foreach item f/ascii-char-tab [
|
|---|
| 156 | if item/1/x == f/end-offset/x [
|
|---|
| 157 | f/stored-curs-position: item/1
|
|---|
| 158 | f/stored-curs-position/x: item/1/x + (( item/3 / 2) - 1)
|
|---|
| 159 | f/pane/1/offset: f/stored-curs-position
|
|---|
| 160 | f/cursor-text-offset: f/stored-curs-position
|
|---|
| 161 | break
|
|---|
| 162 | ]
|
|---|
| 163 | if item/1/x > f/cursor-text-offset/x [
|
|---|
| 164 | f/stored-curs-position: item/1
|
|---|
| 165 | f/pane/1/offset: f/stored-curs-position
|
|---|
| 166 | f/cursor-text-offset: f/stored-curs-position
|
|---|
| 167 | break
|
|---|
| 168 | ]
|
|---|
| 169 |
|
|---|
| 170 | ]
|
|---|
| 171 | ]
|
|---|
| 172 | ]
|
|---|
| 173 | left [ ; touche fl�che gauche
|
|---|
| 174 | if not empty? f/ascii-char-tab [
|
|---|
| 175 | foreach item f/ascii-char-tab [
|
|---|
| 176 | if item/1/x < f/cursor-text-offset/x [
|
|---|
| 177 | f/stored-curs-position: item/1
|
|---|
| 178 | ]
|
|---|
| 179 | ]
|
|---|
| 180 | f/pane/1/offset: f/stored-curs-position
|
|---|
| 181 | f/cursor-text-offset: f/stored-curs-position
|
|---|
| 182 | ]
|
|---|
| 183 | ]
|
|---|
| 184 | down [ ; A FAIRE si on g�re les lignes multiples
|
|---|
| 185 | ]
|
|---|
| 186 | up [ ; A FAIRE si on g�re les lignes multiples
|
|---|
| 187 | ]
|
|---|
| 188 | #"^~" [ ; touche suppr
|
|---|
| 189 | ;A FAIRE
|
|---|
| 190 | ;ajouter dans l'algo la prise en compte de la lettre courante dans le recalcul de
|
|---|
| 191 | ;la position des lettre quand on les d�place
|
|---|
| 192 | ; si la lettre est "fijlt" alors au lieu d'attribuer � la lettre suivante la position de la lettre courante
|
|---|
| 193 | f/end-offset: first last f/ascii-char-tab
|
|---|
| 194 | f/end-offset/x: f/end-offset/x + (((third last f/ascii-char-tab ) / 2 ) - 1)
|
|---|
| 195 | f/tmp: none
|
|---|
| 196 | f/tmp2: none
|
|---|
| 197 | if f/cursor-text-offset/x <> f/end-offset/x [
|
|---|
| 198 | ; on supprime le char correspondant a la position actuelle du curseur
|
|---|
| 199 | f/tmp-ascii-char: copy []
|
|---|
| 200 | foreach item f/ascii-char-tab [
|
|---|
| 201 | either item/1/x <> f/cursor-text-offset/x [
|
|---|
| 202 | insert tail f/tmp-ascii-char reduce [ item ]
|
|---|
| 203 | ][
|
|---|
| 204 | f/tmp: item/1 ; on stock la position du char supprimer pour s'en servir dans l'algo de d�calage
|
|---|
| 205 | ]
|
|---|
| 206 | ]
|
|---|
| 207 | f/ascii-char-tab: copy f/tmp-ascii-char
|
|---|
| 208 | f/tmp-ascii-char: copy []
|
|---|
| 209 | ; on d�place les caract�res apres la position du curseur en tennant compte de la taille du car suppr
|
|---|
| 210 | ; pour calculer le d�calage a appliquer
|
|---|
| 211 | foreach item f/ascii-char-tab [
|
|---|
| 212 | if item/1/x > f/cursor-text-offset/x [
|
|---|
| 213 | either f/tmp2 == none [
|
|---|
| 214 | either find "fijlt" item/2 [
|
|---|
| 215 | f/tmp2: item/1
|
|---|
| 216 | f/tmp2/x: f/tmp2/x - (( item/3 / 2 ) - 3)
|
|---|
| 217 | ][
|
|---|
| 218 | f/tmp2: item/1
|
|---|
| 219 | ]
|
|---|
| 220 | item/1/x: f/tmp/x
|
|---|
| 221 | f/tmp: none
|
|---|
| 222 | ][
|
|---|
| 223 | either find "fijlt" item/2 [
|
|---|
| 224 | f/tmp: item/1
|
|---|
| 225 | f/tmp/x: f/tmp/x - (( item/3 / 2 )- 3)
|
|---|
| 226 | ][
|
|---|
| 227 | f/tmp: item/1
|
|---|
| 228 | ]
|
|---|
| 229 | item/1/x: f/tmp2/x
|
|---|
| 230 | f/tmp2: none
|
|---|
| 231 | ]
|
|---|
| 232 | ]
|
|---|
| 233 | ]
|
|---|
| 234 | f/tmp: none
|
|---|
| 235 | ;on redessine a l'�cran
|
|---|
| 236 | f/draw-text: copy []
|
|---|
| 237 | foreach char f/ascii-char-tab [
|
|---|
| 238 | font-obj: make face/font compose/deep [space: 2x0 size: (char/3) style: [(char/4)] color: (char/5)]
|
|---|
| 239 | insert tail f/draw-text compose [ font (font-obj) pen (font-obj/color) text (char/1) (char/2)]
|
|---|
| 240 | ]
|
|---|
| 241 | f/effect: none
|
|---|
| 242 | f/effect: make effect reduce [ 'draw (f/draw-text) ]
|
|---|
| 243 |
|
|---|
| 244 | ]
|
|---|
| 245 | ]
|
|---|
| 246 | #"^H" [ ; touche backspace
|
|---|
| 247 | ; parcourt le block de donn�es et on cherche la position
|
|---|
| 248 | ; la plus proche de la position actuelle du curseur
|
|---|
| 249 |
|
|---|
| 250 |
|
|---|
| 251 | ; OLD ALGORITHM !!
|
|---|
| 252 |
|
|---|
| 253 | ; if not empty? f/ascii-char-tab [
|
|---|
| 254 | ; f/tmp: first first f/ascii-char-tab
|
|---|
| 255 | ; ]
|
|---|
| 256 | ; if f/cursor-text-offset/x <> f/tmp/x [
|
|---|
| 257 | ; foreach item f/ascii-char-tab [
|
|---|
| 258 | ; if item/1/x < f/cursor-text-offset/x [
|
|---|
| 259 | ; f/stored-curs-position: item/1
|
|---|
| 260 | ; ]
|
|---|
| 261 | ; ]
|
|---|
| 262 | ; f/tmp: none
|
|---|
| 263 | ; f/tmp2: none
|
|---|
| 264 | ; ;on supprime l'element dont la position correspond a
|
|---|
| 265 | ; f/tmp-ascii-char: copy []
|
|---|
| 266 | ; foreach item f/ascii-char-tab [
|
|---|
| 267 | ; either item/1/x <> f/stored-curs-position/x [
|
|---|
| 268 | ; insert tail f/tmp-ascii-char reduce [ item ]
|
|---|
| 269 | ; ][ ;f/rm-char-sz: item/3
|
|---|
| 270 | ; f/tmp: item/1
|
|---|
| 271 | ; ]
|
|---|
| 272 | ; if item/1/x > f/stored-curs-position/x [
|
|---|
| 273 | ; either f/tmp2 == none [
|
|---|
| 274 | ; either find "fijltr" item/2 [
|
|---|
| 275 | ; f/tmp2: item/1
|
|---|
| 276 | ; f/tmp2/x: f/tmp2/x - (( item/3 / 2 ) - 3)
|
|---|
| 277 | ; ][
|
|---|
| 278 | ; f/tmp2: item/1
|
|---|
| 279 | ; ]
|
|---|
| 280 | ; item/1/x: f/tmp/x
|
|---|
| 281 | ; f/tmp: none
|
|---|
| 282 | ; ][
|
|---|
| 283 | ; either find "fijltr" item/2 [
|
|---|
| 284 | ; f/tmp: item/1
|
|---|
| 285 | ; f/tmp/x: f/tmp/x - (( item/3 / 2 )- 3)
|
|---|
| 286 | ; ][
|
|---|
| 287 | ; f/tmp: item/1
|
|---|
| 288 | ; ]
|
|---|
| 289 | ; item/1/x: f/tmp2/x
|
|---|
| 290 | ; f/tmp2: none
|
|---|
| 291 | ; ]
|
|---|
| 292 | ; ]
|
|---|
| 293 | ; ]
|
|---|
| 294 | ;
|
|---|
| 295 | ; f/ascii-char-tab: none
|
|---|
| 296 | ;
|
|---|
| 297 | ; f/ascii-char-tab: copy f/tmp-ascii-char
|
|---|
| 298 | ; f/tmp-ascii-char: none
|
|---|
| 299 | ;
|
|---|
| 300 | ; ; on d�place le curseur a la stored-position
|
|---|
| 301 | ; f/pane/1/offset: f/stored-curs-position
|
|---|
| 302 | ; f/cursor-text-offset: f/stored-curs-position
|
|---|
| 303 | ; ; on redessine la ligne avec les nouvelle donn�es
|
|---|
| 304 | ; ;on fabrique le block de donn�e draw
|
|---|
| 305 | ; f/draw-text: copy []
|
|---|
| 306 | ; foreach char f/ascii-char-tab [
|
|---|
| 307 | ; font-obj: make face/font compose/deep [space: 2x0 size: (char/3) style: [(char/4)] color: (char/5) name: "font-serif" ]
|
|---|
| 308 | ; insert tail f/draw-text compose [ font (font-obj) pen (font-obj/color) text (char/1) (char/2)]
|
|---|
| 309 | ; ]
|
|---|
| 310 | ; ;on dessine le contenu de du block de donn�e draw
|
|---|
| 311 | ; f/effect: none
|
|---|
| 312 | ;
|
|---|
| 313 | ; f/effect: make effect reduce [ 'draw (f/draw-text) ]
|
|---|
| 314 | ; ]
|
|---|
| 315 | ; code d'example pour transformer ascii-char-tab en table de hash ce qui facilite les
|
|---|
| 316 | ; modifications
|
|---|
| 317 | ;hash-tab: [] foreach i ascii-char-tab [ insert tail b reduce [ i/1 reduce [ i/2 i/3 i/4 i/5 ] ] ]
|
|---|
| 318 |
|
|---|
| 319 | ]
|
|---|
| 320 | ][
|
|---|
| 321 | ;si la position est deja pr�sente dans la liste alors ca veux dire que la position nouvelle
|
|---|
| 322 | ; lettre que l'on va ins�rer dans la liste est d�j� prise.
|
|---|
| 323 | ; il faut prendre en compte aussi la taille des lettres qui pr�c�de la position d'insertion
|
|---|
| 324 |
|
|---|
| 325 | ;/***
|
|---|
| 326 | ;nouvel algo
|
|---|
| 327 | comment {
|
|---|
| 328 | 1) on recherche si la position courante du curseur est deja attribu�e a un element de la liste
|
|---|
| 329 | 2) on calcule la taille en pixel de la nouvelle lettre. (face cach�e + sizetext)
|
|---|
| 330 |
|
|---|
| 331 | 3) on insert le nouvel �l�ment dans la liste ainsi que sa taille dans la liste
|
|---|
| 332 | 4) on decale tout les �l�mets suivant si besoin est enfonction de la taille du novelle �l�ment
|
|---|
| 333 | 5) on cr�e le nouveau block draw
|
|---|
| 334 | 6) on place le curseur juste apres la nouvelle lettre.
|
|---|
| 335 |
|
|---|
| 336 |
|
|---|
| 337 | }
|
|---|
| 338 | ;/****
|
|---|
| 339 | ;calcule la taille en X de notre nouvelle lettre saisie
|
|---|
| 340 | ; font1: make face/font compose/deep [ size: (f/char-sz) style: [(to-word f/font-st)] color: (f/text-color) name: "font-serif" ] ; la font est adapter avec les informations dynamique courante evidement
|
|---|
| 341 | font1/style: compose [ ( to-word f/font-st) ]
|
|---|
| 342 | font1/size: f/char-sz
|
|---|
| 343 | font1/color: f/text-color font1/name: "font-serif"
|
|---|
| 344 | ;probe font1
|
|---|
| 345 | ;char-sz-decalage: size-text fu: make ff [font: font1 text: e/key]
|
|---|
| 346 | fu: make ff [font: font1 text: rejoin [ e/key "M"]]
|
|---|
| 347 | txt-test: fu/text
|
|---|
| 348 | forall txt-test [
|
|---|
| 349 | char-sz-decalage: caret-to-offset fu txt-test
|
|---|
| 350 | probe char-sz-decalage
|
|---|
| 351 | ]
|
|---|
| 352 | probe char-sz-decalage
|
|---|
| 353 | ;recherche si la position de du curser existe deja et si oui nous d�callons tout les �l�ments de la taille de notre nouvelle lettre
|
|---|
| 354 |
|
|---|
| 355 | foreach item f/ascii-char-tab [
|
|---|
| 356 | if item/1 == f/cursor-text-offset [
|
|---|
| 357 | f/found_existing_coord: true
|
|---|
| 358 | ]
|
|---|
| 359 | if f/found_existing_coord [
|
|---|
| 360 | item/1/x: item/1/x + char-sz-decalage/x
|
|---|
| 361 | ]
|
|---|
| 362 | ]
|
|---|
| 363 | f/found_existing_coord: false
|
|---|
| 364 |
|
|---|
| 365 |
|
|---|
| 366 | ;on insert notre �l�ment dans ascii tab
|
|---|
| 367 | ascii-char-item: compose [ (f/cursor-text-offset) (to-string e/key) (f/char-sz) (f/font-st) (f/text-color) (f/f-name) ]
|
|---|
| 368 | f/draw-text: copy []
|
|---|
| 369 | ;
|
|---|
| 370 | ; ; on insert ascii-char-item dans notre table;
|
|---|
| 371 | insert tail f/ascii-char-tab reduce [(ascii-char-item)]
|
|---|
| 372 | ;on fabrique le block de donn�e draw
|
|---|
| 373 | ;
|
|---|
| 374 | foreach char f/ascii-char-tab [
|
|---|
| 375 | font-obj: make face/font compose/deep [space: 0x0 size: (char/3) style: [(char/4)] color: (char/5) name: (char/6) ]
|
|---|
| 376 | insert tail f/draw-text compose [ font (font-obj) pen (font-obj/color) text (char/1) (char/2)]
|
|---|
| 377 | ]
|
|---|
| 378 | ; ;on dessine le contenu de du block de donn�e draw
|
|---|
| 379 | f/effect: none
|
|---|
| 380 | f/effect: make effect reduce [ 'draw (f/draw-text) ]
|
|---|
| 381 | ;
|
|---|
| 382 | ; ;probe f/effect
|
|---|
| 383 | ; ; on d�place la position actuelle du curseur
|
|---|
| 384 | f/cursor-text-offset/x: f/cursor-text-offset/x + char-sz-decalage/x
|
|---|
| 385 | f/pane/1/offset: f/cursor-text-offset
|
|---|
| 386 | sort/all f/ascii-char-tab
|
|---|
| 387 |
|
|---|
| 388 | ; I LET THE PREVIOUS ALGORITHM TO SHOW YOU THE PROGRESSION
|
|---|
| 389 | ; IN MY THINKING WAY
|
|---|
| 390 |
|
|---|
| 391 | ; foreach item f/ascii-char-tab [
|
|---|
| 392 | ; if item/1 == f/cursor-text-offset [
|
|---|
| 393 | ; f/found_existing_coord: true
|
|---|
| 394 | ; ]
|
|---|
| 395 | ; if f/found_existing_coord [
|
|---|
| 396 | ; switch f/char-sz [
|
|---|
| 397 | ; 12 [
|
|---|
| 398 | ; either find "fijltr" e/key [
|
|---|
| 399 | ; item/1/x: item/1/x + 2
|
|---|
| 400 | ; ][
|
|---|
| 401 | ; either find "mw" e/key [
|
|---|
| 402 | ; item/1/x: item/1/x + 7
|
|---|
| 403 | ; ][
|
|---|
| 404 | ; item/1/x: item/1/x + 5
|
|---|
| 405 | ; ]
|
|---|
| 406 | ; ]
|
|---|
| 407 | ; ]
|
|---|
| 408 | ; 20 [
|
|---|
| 409 | ; either find "fijltr" e/key [
|
|---|
| 410 | ; item/1/x: item/1/x + 5
|
|---|
| 411 | ; ][
|
|---|
| 412 | ; either find "mw" e/key [
|
|---|
| 413 | ; item/1/x: item/1/x + 15
|
|---|
| 414 | ; ][
|
|---|
| 415 | ; item/1/x: item/1/x + 12
|
|---|
| 416 | ; ]
|
|---|
| 417 | ; ]
|
|---|
| 418 | ; ]
|
|---|
| 419 | ; 30 [
|
|---|
| 420 | ; either find "fijltr" e/key [
|
|---|
| 421 | ; item/1/x: item/1/x + 11
|
|---|
| 422 | ; ][
|
|---|
| 423 | ; either find "mw" e/key [
|
|---|
| 424 | ; item/1/x: item/1/x + 22
|
|---|
| 425 | ; ][
|
|---|
| 426 | ; item/1/x: item/1/x + 20
|
|---|
| 427 | ; ]
|
|---|
| 428 | ; ]
|
|---|
| 429 | ; ]
|
|---|
| 430 | ;
|
|---|
| 431 | ; ]
|
|---|
| 432 | ; either find "MW" e/key [
|
|---|
| 433 | ; item/1/x: item/1/x + 3
|
|---|
| 434 | ;
|
|---|
| 435 | ; ][
|
|---|
| 436 | ; if find "ABCDEFGHIJKLNOPQRSTUVXYZ" e/key [
|
|---|
| 437 | ; item/1/x: item/1/x + 2
|
|---|
| 438 | ; ]
|
|---|
| 439 | ; ]
|
|---|
| 440 | ; ]
|
|---|
| 441 | ;
|
|---|
| 442 | ; ]
|
|---|
| 443 | ; f/found_existing_coord: false
|
|---|
| 444 | ;
|
|---|
| 445 | ; l-fnt-disp/text: rejoin [ to-string f/char-sz "," to-string f/font-st "," to-string f/text-color ]
|
|---|
| 446 | ; show l-fnt-disp
|
|---|
| 447 | ; ;
|
|---|
| 448 | ; ascii-char-item: compose [ (f/cursor-text-offset) (to-string e/key) (f/char-sz) (f/font-st) (f/text-color) ]
|
|---|
| 449 | ; ;ascii-char-item a l'emplacement actuel du curseur, le char saisi, la taille de la fnt,
|
|---|
| 450 | ; ; le style de la font,la couleur de la font
|
|---|
| 451 | ; ;
|
|---|
| 452 | ; f/draw-text: copy []
|
|---|
| 453 | ;
|
|---|
| 454 | ; ; on insert ascii-char-item dans notre table
|
|---|
| 455 | ; insert tail f/ascii-char-tab reduce [(ascii-char-item)]
|
|---|
| 456 | ; ;on fabrique le block de donn�e draw
|
|---|
| 457 | ;
|
|---|
| 458 | ; foreach char f/ascii-char-tab [
|
|---|
| 459 | ; font-obj: make face/font compose/deep [space: 2x0 size: (char/3) style: [(char/4)] color: (char/5)name: "font-serif" ]
|
|---|
| 460 | ; insert tail f/draw-text compose [ font (font-obj) pen (font-obj/color) text (char/1) (char/2)]
|
|---|
| 461 | ; ]
|
|---|
| 462 | ; ;on dessine le contenu de du block de donn�e draw
|
|---|
| 463 | ; f/effect: none
|
|---|
| 464 | ; f/effect: make effect reduce [ 'draw (f/draw-text) ]
|
|---|
| 465 | ;
|
|---|
| 466 | ; ;probe f/effect
|
|---|
| 467 | ; ; on d�place la position actuelle du curseur
|
|---|
| 468 | ;
|
|---|
| 469 | ; switch f/char-sz [
|
|---|
| 470 | ; 12 [
|
|---|
| 471 | ; either find "fijltr" e/key [
|
|---|
| 472 | ; f/cursor-text-offset/x: f/cursor-text-offset/x + 2
|
|---|
| 473 | ; ][
|
|---|
| 474 | ; either find "mw" e/key [
|
|---|
| 475 | ; f/cursor-text-offset/x: f/cursor-text-offset/x + 7
|
|---|
| 476 | ; ][
|
|---|
| 477 | ; f/cursor-text-offset/x: f/cursor-text-offset/x + 5
|
|---|
| 478 | ; ]
|
|---|
| 479 | ; ]
|
|---|
| 480 | ; ]
|
|---|
| 481 | ; 20 [
|
|---|
| 482 | ; either find "fijltr" e/key [
|
|---|
| 483 | ; f/cursor-text-offset/x: f/cursor-text-offset/x + 5
|
|---|
| 484 | ; ][
|
|---|
| 485 | ; either find "mw" e/key [
|
|---|
| 486 | ; f/cursor-text-offset/x: f/cursor-text-offset/x + 15
|
|---|
| 487 | ; ][
|
|---|
| 488 | ; f/cursor-text-offset/x: f/cursor-text-offset/x + 12
|
|---|
| 489 | ; ]
|
|---|
| 490 | ; ]
|
|---|
| 491 | ; ]
|
|---|
| 492 | ; 30 [
|
|---|
| 493 | ; either find "fijltr" e/key [
|
|---|
| 494 | ; f/cursor-text-offset/x: f/cursor-text-offset/x + 11
|
|---|
| 495 | ; ][
|
|---|
| 496 | ; either find "mw" e/key [
|
|---|
| 497 | ; f/cursor-text-offset/x: f/cursor-text-offset/x + 22
|
|---|
| 498 | ; ][
|
|---|
| 499 | ; f/cursor-text-offset/x: f/cursor-text-offset/x + 20
|
|---|
| 500 | ; ]
|
|---|
| 501 | ;
|
|---|
| 502 | ; ]
|
|---|
| 503 | ; ]
|
|---|
| 504 | ; ]
|
|---|
| 505 | ; either find "MW" e/key [
|
|---|
| 506 | ; f/cursor-text-offset/x: f/cursor-text-offset/x + 3
|
|---|
| 507 | ;
|
|---|
| 508 | ; ][
|
|---|
| 509 | ; if find "ABCDEFGHIJKLNOPQRSTUVXYZ" e/key [
|
|---|
| 510 | ; f/cursor-text-offset/x: f/cursor-text-offset/x + 2
|
|---|
| 511 | ; ]
|
|---|
| 512 | ; ]
|
|---|
| 513 | ; f/pane/1/offset: f/cursor-text-offset
|
|---|
| 514 | ; sort/all f/ascii-char-tab
|
|---|
| 515 | ]
|
|---|
| 516 | show f
|
|---|
| 517 | ]
|
|---|
| 518 | down [
|
|---|
| 519 | ;insert f/buffer compose [(as-pair 0 (line-index * 20)) ""]
|
|---|
| 520 | f/color: white show f focus f
|
|---|
| 521 | ]
|
|---|
| 522 |
|
|---|
| 523 | ]
|
|---|
| 524 | ]
|
|---|
| 525 | ]
|
|---|
| 526 | append init [
|
|---|
| 527 | ; probe buffer
|
|---|
| 528 | set-font-style 'normal char-sz
|
|---|
| 529 | insert pane make face [ color: red size: 1x20 offset: cursor-text-offset ]
|
|---|
| 530 | show self
|
|---|
| 531 | ]
|
|---|
| 532 | ]
|
|---|
| 533 | ]
|
|---|
| 534 |
|
|---|
| 535 | view layout [
|
|---|
| 536 | across
|
|---|
| 537 | rotary "font-sans-serif" "font-serif" "font-fixed" [
|
|---|
| 538 | test-rte/f-name: get to-word face/text
|
|---|
| 539 | ]
|
|---|
| 540 | btn "bold" [test-rte/set-font-style 'bold (to-integer dd1/text)]
|
|---|
| 541 | btn "underline" [test-rte/set-font-style 'underline (to-integer dd1/text)]
|
|---|
| 542 | btn "italic" [test-rte/set-font-style 'italic (to-integer dd1/text)]
|
|---|
| 543 | btn "normal" [test-rte/set-font-style 'normal (to-integer dd1/text)]
|
|---|
| 544 | dd1: drop-down "12" "20" "30" [test-rte/set-font-style test-rte/font-st (to-integer dd1/text) ]
|
|---|
| 545 | col-r: box 20x20 black edge [ siez: 2x2 color: black] [ test-rte/text-color: request-color col-r/color: test-rte/text-color show col-r test-rte/set-font-style test-rte/font-st test-rte/char-sz ]
|
|---|
| 546 | return
|
|---|
| 547 | test-rte: rte 400x20
|
|---|
| 548 | return
|
|---|
| 549 | text black "Current font style: "
|
|---|
| 550 | l-fnt-disp: text black 200x20 ""
|
|---|
| 551 | ]
|
|---|
| 552 | do-events |
|---|