1 | #include "sopnamsp.h" |
---|
2 | #include "pisysdep.h" |
---|
3 | #include <stdlib.h> |
---|
4 | #include <stdio.h> |
---|
5 | #include <string.h> |
---|
6 | #include <ctype.h> |
---|
7 | |
---|
8 | #include PIMENU_H |
---|
9 | #include "picons.h" |
---|
10 | |
---|
11 | |
---|
12 | //++ |
---|
13 | // Class PIConsole |
---|
14 | // Lib PI |
---|
15 | // include picons.h |
---|
16 | // |
---|
17 | // Cette classe fournit une partie des services equivalentes |
---|
18 | // a une console. Les sorties stdout et stderr peuvent etre |
---|
19 | // redirigees sur un objet *PIConsole* (Voir "PIApplication"). |
---|
20 | // La classe offre aussi la possibilite de gestion d'un ScrollBar, |
---|
21 | // ainsi que la saisie et l'edition de commande, avec la gestion |
---|
22 | // d'un buffer de rappel. |
---|
23 | // |
---|
24 | // * Bouton-1 : Envoie le message "PIMsg_Active". Permet aussi |
---|
25 | // la selection d'un rectangle pour le copie/coller |
---|
26 | // * Bouton-2 : Effectue l'operation Copier/*Coller* sur la ligne |
---|
27 | // d'edition de commandes. |
---|
28 | // de commande (convention Xt) |
---|
29 | // * Bouton-3 : Affiche le menu des options d'affichage. |
---|
30 | // |
---|
31 | // Gestion du clavier : |
---|
32 | // * <Alt>O : Affiche le menu des options d'affichage. |
---|
33 | // * <Alt>V : Copier/*Coller* Copie le texte depuis le buffer copier/coller |
---|
34 | // sur la ligne d'edition de commande. |
---|
35 | // * <Alt>A : Selectionne toute la fenetre pour *Copier*/Coller |
---|
36 | // * <Alt>L : Liste des commandes dans le tampon de rappel. |
---|
37 | // |
---|
38 | // Commandes d'edition : |
---|
39 | // * <Ctl>A : Debut de ligne. |
---|
40 | // * <Ctl>E : Fin de ligne. |
---|
41 | // * <Ctl>K : Effacement jusqu'en fin de ligne. |
---|
42 | // * <Ctl>C : Effacement de la ligne et envoi du message PIMsg_Cancel |
---|
43 | // * Curseur gauche, droite : deplacement curseur |
---|
44 | // * Cursur Haut,bas : rappel de commande |
---|
45 | // * Backspace, del : effacement de caracteres |
---|
46 | // * <Return> : Validation (Envoi du message PIMsg_OK) |
---|
47 | //-- |
---|
48 | //++ |
---|
49 | // Links Parents |
---|
50 | // PIBaseWdg |
---|
51 | //-- |
---|
52 | |
---|
53 | // #define DEBUG_PICONS 1 |
---|
54 | |
---|
55 | // Le menu qui va servir a changer de fontes, couleurs, ... |
---|
56 | // de bouton-3 |
---|
57 | static PIMenu* opmc=NULL; |
---|
58 | static int nb_opmc = 0; |
---|
59 | |
---|
60 | static void ActivatePIConsOptionMenu(PIConsole* par) |
---|
61 | { |
---|
62 | if (opmc) delete opmc; |
---|
63 | opmc = NULL; |
---|
64 | |
---|
65 | opmc = new PIMenu(par, "OptCons", k_PopupMenu); |
---|
66 | opmc->AppendItem("SmallFont", 3101); |
---|
67 | opmc->AppendItem("NormalFont", 3102); |
---|
68 | opmc->AppendItem("LargeFont", 3103); |
---|
69 | opmc->AppendItem("25L x 132C", 3301); |
---|
70 | opmc->AppendItem("20L x 80C", 3302); |
---|
71 | opmc->AppendItem("10L x 80C", 3303); |
---|
72 | opmc->AppendItem("5L x 60C", 3304); |
---|
73 | opmc->AppendItem("Bkg White", 3201); |
---|
74 | opmc->AppendItem("Bkg Black", 3202); |
---|
75 | opmc->AppendItem("Black/Yellow", 3203); |
---|
76 | |
---|
77 | opmc->SetMsgParent((PIMsgHandler*)par); |
---|
78 | opmc->Show(); |
---|
79 | |
---|
80 | } |
---|
81 | |
---|
82 | /* --------------------------------------------------------------------------------- */ |
---|
83 | /* --------- Classe PIConsole : I/O (Ecriture/lecture) texte standard ------------ */ |
---|
84 | /* --------------------------------------------------------------------------------- */ |
---|
85 | |
---|
86 | static int CmdStrLen = 256; |
---|
87 | static int PIVA_Select = 1 << 3; |
---|
88 | |
---|
89 | // Gestion du scroll-bar |
---|
90 | static int Scb_Width = 14; |
---|
91 | |
---|
92 | |
---|
93 | //++ |
---|
94 | // Titre Constructeur |
---|
95 | //-- |
---|
96 | //++ |
---|
97 | // PIConsole(PIContainer* par, const char* nom, PIMessage msg, \ |
---|
98 | // int nl, int nc, int sx, int sy, int px, int py, bool scb) |
---|
99 | // Creation d'un objet PIConsole, avec "nl" lignes et "nc" colonnes. |
---|
100 | // "sx,sy" indique la taille de la fenetre. Si "scb==true", un |
---|
101 | // ScrollBar est cree associe a l'objet PIConsole. |
---|
102 | //-- |
---|
103 | |
---|
104 | /* --Methode-- */ |
---|
105 | PIConsole::PIConsole(PIContainer* par, const char* nom, PIMessage msg, |
---|
106 | int nl, int nc, int sx, int sy, int px, int py, bool scb) : |
---|
107 | PIBaseWdg(par, nom, ((scb)?sx-Scb_Width:sx), sy, px, py) |
---|
108 | { |
---|
109 | mNL = (nl > 10) ? nl : 10; |
---|
110 | mNC = (nc > 30) ? nc : 30; |
---|
111 | mText = new char[mNL*mNC]; |
---|
112 | mAtt = new unsigned char[mNL*mNC]; |
---|
113 | mLPo = new int[mNL]; |
---|
114 | mStrBuf = new char[mNC+1]; |
---|
115 | mCmdStr = new char[CmdStrLen+1]; |
---|
116 | mCCP = mCLC = 0; |
---|
117 | mDCOff = 0; |
---|
118 | mScb = NULL; |
---|
119 | |
---|
120 | SetMsg(msg); |
---|
121 | |
---|
122 | int i; |
---|
123 | for(i=0; i<mNL; i++) { |
---|
124 | mLPo[i] = i*mNC; |
---|
125 | ClearLine(i); |
---|
126 | } |
---|
127 | |
---|
128 | mOffL = 0; |
---|
129 | mNCmdL = 0; |
---|
130 | mCmd = ""; |
---|
131 | |
---|
132 | // Pile de rappel des commandes |
---|
133 | mRStr = NULL; |
---|
134 | mNComm = NMxRecall = 0; |
---|
135 | mRCindx = mRindx = 0; |
---|
136 | mChangeFg = false; |
---|
137 | |
---|
138 | // Copier/coller |
---|
139 | mCPBuffer = NULL; |
---|
140 | mCPBufLen = 0; |
---|
141 | mCPbeginC = mCPendC = -1; |
---|
142 | mCPbeginL = mCPendL = -1; |
---|
143 | |
---|
144 | SetPrompt("Cmd> "); |
---|
145 | ClrCmd(); |
---|
146 | SelectFont(); |
---|
147 | SelFgBgCol(); |
---|
148 | mCurL = mNL-mWSzL-1; |
---|
149 | mCurC = 0; |
---|
150 | |
---|
151 | |
---|
152 | // Pour ajouter un scroll-bar |
---|
153 | AssocScrollBar(par, nom, scb, sx, sy, px, py); |
---|
154 | |
---|
155 | |
---|
156 | ActivateKeyboard(); // Gestion de l'edition |
---|
157 | ActivateButton(1); // Action selection / copier - coller |
---|
158 | ActivateMove(1); // " " " |
---|
159 | ActivateButton(2); // " " " |
---|
160 | // ActivateButton(3); Pour afficher le menu des options (Fontes/couleur) |
---|
161 | Manage(); |
---|
162 | return; |
---|
163 | } |
---|
164 | |
---|
165 | /* --Methode-- */ |
---|
166 | PIConsole::~PIConsole() |
---|
167 | { |
---|
168 | delete[] mText; |
---|
169 | delete[] mAtt; |
---|
170 | delete[] mLPo; |
---|
171 | delete[] mStrBuf; |
---|
172 | delete[] mCmdStr; |
---|
173 | if (mScb) delete mScb; |
---|
174 | if (opmc) { delete opmc; opmc=NULL; } |
---|
175 | } |
---|
176 | |
---|
177 | |
---|
178 | //++ |
---|
179 | // Titre Méthodes |
---|
180 | // Seule les méthodes les plus usuelles sont décrites ici. Se reporter |
---|
181 | // au fichier .h pour la liste complete des méthodes |
---|
182 | // le type "enum PIVAType" est utilise pour definir les attributs |
---|
183 | // graphiques du texte affiche dans l'objet PIConsole. Les attributs |
---|
184 | // de texte et de couleur peuvent etre combine a l'aide de l'operateur |
---|
185 | // ou logique (|) |
---|
186 | //| PIVA_Def : Attribut par defaut |
---|
187 | //| PIVA_Bold : Caracteres gras |
---|
188 | //| PIVA_Ital : Caracteres italiques |
---|
189 | //| PIVA_Reverse : Caracteres en video inverse |
---|
190 | //| PIVA_DefCol : Couleur par defaut |
---|
191 | //| PIVA_Red : couleur rouge |
---|
192 | //| PIVA_Blue : Couleur bleue |
---|
193 | //| PIVA_Green : Couleur verte |
---|
194 | //| PIVA_Yellow : couleur jaune |
---|
195 | //| PIVA_Magenta : couleur mauve |
---|
196 | //-- |
---|
197 | |
---|
198 | //++ |
---|
199 | // void AddChar(char c, unsigned char va= PIVA_Def, bool ref=true) |
---|
200 | // Ajout d'un caractere a la position courante. si "ref==true", |
---|
201 | // la fenetre est rafraichie. le caractere newline declenche |
---|
202 | // un retour a la ligne. |
---|
203 | // void AddStr(const char* strg, unsigned char va= PIVA_Def, bool ref=true); |
---|
204 | // Ajout d'une chaine de caracteres a partir de la position courante. |
---|
205 | // si "ref==true", la fenetre est rafraichie. le caractere newline declenche |
---|
206 | // un retour a la ligne. |
---|
207 | // void AcceptCmd(bool acc=true, int nrecmx=20) |
---|
208 | // Active/desactive l'edition de commandes. "nrecmx" indique la profondeur |
---|
209 | // du tampon de rappel de commandes. Le message associe a l'objet PIConsole |
---|
210 | // avec la qualificatif "PIMsg_OK" est envoye lors de la validation de la |
---|
211 | // commande. |
---|
212 | // string GetCmdString() |
---|
213 | // Renvoie la chaine de caractere correspondant a la ligne editee. |
---|
214 | //-- |
---|
215 | |
---|
216 | /* --Methode-- */ |
---|
217 | void PIConsole::AddChar(char c, unsigned char va, bool ref) |
---|
218 | { |
---|
219 | int l1, l2; |
---|
220 | if (mOffL != 0) // Decalage d'affichage precedant -> Tout rafraichir |
---|
221 | { l1 = mNL-mWSzL-1; l2 = mNL-1; SetDispOffset(-1); } |
---|
222 | else l1 = l2 = mCurL; |
---|
223 | if (c == '\n') { |
---|
224 | mCurC = 0; |
---|
225 | mCurL++; |
---|
226 | } |
---|
227 | else { |
---|
228 | mText[mLPo[mCurL]+mCurC] = c; |
---|
229 | mAtt[mLPo[mCurL]+mCurC] = va; |
---|
230 | if (++mCurC == mNC) {mCurC = 0; mCurL++; } |
---|
231 | } |
---|
232 | |
---|
233 | if (mCurL >= (mNL-mNCmdL) ) { // Il faut scroller |
---|
234 | ScrollUp(); |
---|
235 | mCurL = mNL-mNCmdL-1; |
---|
236 | l1 = mNL-mWSzL-1; |
---|
237 | } |
---|
238 | if (l2 < mCurL) l2 = mCurL; |
---|
239 | if (ref) DisplayLines(mWGrC, l1, l2); |
---|
240 | return; |
---|
241 | } |
---|
242 | |
---|
243 | |
---|
244 | /* --Methode-- */ |
---|
245 | void PIConsole::AddStr(const char* strg, unsigned char va, bool ref) |
---|
246 | { |
---|
247 | int l1, l2; |
---|
248 | if (mOffL != 0) // Decalage d'affichage precedant -> Tout rafraichir |
---|
249 | { l1 = mNL-mWSzL-1; l2 = mNL-1; SetDispOffset(-1); } |
---|
250 | else l1 = l2 = mCurL; |
---|
251 | |
---|
252 | char c; |
---|
253 | while ( (c = *strg) != '\0') { |
---|
254 | if ( c != '\n' ) { |
---|
255 | mText[mLPo[mCurL]+mCurC] = c; |
---|
256 | mAtt[mLPo[mCurL]+mCurC] = va; |
---|
257 | if (++mCurC == mNC) {mCurC = 0; mCurL++; } |
---|
258 | } |
---|
259 | else { mCurL++; mCurC = 0; } |
---|
260 | if (mCurL >= (mNL-mNCmdL) ) { // Il faut scroller |
---|
261 | ScrollUp(); |
---|
262 | mCurL = mNL-mNCmdL-1; |
---|
263 | l1 = mNL-mWSzL-1; |
---|
264 | } |
---|
265 | strg++; |
---|
266 | } |
---|
267 | |
---|
268 | if (l2 < mCurL) l2 = mCurL; |
---|
269 | if (ref) DisplayLines(mWGrC, l1, l2); |
---|
270 | return; |
---|
271 | } |
---|
272 | |
---|
273 | /* --Methode-- */ |
---|
274 | void PIConsole::SelectFont(PIFontSize sz) |
---|
275 | { |
---|
276 | int asc, desc; |
---|
277 | mWGrC->SelFont(sz); |
---|
278 | mFTaille = sz; |
---|
279 | mFHaut = mWGrC->GetFont().GetFontHeight(asc, desc); |
---|
280 | mFLarg = (int)mWGrC->CalcStringWidth("ABCDEFGHIJ")/10; |
---|
281 | mWSzL = YSize()/mFHaut - 1; |
---|
282 | mWSzC = XSize()/mFLarg - 2; |
---|
283 | mOffL = 0; |
---|
284 | if (mScb) { |
---|
285 | mScb->SetMinMax(0, NbLines()-1); |
---|
286 | mScb->SetSlSize(WindNbLines()); |
---|
287 | mScb->SetValue(0); |
---|
288 | } |
---|
289 | } |
---|
290 | |
---|
291 | |
---|
292 | /* --Methode-- */ |
---|
293 | void PIConsole::AutoSize(int nl, int nc) |
---|
294 | { |
---|
295 | if ( (nl < 1) || (nc < 1) ) { |
---|
296 | nl = mWSzL; nc = mNC; |
---|
297 | } |
---|
298 | if (nc > mNC) nc = mNC; |
---|
299 | int dsz[2]; |
---|
300 | dsz[0] = (nc+2)*mFLarg - XSize(); |
---|
301 | dsz[1] = (nl+1)*mFHaut - YSize(); |
---|
302 | Send(Msg(), PIMsg_ResizeRequest, dsz); |
---|
303 | |
---|
304 | mWSzL = YSize()/mFHaut - 1; |
---|
305 | mWSzC = XSize()/mFLarg - 2; |
---|
306 | /* |
---|
307 | if (mScb) { |
---|
308 | mScb->SetMinMax(0, NbLines()-1); |
---|
309 | mScb->SetSlSize(WindNbLines()); |
---|
310 | mScb->SetValue(0); |
---|
311 | } |
---|
312 | */ |
---|
313 | mOffL = 0; |
---|
314 | } |
---|
315 | |
---|
316 | /* --Methode-- */ |
---|
317 | void PIConsole::PreferedSize(int& sx, int& sy) |
---|
318 | { |
---|
319 | sx = (mNC+2)*mFLarg; |
---|
320 | sy = (mWSzL+1)*mFHaut; |
---|
321 | return; |
---|
322 | } |
---|
323 | |
---|
324 | /* --Methode-- */ |
---|
325 | void PIConsole::AcceptCmd(bool acc, int nmxrec) |
---|
326 | { |
---|
327 | int l1, l2; |
---|
328 | if (acc) { |
---|
329 | if (mNCmdL) return; // Pas de changement d'etat |
---|
330 | if (mCurL == (mNL-1) ) { l1 = mNL-mWSzL-1; ScrollUp(); mCurL = (mNL-2); } |
---|
331 | else l1 = mNL-1; |
---|
332 | mNCmdL = 1; |
---|
333 | ClrCmd(); |
---|
334 | UpdCmdLine(); |
---|
335 | l2 = mNL-1; |
---|
336 | if (nmxrec > 0) { |
---|
337 | NMxRecall = (nmxrec > 5) ? nmxrec : 5; |
---|
338 | if (mRStr) delete[] mRStr; |
---|
339 | mRStr = new string[NMxRecall]; |
---|
340 | mNComm = mRCindx = mRindx = 0; |
---|
341 | mRStr[0] = ""; |
---|
342 | } |
---|
343 | } |
---|
344 | else { |
---|
345 | if (mNCmdL == 0) return; // Pas de changement d'etat |
---|
346 | mNCmdL = 0; |
---|
347 | ClearLine(mNL-1); |
---|
348 | ClrCmd(); |
---|
349 | l1 = l2 = mNL-1; |
---|
350 | delete[] mRStr; |
---|
351 | mRCindx = mRindx = 0; |
---|
352 | } |
---|
353 | DisplayLines(mWGrC, l1, l2); |
---|
354 | return; |
---|
355 | } |
---|
356 | |
---|
357 | /* --Methode-- */ |
---|
358 | void PIConsole::SetPrompt(const char* prompt) |
---|
359 | { |
---|
360 | strncpy(mPrompt, prompt, 31); |
---|
361 | mPrompt[31] = '\0'; |
---|
362 | return; |
---|
363 | } |
---|
364 | |
---|
365 | /* --Methode-- */ |
---|
366 | void PIConsole::SetDispOffset(int ldeb) |
---|
367 | { |
---|
368 | if (ldeb < 0) { |
---|
369 | if (mScb) mScb->SetValue(0); |
---|
370 | mOffL = 0; |
---|
371 | } |
---|
372 | else mOffL = (ldeb < mNL-mWSzL-1) ? ldeb : mNL-mWSzL-1; |
---|
373 | } |
---|
374 | |
---|
375 | |
---|
376 | /* --Methode-- */ |
---|
377 | void PIConsole::Resize() |
---|
378 | { |
---|
379 | mWSzL = YSize()/mFHaut - 1; |
---|
380 | mWSzC = XSize()/mFLarg - 2; |
---|
381 | if (mScb) { |
---|
382 | mScb->SetMinMax(0, NbLines()-1); |
---|
383 | mScb->SetSlSize(WindNbLines()); |
---|
384 | mScb->SetValue(0); |
---|
385 | } |
---|
386 | mOffL = 0; |
---|
387 | } |
---|
388 | |
---|
389 | /* --Methode-- */ |
---|
390 | void PIConsole::Draw(PIGraphicGen* g, int /*x0*/, int /*y0*/, int /*dx*/, int /*dy*/) |
---|
391 | { |
---|
392 | EraseWindow(); |
---|
393 | DisplayLines(g, 0, mNL); |
---|
394 | } |
---|
395 | |
---|
396 | |
---|
397 | /* --Methode-- */ |
---|
398 | void PIConsole::Keyboard(int key, PIKeyModifier kmod) |
---|
399 | { |
---|
400 | |
---|
401 | if (kmod == PIKM_Alt) { |
---|
402 | if (key == 'O' || key == 'o') { // Menu des options |
---|
403 | ActivatePIConsOptionMenu(this); |
---|
404 | return; |
---|
405 | } |
---|
406 | else if (key == 'A' || key == 'a') { // Pour tout selectionner |
---|
407 | mCPbeginC = 0; mCPendC = XSize(); |
---|
408 | mCPbeginL = 0; mCPendL = YSize(); |
---|
409 | SaveSelection(); |
---|
410 | return; |
---|
411 | } |
---|
412 | else if (key == 'L' || key == 'l') { // Pour lister le buffer de rappel |
---|
413 | int nmxrec = (mNComm < NMxRecall) ? mNComm : NMxRecall; |
---|
414 | if (nmxrec < 1) return; |
---|
415 | AddStr("PIConsole - Command history : \n", PIVA_Def, false); |
---|
416 | int ridx = mRCindx+nmxrec; |
---|
417 | int kk; |
---|
418 | char strg[64]; |
---|
419 | for(kk=0; kk<nmxrec; kk++) { |
---|
420 | sprintf(strg, "%d- ", mNComm-nmxrec+kk+1); |
---|
421 | AddStr(strg, PIVA_Def, false); |
---|
422 | AddStr(mRStr[ridx%nmxrec].c_str(), PIVA_Def, false); |
---|
423 | AddChar('\n', PIVA_Def, false); |
---|
424 | ridx++; |
---|
425 | } |
---|
426 | AddChar('\n', PIVA_Def, false); |
---|
427 | Refresh(); |
---|
428 | return; |
---|
429 | } |
---|
430 | } |
---|
431 | |
---|
432 | if (mNCmdL < 1) return; |
---|
433 | |
---|
434 | int k; |
---|
435 | bool fgfk = false; |
---|
436 | |
---|
437 | if (kmod == PIKM_Cntl) { |
---|
438 | switch (key) { |
---|
439 | case 1 : // <Cntl> A Debut de ligne |
---|
440 | mCCP = 0; |
---|
441 | break; |
---|
442 | case 3 : // <Cntl> C On efface la ligne |
---|
443 | mCCP = mCLC = 0; |
---|
444 | mCmdStr[mCLC] = '\0'; |
---|
445 | mRindx = mRCindx; |
---|
446 | mChangeFg = true; |
---|
447 | Send( Msg(), PIMsg_Cancel, NULL); |
---|
448 | |
---|
449 | break; |
---|
450 | case 5 : // <Cntl> E Fin de ligne |
---|
451 | mCCP = mCLC; |
---|
452 | break; |
---|
453 | case 11 : // <Cntl> K On efface jusqu'en fin de ligne |
---|
454 | mCLC = mCCP; |
---|
455 | break; |
---|
456 | } |
---|
457 | } |
---|
458 | |
---|
459 | else if (kmod == PIKM_Alt) { |
---|
460 | if (key == 'V' || key == 'v') RequestSelection(); // Pour coller (copier/coller) |
---|
461 | } |
---|
462 | |
---|
463 | else if (kmod == PIKM_Blank) { |
---|
464 | switch (key) { |
---|
465 | case PIK_Return : |
---|
466 | case PIK_Enter : |
---|
467 | SendCmd(); |
---|
468 | break; |
---|
469 | |
---|
470 | case PIK_BackSpace : |
---|
471 | case 127 : // Touche del |
---|
472 | case 8 : // Touche backspace |
---|
473 | if (mCCP > 0) { |
---|
474 | for(k=mCCP-1; k<mCLC-1; k++) mCmdStr[k] = mCmdStr[k+1]; |
---|
475 | mCmdStr[mCLC-1] = ' '; mCCP--; mCLC--; |
---|
476 | mChangeFg = true; |
---|
477 | } |
---|
478 | // printf("Keyb()-Debug- Backspace CCP,CLC= %d %d CmdStr= %s (L=%d) \n", mCCP, mCLC, |
---|
479 | // mCmdStr, strlen(mCmdStr)); |
---|
480 | break; |
---|
481 | |
---|
482 | case PIK_Up : |
---|
483 | case PIK_Down : |
---|
484 | // printf("Keyb()-Debug- CursorUp/Down(%d) Index= %d %d \n", key, mRindx, mRCindx); |
---|
485 | if (mNComm > 0) { |
---|
486 | if (mChangeFg) { |
---|
487 | mCmdStr[mCLC] = '\0'; |
---|
488 | mRStr[mRCindx] = mCmdStr; |
---|
489 | mChangeFg = false; |
---|
490 | } |
---|
491 | int nmxrec = ((mNComm+1) < NMxRecall) ? mNComm+1 : NMxRecall; |
---|
492 | if (key == PIK_Up) { |
---|
493 | mRindx --; |
---|
494 | if (mRindx < 0) mRindx += nmxrec; |
---|
495 | } |
---|
496 | else mRindx++; |
---|
497 | int ridx = mRindx%nmxrec; |
---|
498 | mCLC = mCCP = mRStr[ridx].length(); |
---|
499 | for(k=0; k< mCLC; k++) mCmdStr[k] = mRStr[ridx][k]; |
---|
500 | mCmdStr[mCLC] = '\0'; |
---|
501 | int mxCC = mWSzC-strlen(mPrompt)-2; |
---|
502 | if (mCCP >= mxCC) mCCP = mxCC; // On se met le plus loin possible sur la ligne |
---|
503 | } |
---|
504 | break; |
---|
505 | |
---|
506 | case PIK_Left : |
---|
507 | if (mCCP > 0) mCCP--; |
---|
508 | // printf("Keyb()-Debug- Left CCP,CLC= %d %d \n", mCCP, mCLC); |
---|
509 | break; |
---|
510 | case PIK_Right : |
---|
511 | if (mCCP < mCLC) mCCP++; |
---|
512 | // printf("Keyb()-Debug- Right CCP,CLC= %d %d \n", mCCP, mCLC); |
---|
513 | break; |
---|
514 | default : |
---|
515 | fgfk = true; |
---|
516 | break; |
---|
517 | } |
---|
518 | } |
---|
519 | if ( ( fgfk && (kmod == PIKM_Blank) ) || (kmod == PIKM_Shift) ) CmdAddChar(key); |
---|
520 | UpdCmdLine(); |
---|
521 | // DisplayLines(mNL-1, mNL-1); |
---|
522 | return; |
---|
523 | } |
---|
524 | |
---|
525 | |
---|
526 | /* --Methode-- */ |
---|
527 | void PIConsole::But1Press(int x, int y) |
---|
528 | { |
---|
529 | Send(Msg(), PIMsg_Active); |
---|
530 | AssignKeyboard(); |
---|
531 | mWGrC->SelGOMode(PI_GOXOR); |
---|
532 | mWGrC->SelForeground(PI_Grey); |
---|
533 | mCPbeginC = x; mCPbeginL = y; |
---|
534 | mCPendC = mCPendL = -1; |
---|
535 | } |
---|
536 | |
---|
537 | /* --Methode-- */ |
---|
538 | void PIConsole::Ptr1Move(int x, int y) |
---|
539 | { |
---|
540 | if (mCPendC >= 0) mWGrC->DrawBox(mCPbeginC, mCPbeginL, mCPendC-mCPbeginC, mCPendL-mCPbeginL); |
---|
541 | mCPendC = x; mCPendL = y; |
---|
542 | mWGrC->DrawBox(mCPbeginC, mCPbeginL, mCPendC-mCPbeginC, mCPendL-mCPbeginL); |
---|
543 | } |
---|
544 | |
---|
545 | /* --Methode-- */ |
---|
546 | void PIConsole::But1Release(int x, int y) |
---|
547 | { |
---|
548 | if ( (mCPendC >= 0) && (mCPbeginC >= 0) ) { |
---|
549 | mWGrC->DrawBox(mCPbeginC, mCPbeginL, mCPendC-mCPbeginC, mCPendL-mCPbeginL); |
---|
550 | mCPendC = x; mCPendL = y; |
---|
551 | } |
---|
552 | else { |
---|
553 | mCPbeginC = mCPendC = -1; |
---|
554 | mCPbeginL = mCPendL = -1; |
---|
555 | } |
---|
556 | mWGrC->SelGOMode(PI_GOCopy); |
---|
557 | mWGrC->SelForeground(mFgC); |
---|
558 | SaveSelection(); |
---|
559 | } |
---|
560 | |
---|
561 | /* --Methode-- */ |
---|
562 | void PIConsole::But2Press(int x, int y) |
---|
563 | { |
---|
564 | RequestSelection(); // Pour recuperer la selection = coller (copier/coller) |
---|
565 | } |
---|
566 | |
---|
567 | /* --Methode-- */ |
---|
568 | void PIConsole::But3Press(int x, int y) |
---|
569 | { |
---|
570 | ActivatePIConsOptionMenu(this); |
---|
571 | } |
---|
572 | |
---|
573 | /* --Methode-- */ |
---|
574 | void PIConsole::PasteSelection(unsigned int typ, void *pdata, unsigned int l) |
---|
575 | { |
---|
576 | if (typ != PICP_string) return; |
---|
577 | int i; |
---|
578 | char *pc = (char *)pdata; |
---|
579 | for(i=0; i<l; i++) { |
---|
580 | if ((i > 0) && (pc[i] == '\n')) SendCmd(); |
---|
581 | else CmdAddChar(pc[i]); |
---|
582 | } |
---|
583 | UpdCmdLine(); |
---|
584 | } |
---|
585 | |
---|
586 | /* --Methode-- */ |
---|
587 | void PIConsole::SelectionLost() |
---|
588 | { |
---|
589 | // printf("Debug PIConsole::SelectionLost() %lx (L=%d)\n",(long)mCPBuffer, mCPBufLen); |
---|
590 | if (!mCPBuffer) return; |
---|
591 | delete[] mCPBuffer; |
---|
592 | mCPBuffer = NULL; |
---|
593 | mCPBufLen = 0; |
---|
594 | mCPbeginC = mCPendC = -1; |
---|
595 | mCPbeginL = mCPendL = -1; |
---|
596 | int i,j; |
---|
597 | int l1,l2; |
---|
598 | l1 = mNL+1; l2 = -1; |
---|
599 | for(i=0; i<mNL; i++) // On enleve le bit select a tous les caracteres |
---|
600 | for(j=0; j<mNC; j++) |
---|
601 | if ( mAtt[mLPo[i]+j] & PIVA_Select) { |
---|
602 | if (l1 > i) l1 = i; |
---|
603 | if (l2 < i) l2 = i; |
---|
604 | mAtt[mLPo[i]+j] &= ~PIVA_Select ; |
---|
605 | } |
---|
606 | |
---|
607 | if (IsVisible() && l2 > -1) DisplayLines(mWGrC, l1, l2); |
---|
608 | return; |
---|
609 | } |
---|
610 | |
---|
611 | /* --Methode-- */ |
---|
612 | void PIConsole::SelectionTransferEnd() |
---|
613 | { |
---|
614 | // printf("Debug PIConsole::SelectionTransferEnd() -Rien- %lx (L=%d)\n",(long)mCPBuffer, mCPBufLen); |
---|
615 | } |
---|
616 | |
---|
617 | |
---|
618 | /* --Methode-- */ |
---|
619 | void * PIConsole::ProvideSelection(unsigned int& typ, unsigned int& len) |
---|
620 | { |
---|
621 | typ = PICP_string; |
---|
622 | len = mCPBufLen; |
---|
623 | return(mCPBuffer); |
---|
624 | } |
---|
625 | |
---|
626 | /* ----------------------------------------------------------------------------- */ |
---|
627 | /* ---------------------- Methodes protected ------------------------- */ |
---|
628 | /* ----------------------------------------------------------------------------- */ |
---|
629 | |
---|
630 | |
---|
631 | /* --Methode-- |
---|
632 | void PIConsole::DebugPrint(int lp) |
---|
633 | { |
---|
634 | printf("PIConsole::DebugPrint() - NL,NC= %d %d - WSzL,C= %d %d Cur= %d %d\n", mNL, mNC, |
---|
635 | mWSzL, mWSzC, mCurL, mCurC); |
---|
636 | printf(" OffL, NCmdL= %d %d - mCCP, mCLC= %d %d - LPo= %d %d \n", |
---|
637 | mOffL, mNCmdL, mCCP, mCLC, mLPo[mNL-2], mLPo[mNL-1]); |
---|
638 | |
---|
639 | if (lp == 0) return; |
---|
640 | int i,j; |
---|
641 | for(j=0; j<mNL; j++) { |
---|
642 | printf("Line[%d] (%d) = ", j, mLPo[j]); |
---|
643 | for(i=0; i<mNC; i++) putchar(mText[mLPo[j]+i]); |
---|
644 | putchar('\n'); |
---|
645 | } |
---|
646 | return; |
---|
647 | } |
---|
648 | */ |
---|
649 | |
---|
650 | |
---|
651 | /* --Methode-- */ |
---|
652 | void PIConsole::AssocScrollBar(PIContainer* par, const char* nom, bool scb, int sx, int sy, int px, int py) |
---|
653 | { |
---|
654 | if (!scb) { |
---|
655 | mScb = NULL; |
---|
656 | msgScb = 0; |
---|
657 | SetBinding(PIBK_fixed, PIBK_fixed, PIBK_fixed, PIBK_fixed); |
---|
658 | return; |
---|
659 | } |
---|
660 | |
---|
661 | sx -= Scb_Width; |
---|
662 | // SetSize(sx, sy); |
---|
663 | SetBinding(PIBK_fixed, PIBK_fixed, PIBK_fixed, PIBK_fixed); |
---|
664 | char name[128]; |
---|
665 | strcpy(name,"ScrollBar_"); |
---|
666 | strncat(name, nom, 127); |
---|
667 | msgScb = Msg()+55; |
---|
668 | mScb = new PIScrollBar (par, name, msgScb, kSDirDownUp, Scb_Width, sy, px+sx, py); |
---|
669 | mScb->SetBinding(PIBK_free, PIBK_fixed, PIBK_fixed, PIBK_fixed); |
---|
670 | |
---|
671 | mScb->SetMsgParent(this); |
---|
672 | mScb->SetMinMax(0, NbLines()-1); |
---|
673 | mScb->SetSlSize(WindNbLines()); |
---|
674 | mScb->SetValue(0); |
---|
675 | mScb->ActivateDrag(true); |
---|
676 | } |
---|
677 | |
---|
678 | /* --Methode-- */ |
---|
679 | void PIConsole::ScrollUp() |
---|
680 | { |
---|
681 | int i,l,kpo; |
---|
682 | l = mNL-1-mNCmdL; |
---|
683 | kpo = mLPo[0]; |
---|
684 | for(i=0; i<mNL-mNCmdL-1; i++) mLPo[i] = mLPo[i+1]; |
---|
685 | mLPo[l] = kpo; |
---|
686 | ClearLine(l); |
---|
687 | return; |
---|
688 | } |
---|
689 | |
---|
690 | /* --Methode-- */ |
---|
691 | void PIConsole::ClearLine(int l) |
---|
692 | { |
---|
693 | if ((l<0) || (l >= mNL)) return; |
---|
694 | int j; |
---|
695 | for(j=0; j<mNC; j++) { |
---|
696 | mText[mLPo[l]+j] = ' '; |
---|
697 | mAtt[mLPo[l]+j] = PIVA_Def; |
---|
698 | } |
---|
699 | return; |
---|
700 | } |
---|
701 | |
---|
702 | /* --Methode-- */ |
---|
703 | void PIConsole::DisplayLines(PIGraphicGen* g, int l1, int l2) |
---|
704 | { |
---|
705 | int j,l,k,l0; |
---|
706 | int x,y; |
---|
707 | |
---|
708 | // DBG printf("PIConsole::DisplayLines(%d %d ) -> %d - %lx \n ", l1, l2, |
---|
709 | // (int)IsVisible(), (long)XtWindow(XtWdg())); |
---|
710 | |
---|
711 | if (! IsVisible() ) return; |
---|
712 | |
---|
713 | int lva = -1; |
---|
714 | int ccol, cfnt; |
---|
715 | |
---|
716 | PIFontAtt vafat[8] = {PI_RomanFont, PI_BoldFont, PI_ItalicFont, |
---|
717 | PI_RomanFont, PI_RomanFont, PI_BoldFont, |
---|
718 | PI_ItalicFont, PI_RomanFont}; |
---|
719 | PIColors fgc, bgc, dbgc; |
---|
720 | PIColors col[6] = {PI_Black, PI_Red, PI_Blue, PI_Green, PI_Yellow, PI_Magenta}; |
---|
721 | |
---|
722 | g->SelForeground(mFgC); |
---|
723 | g->SelBackground(mBgC); |
---|
724 | fgc = col[0] = g->GetForeground(); |
---|
725 | dbgc = bgc = g->GetBackground(); |
---|
726 | |
---|
727 | int dx = mFLarg; |
---|
728 | int dy = mFHaut/2; |
---|
729 | int dxo2 = dx/2; |
---|
730 | if (dxo2 > 3) dxo2 = 3; |
---|
731 | int dyo2 = dy/2; |
---|
732 | if (dyo2 > 3) dyo2 = 3; |
---|
733 | |
---|
734 | g->DrawBox(dxo2, dyo2, (mNC+2)*mFLarg-2*dxo2, (mWSzL+1)*mFHaut-dyo2); |
---|
735 | |
---|
736 | l0 = mNL-mWSzL-mOffL; |
---|
737 | if (l0 < 0) l0 = 0; |
---|
738 | if (l1 < l0) l1 = l0; |
---|
739 | if (++l2 > mNL-mOffL) l2 = mNL-mOffL; |
---|
740 | |
---|
741 | for(l=l1; l<l2; l++) { |
---|
742 | y = (l-l0+1)*mFHaut+dy; |
---|
743 | k = 0; x = dx; |
---|
744 | for(j=0; j<mNC; j++) { |
---|
745 | if (mAtt[mLPo[l]+j] != lva) { |
---|
746 | if (k > 0) { |
---|
747 | mStrBuf[k] = '\0'; |
---|
748 | g->DrawOpaqueString(x, y, mStrBuf); |
---|
749 | // printf("l,J,K=%d %d %d - X,Y= %d %d - %s \n", l,j,k,x,y,mStrBuf); |
---|
750 | x += k*mFLarg; k = 0; |
---|
751 | } |
---|
752 | lva = mAtt[mLPo[l]+j]; |
---|
753 | cfnt = lva & 15; // Index de fonte |
---|
754 | ccol = lva >> 4; // Index de couleur |
---|
755 | fgc = col[ccol]; |
---|
756 | if (cfnt & PIVA_Select) |
---|
757 | { bgc = PI_Grey; g->SelFont(mFTaille, vafat[cfnt-PIVA_Select]); } |
---|
758 | else { bgc = dbgc; g->SelFont(mFTaille, vafat[cfnt]); } |
---|
759 | |
---|
760 | if (cfnt & PIVA_Reverse) { |
---|
761 | g->SelForeground(bgc); |
---|
762 | g->SelBackground(fgc); |
---|
763 | } |
---|
764 | else { |
---|
765 | g->SelForeground(fgc); |
---|
766 | g->SelBackground(bgc); |
---|
767 | } |
---|
768 | } |
---|
769 | mStrBuf[k] = mText[mLPo[l]+j]; |
---|
770 | k++; |
---|
771 | } |
---|
772 | if (k > 0) { |
---|
773 | mStrBuf[k] = '\0'; |
---|
774 | g->DrawOpaqueString(x, y, mStrBuf); |
---|
775 | // printf("l,J,K=%d %d %d - X,Y= %d %d - %s \n", l,j,k,x,y,mStrBuf); |
---|
776 | } |
---|
777 | } |
---|
778 | |
---|
779 | g->SelForeground(fgc); |
---|
780 | g->SelBackground(dbgc); |
---|
781 | return; |
---|
782 | } |
---|
783 | |
---|
784 | /* --Methode-- */ |
---|
785 | void PIConsole::UpdCmdLine() |
---|
786 | { |
---|
787 | // char strg[260]; debug |
---|
788 | int l1,l2; |
---|
789 | l1 = l2 = mNL-1; |
---|
790 | if (mOffL != 0) // Decalage d'affichage precedant -> Tout rafraichir |
---|
791 | { l1 = mNL-mWSzL-1; l2 = mNL-1; SetDispOffset(-1); } |
---|
792 | |
---|
793 | ClearLine(mNL-1); |
---|
794 | int j1,j2,j,jj2; |
---|
795 | j1 = strlen(mPrompt); |
---|
796 | for(j=0; j<j1; j++) { |
---|
797 | mText[mLPo[mNL-1]+j] = mPrompt[j]; |
---|
798 | mAtt[mLPo[mNL-1]+j] = PIVA_Def; |
---|
799 | // strg[j] = mPrompt[j]; debug |
---|
800 | } |
---|
801 | jj2 = mWSzC-j1; |
---|
802 | if (mDCOff>=mCCP) mDCOff = 0; |
---|
803 | int koff = ((mCCP-mDCOff) >= jj2) ? mCCP-(jj2/2) : mDCOff; |
---|
804 | mDCOff = koff; |
---|
805 | int kmx = mCLC-koff; |
---|
806 | j2 = j1+kmx; |
---|
807 | if (j2 > mWSzC) j2 = mWSzC; |
---|
808 | int k = koff; |
---|
809 | for(j=j1; j<j2; j++) { |
---|
810 | mText[mLPo[mNL-1]+j] = mCmdStr[k]; |
---|
811 | mAtt[mLPo[mNL-1]+j] = PIVA_Bold; |
---|
812 | // strg[j] = mCmdStr[k]; debug |
---|
813 | k++; |
---|
814 | } |
---|
815 | |
---|
816 | // strg[j] = '\0'; Debug |
---|
817 | // printf("UpdCmdLine() %d %d - %s (%d) \n [%d %d %d] %d\n", koff,kmx,strg,j1+mCCP-koff, mWSzC, j1, jj2, mCCP-(jj2/2)); |
---|
818 | mAtt[mLPo[mNL-1]+j1+mCCP-koff] = PIVA_Reverse; // Pour le curseur |
---|
819 | DisplayLines(mWGrC, l1, l2); |
---|
820 | } |
---|
821 | |
---|
822 | /* --Methode-- */ |
---|
823 | void PIConsole::ClrCmd() |
---|
824 | { |
---|
825 | mCCP = 0; mCLC = 0; mDCOff = 0; |
---|
826 | mCmdStr[0] = '\0'; |
---|
827 | } |
---|
828 | |
---|
829 | /* --Methode-- */ |
---|
830 | void PIConsole::SendCmd() |
---|
831 | { |
---|
832 | mCmdStr[mCLC] = '\0'; |
---|
833 | // printf("Keyb()-Debug- <CR/Enter> CmdStr= %s (L=%d)\n", mCmdStr, strlen(mCmdStr) ); |
---|
834 | // Gestion de rappel des commandes |
---|
835 | if (mCLC > 0) { |
---|
836 | mRStr[mRCindx] = mCmdStr; |
---|
837 | mRCindx++; mNComm++; |
---|
838 | if (mRCindx >= NMxRecall) mRCindx = 0; |
---|
839 | mRindx = mRCindx; |
---|
840 | } |
---|
841 | mChangeFg = false; |
---|
842 | mCmd = mCmdStr; |
---|
843 | ClrCmd(); |
---|
844 | Send( Msg(), PIMsg_OK, NULL); |
---|
845 | return; |
---|
846 | } |
---|
847 | |
---|
848 | /* --Methode-- */ |
---|
849 | void PIConsole::CmdAddChar(int key) |
---|
850 | { |
---|
851 | int k, kmx; |
---|
852 | if ( (mCCP < CmdStrLen) && isprint(key) ) { // Ajout de caracteres |
---|
853 | if (mCCP < mCLC) { // Insertion au milieu de la chaine |
---|
854 | kmx = (mCLC < CmdStrLen) ? mCLC : CmdStrLen-1; |
---|
855 | // printf(" ++DBG++ C=%d L=%d MX=%d KMX=%d\n", mCCP, mCLC, CmdStrLen,kmx); |
---|
856 | for(k=kmx; k>mCCP; k--) mCmdStr[k] = mCmdStr[k-1]; mCLC = kmx+1; |
---|
857 | } |
---|
858 | mCmdStr[mCCP] = key; mCCP++; |
---|
859 | if (mCCP > mCLC) mCLC = mCCP; |
---|
860 | mChangeFg = true; |
---|
861 | } |
---|
862 | } |
---|
863 | |
---|
864 | |
---|
865 | /* --Methode-- */ |
---|
866 | void PIConsole::SelFgBgCol(PIColors fc, PIColors bc) |
---|
867 | { |
---|
868 | mFgC = fc; mBgC = bc; |
---|
869 | SetBackgroundColor(bc); |
---|
870 | } |
---|
871 | |
---|
872 | |
---|
873 | /* --Methode-- */ |
---|
874 | void PIConsole::SaveSelection() |
---|
875 | { |
---|
876 | int i,j,k,l; |
---|
877 | int l1, l2, nl, nc; |
---|
878 | |
---|
879 | if (mCPbeginC > mCPendC) { j = mCPbeginC; mCPbeginC = mCPendC ; mCPendC = j; } |
---|
880 | if (mCPbeginL > mCPendL) { j = mCPbeginL; mCPbeginL = mCPendL ; mCPendL = j; } |
---|
881 | |
---|
882 | nc = (mCPendC-mCPbeginC)/mFLarg; |
---|
883 | nl = (mCPendL-mCPbeginL)/mFHaut; |
---|
884 | if (nl < 1) nl = 1; // On selectionne au moins une ligne |
---|
885 | // printf("*DBG* NC=%d NL=%d \n",nc, nl); |
---|
886 | l1 = mNL+1; l2 = -1; |
---|
887 | |
---|
888 | if (mCPBuffer) { |
---|
889 | delete[] mCPBuffer; |
---|
890 | mCPBuffer = NULL; |
---|
891 | mCPBufLen = 0; |
---|
892 | for(i=0; i<mNL; i++) // On enleve le bit select a tous les caracteres |
---|
893 | for(j=0; j<mNC; j++) |
---|
894 | if ( mAtt[mLPo[i]+j] & PIVA_Select) { |
---|
895 | if (l1 > i) l1 = i; |
---|
896 | if (l2 < i) l2 = i; |
---|
897 | mAtt[mLPo[i]+j] &= ~PIVA_Select ; |
---|
898 | } |
---|
899 | } |
---|
900 | |
---|
901 | // printf("**DBG** Save: C= %d %d L = %d %d \n", mCPbeginC, mCPendC, mCPbeginL, mCPendL); |
---|
902 | |
---|
903 | |
---|
904 | // On transforme la position sur la fenetre en position en caracteres ds les buffers |
---|
905 | |
---|
906 | mCPbeginC = mCPbeginC/mFLarg-1; |
---|
907 | mCPendC = (int) ( (float)mCPendC/(float)mFLarg-0.8 ); |
---|
908 | mCPbeginL = (int) ( (float)mCPbeginL/(float)mFHaut-0.5 ) ; |
---|
909 | mCPendL = (int) ( (float)mCPendL/(float)mFHaut-0.5 ) ; |
---|
910 | if (mCPendL <= mCPbeginL) mCPendL = mCPbeginL+1; // Au moins une ligne selectionnee |
---|
911 | // printf("..DBG.. C= %d %d L = %d %d ", mCPbeginC, mCPendC, mCPbeginL, mCPendL); |
---|
912 | j = mNL-mWSzL-mOffL; |
---|
913 | mCPbeginL += j; mCPendL += j; |
---|
914 | // printf(" -> %d %d \n", mCPbeginL, mCPendL); |
---|
915 | |
---|
916 | if (mCPbeginC < 0) mCPbeginC = 0; |
---|
917 | if (mCPendC > mNC) mCPendC = mNC; |
---|
918 | if (mCPbeginL < 0) mCPbeginL = 0; |
---|
919 | if (mCPendL > mNL) mCPendL = mNL; |
---|
920 | |
---|
921 | if ( (nc > 0) && (nl > 0) ) { |
---|
922 | if (!ClaimSelection()) { |
---|
923 | mCPbeginC = mCPendC = -1; |
---|
924 | mCPbeginL = mCPendL = -1; |
---|
925 | if (l2 > -1) DisplayLines(mWGrC, l1, l2); |
---|
926 | return; |
---|
927 | } |
---|
928 | l = (mCPendC-mCPbeginC+1) * (mCPendL-mCPbeginL); |
---|
929 | if (l < 0) l = 0; |
---|
930 | mCPBufLen = l; |
---|
931 | mCPBuffer = new char[l+1]; |
---|
932 | k = 0; |
---|
933 | for(j=mCPbeginL; j<mCPendL; j++) { |
---|
934 | for(i=mCPbeginC; i<mCPendC; i++) { |
---|
935 | mAtt[mLPo[j]+i] |= PIVA_Select; |
---|
936 | mCPBuffer[k] = mText[mLPo[j]+i]; k++; |
---|
937 | } |
---|
938 | if (j<mCPendL-1) { mCPBuffer[k] = '\n'; k++; } |
---|
939 | else mCPBuffer[k] = '\0'; |
---|
940 | } |
---|
941 | mCPBuffer[l] = '\0'; |
---|
942 | if (l1 > mCPbeginL) l1 = mCPbeginL; |
---|
943 | if (l2 < (mCPendL-1)) l2 = mCPendL-1; |
---|
944 | } |
---|
945 | else { |
---|
946 | l = 0; |
---|
947 | mCPbeginC = mCPendC = mCPbeginL = mCPendL = -1; |
---|
948 | mCPBufLen = 0; |
---|
949 | mCPBuffer = new char[10]; |
---|
950 | mCPBuffer[0] = mCPBuffer[1] = '\0'; |
---|
951 | } |
---|
952 | |
---|
953 | // printf("*DBG* Save_Display %d %d \n", l1, l2); |
---|
954 | |
---|
955 | if (l2 > -1) DisplayLines(mWGrC, l1, l2); |
---|
956 | } |
---|
957 | |
---|
958 | /* --Methode-- */ |
---|
959 | void PIConsole::Process(PIMessage msg, PIMsgHandler* sender, void* data) |
---|
960 | { |
---|
961 | int off; |
---|
962 | // printf("PIConsole::Process() UserMsg()= %d ModMsg= %d \n", (int)UserMsg(msg), |
---|
963 | // (int)ModMsg(msg) ); |
---|
964 | |
---|
965 | if (sender == opmc) { // Menu des options |
---|
966 | bool fgr = true; |
---|
967 | switch (UserMsg(msg)) { |
---|
968 | case 3101 : |
---|
969 | SelectFont(PI_SmallSizeFont); |
---|
970 | AutoSize(); |
---|
971 | break; |
---|
972 | case 3102 : |
---|
973 | SelectFont(PI_NormalSizeFont); |
---|
974 | AutoSize(); |
---|
975 | break; |
---|
976 | case 3103 : |
---|
977 | SelectFont(PI_LargeSizeFont); |
---|
978 | AutoSize(); |
---|
979 | break; |
---|
980 | case 3201 : |
---|
981 | SelFgBgCol(PI_Black, PI_White); |
---|
982 | break; |
---|
983 | case 3202 : |
---|
984 | SelFgBgCol(PI_White, PI_Black); |
---|
985 | break; |
---|
986 | case 3203 : |
---|
987 | SelFgBgCol(PI_Yellow, PI_Black); |
---|
988 | break; |
---|
989 | case 3301 : |
---|
990 | AutoSize(25, 132); |
---|
991 | break; |
---|
992 | case 3302 : |
---|
993 | AutoSize(20, 80); |
---|
994 | break; |
---|
995 | case 3303 : |
---|
996 | AutoSize(10, 80); |
---|
997 | break; |
---|
998 | case 3304 : |
---|
999 | AutoSize(5, 60); |
---|
1000 | break; |
---|
1001 | default : |
---|
1002 | fgr = false; |
---|
1003 | break; |
---|
1004 | } |
---|
1005 | if (fgr) Refresh(); |
---|
1006 | delete opmc; opmc = NULL; |
---|
1007 | } |
---|
1008 | // Le traitement du scroll-bar |
---|
1009 | else if (((ModMsg(msg) == PIMsg_DataChanged) || |
---|
1010 | (ModMsg(msg) == PIMsg_Drag) ) && (UserMsg(msg) == msgScb) ) { |
---|
1011 | off = * ((int *)data); |
---|
1012 | // printf(" PIConsole::Process() From ScrollBar : Off=%d \n ", off); |
---|
1013 | SetDispOffset(off); |
---|
1014 | Refresh(); |
---|
1015 | } |
---|
1016 | // Sinon, on retranmet le message |
---|
1017 | else ReSend(msg, sender, data); |
---|
1018 | } |
---|
1019 | |
---|