d09aa4e843f980aec01ed7e40b4e9fbf21fc36f3
[scilab.git] / scilab / modules / history_manager / src / cpp / HistoryManager.cpp
1 /*
2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2007-2008 - INRIA - Allan CORNET
4 * Copyright (C) 2010 - DIGITEO - Vincent COUVERT
5 * Copyright (C) 2011 - DIGITEO - Allan CORNET
6 *
7 * This file must be used under the terms of the CeCILL.
8 * This source file is licensed as described in the file COPYING, which
9 * you should have received as part of this distribution.  The terms
10 * are also available at
11 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
12 *
13 */
14
15 /*------------------------------------------------------------------------*/
16 #include "HistoryManager.hxx"
17 #include "HistoryManager.h"
18 #include "getCommentDateSession.h"
19 #include "MALLOC.h"
20 /*------------------------------------------------------------------------*/
21 extern "C"
22 {
23 #include <stdio.h>
24 #include <string.h>
25 #include <stdlib.h>
26 #include "sciprint.h"
27 #include "SCIHOME.h"
28 #include "expandPathVariable.h"
29 #include "InitializeHistoryManager.h"
30 #include "TerminateHistoryManager.h"
31 #include "freeArrayOfString.h"
32 #ifdef _MSC_VER
33 #include "strdup_windows.h"
34 #endif
35 #include "CommandHistory_Wrap.h"
36 };
37
38 /*------------------------------------------------------------------------*/
39 #define MAXBUF  1024
40 /*------------------------------------------------------------------------*/
41 static HistoryManager *ScilabHistory = NULL;
42
43 /*------------------------------------------------------------------------*/
44 BOOL historyIsEnabled(void)
45 {
46     if (ScilabHistory)
47     {
48         return TRUE;
49     }
50     return FALSE;
51 }
52
53 /*------------------------------------------------------------------------*/
54 BOOL InitializeHistoryManager(void)
55 {
56     if (!ScilabHistory)
57     {
58         ScilabHistory = new HistoryManager();
59         if (ScilabHistory)
60         {
61             return TRUE;
62         }
63     }
64     return FALSE;
65 }
66
67 /*------------------------------------------------------------------------*/
68 BOOL TerminateHistoryManager(void)
69 {
70     if (ScilabHistory)
71     {
72         delete ScilabHistory;
73
74         ScilabHistory = NULL;
75         return TRUE;
76     }
77     return FALSE;
78 }
79
80 /*------------------------------------------------------------------------*/
81 BOOL setSearchedTokenInScilabHistory(char *token)
82 {
83     if (ScilabHistory)
84     {
85         return ScilabHistory->setToken(token);
86     }
87     return FALSE;
88 }
89
90 /*------------------------------------------------------------------------*/
91 BOOL resetSearchedTokenInScilabHistory(void)
92 {
93     if (ScilabHistory)
94     {
95         return ScilabHistory->resetToken();
96     }
97     return FALSE;
98 }
99
100 /*------------------------------------------------------------------------*/
101 char *getSearchedTokenInScilabHistory(void)
102 {
103     char *token = NULL;
104
105     if (ScilabHistory)
106     {
107         token = ScilabHistory->getToken();
108     }
109     return token;
110 }
111
112 /*------------------------------------------------------------------------*/
113 BOOL appendLineToScilabHistory(char *line)
114 {
115     BOOL bOK = FALSE;
116
117     if (line)
118     {
119         int i = 0;
120         char *cleanedline = NULL;
121
122         if (ScilabHistory && ScilabHistory->getNumberOfLines() == 0)
123         {
124             char * commentbeginsession = getCommentDateSession(FALSE);
125             ScilabHistory->appendLine(commentbeginsession);
126             FREE(commentbeginsession);
127             CommandHistoryExpandAll();
128         }
129
130         /* remove space & carriage return at the end of line */
131         cleanedline = strdup(line);
132
133         /* remove carriage return at the end of line */
134         for (i = (int)strlen(cleanedline); i > 0; i--)
135         {
136             if (cleanedline[i] == '\n')
137             {
138                 cleanedline[i] = '\0';
139                 break;
140             }
141         }
142
143         /* remove spaces at the end of line */
144         i = (int)strlen(cleanedline) - 1;
145         while (i >= 0)
146         {
147             if (cleanedline[i] == ' ')
148             {
149                 cleanedline[i] = '\0';
150             }
151             else
152             {
153                 break;
154             }
155
156             i--;
157         }
158
159         if (ScilabHistory)
160         {
161             bOK = ScilabHistory->appendLine(cleanedline);
162         }
163
164         if (cleanedline)
165         {
166             FREE(cleanedline);
167             cleanedline = NULL;
168         }
169     }
170
171     return bOK;
172 }
173
174 /*------------------------------------------------------------------------*/
175 BOOL appendLinesToScilabHistory(char **lines, int numberoflines)
176 {
177     if (ScilabHistory)
178     {
179         return ScilabHistory->appendLines(lines, numberoflines);
180     }
181     return FALSE;
182 }
183
184 /*------------------------------------------------------------------------*/
185 void displayScilabHistory(void)
186 {
187     if (ScilabHistory)
188     {
189         ScilabHistory->displayHistory();
190     }
191 }
192
193 /*------------------------------------------------------------------------*/
194 BOOL writeScilabHistoryToFile(char *filename)
195 {
196     if (ScilabHistory)
197     {
198         return ScilabHistory->writeToFile(filename);
199     }
200     return FALSE;
201 }
202
203 /*------------------------------------------------------------------------*/
204 BOOL loadScilabHistoryFromFile(char *filename)
205 {
206     if (ScilabHistory)
207     {
208         return ScilabHistory->loadFromFile(filename);
209     }
210     return FALSE;
211 }
212
213 /*------------------------------------------------------------------------*/
214 BOOL isScilabHistoryTruncated(void)
215 {
216     BOOL bOK = FALSE;
217     if (ScilabHistory)
218     {
219         bOK = ScilabHistory->isTruncated();
220     }
221     return bOK;
222 }
223 /*------------------------------------------------------------------------*/
224 BOOL setFilenameScilabHistory(char *filename)
225 {
226     char * expandedPath = NULL;
227
228     if (filename)
229     {
230         if (ScilabHistory)
231         {
232             expandedPath = expandPathVariable(filename);
233             if (expandedPath)
234             {
235                 ScilabHistory->setFilename(expandedPath);
236                 FREE(expandedPath);
237             }
238             else
239             {
240                 ScilabHistory->setFilename(filename);
241             }
242
243             return TRUE;
244         }
245     }
246     return FALSE;
247 }
248
249 /*------------------------------------------------------------------------*/
250 char *getFilenameScilabHistory(void)
251 {
252     char *filename = NULL;
253
254     if (ScilabHistory)
255     {
256         filename = ScilabHistory->getFilename();
257     }
258     return filename;
259 }
260
261 /*------------------------------------------------------------------------*/
262 BOOL setDefaultFilenameScilabHistory(void)
263 {
264     if (ScilabHistory)
265     {
266         return ScilabHistory->setDefaultFilename();
267     }
268     return FALSE;
269 }
270
271 /*------------------------------------------------------------------------*/
272 void resetScilabHistory(void)
273 {
274     if (ScilabHistory)
275     {
276         ScilabHistory->reset();
277     }
278 }
279
280 /*------------------------------------------------------------------------*/
281 char **getAllLinesOfScilabHistory(void)
282 {
283     int nbElements = 0;
284     char **lines = NULL;
285
286     if (ScilabHistory)
287     {
288         lines = ScilabHistory->getAllLines(&nbElements);
289         /* SWIG need array finish with NULL */
290         if (lines)
291         {
292             lines = (char **)REALLOC(lines, sizeof(char *) * (nbElements + 1));
293             lines[nbElements] = NULL;
294         }
295     }
296     return lines;
297 }
298
299 /*------------------------------------------------------------------------*/
300 int getSizeAllLinesOfScilabHistory(void)
301 {
302     int nbElements = 0;
303     char **lines = NULL;
304
305     if (ScilabHistory)
306     {
307         lines = ScilabHistory->getAllLines(&nbElements);
308     }
309
310     freeArrayOfString(lines, nbElements);
311
312     return nbElements;
313 }
314
315 /*------------------------------------------------------------------------*/
316 char *getLastLineInScilabHistory(void)
317 {
318     char *line = NULL;
319
320     if (ScilabHistory)
321     {
322         line = ScilabHistory->getLastLine();
323     }
324     return line;
325 }
326
327 /*------------------------------------------------------------------------*/
328 char *getPreviousLineInScilabHistory(void)
329 {
330     char *line = NULL;
331
332     if (ScilabHistory)
333     {
334         line = ScilabHistory->getPreviousLine();
335     }
336     return line;
337 }
338
339 /*------------------------------------------------------------------------*/
340 char *getNextLineInScilabHistory(void)
341 {
342     char *line = NULL;
343
344     if (ScilabHistory)
345     {
346         line = ScilabHistory->getNextLine();
347     }
348     return line;
349 }
350
351 /*------------------------------------------------------------------------*/
352 int getNumberOfLinesInScilabHistory(void)
353 {
354     int val = 0;
355
356     if (ScilabHistory)
357     {
358         val = ScilabHistory->getNumberOfLines();
359     }
360     return val;
361 }
362
363 /*------------------------------------------------------------------------*/
364 void setSaveConsecutiveDuplicateLinesInScilabHistory(BOOL doit)
365 {
366     if (ScilabHistory)
367     {
368         ScilabHistory->setSaveConsecutiveDuplicateLines(doit);
369     }
370 }
371
372 /*------------------------------------------------------------------------*/
373 BOOL getSaveConsecutiveDuplicateLinesInScilabHistory(void)
374 {
375     if (ScilabHistory)
376     {
377         return ScilabHistory->getSaveConsecutiveDuplicateLines();
378     }
379     return FALSE;
380 }
381
382 /*------------------------------------------------------------------------*/
383 void setAfterHowManyLinesScilabHistoryIsSaved(int num)
384 {
385     if (ScilabHistory)
386     {
387         ScilabHistory->setAfterHowManyLinesHistoryIsSaved(num);
388     }
389 }
390
391 /*------------------------------------------------------------------------*/
392 int getAfterHowManyLinesScilabHistoryIsSaved(void)
393 {
394     int val = 0;
395
396     if (ScilabHistory)
397     {
398         val = ScilabHistory->getAfterHowManyLinesHistoryIsSaved();
399     }
400     return val;
401 }
402
403 /*------------------------------------------------------------------------*/
404 char *getNthLineInScilabHistory(int N)
405 {
406     if (ScilabHistory)
407     {
408         return ScilabHistory->getNthLine(N);
409     }
410     return NULL;
411 }
412
413 /*------------------------------------------------------------------------*/
414 BOOL deleteNthLineScilabHistory(int N)
415 {
416     if (ScilabHistory)
417     {
418         return ScilabHistory->deleteNthLine(N);
419     }
420     return FALSE;
421 }
422
423 /*------------------------------------------------------------------------*/
424 int getSizeScilabHistory(void)
425 {
426     int val = 0;
427
428     if (ScilabHistory)
429     {
430         val = ScilabHistory->getNumberOfLines() - 1;
431     }
432     return val;
433 }
434
435 /*------------------------------------------------------------------------*/
436 BOOL setSizeMaxScilabHistory(int nbLinesMax)
437 {
438     BOOL bOK = FALSE;
439     if (ScilabHistory)
440     {
441         bOK = ScilabHistory->setNumberOfLinesMax(nbLinesMax);
442     }
443     return bOK;
444 }
445 /*------------------------------------------------------------------------*/
446 int getSizeMaxScilabHistory(void)
447 {
448     int val = 0;
449     if (ScilabHistory)
450     {
451         val = ScilabHistory->getNumberOfLinesMax();
452     }
453     return val;
454 }
455 /*------------------------------------------------------------------------*/
456 HistoryManager::HistoryManager()
457 {
458     bTruncated = FALSE;
459     CommandsList.clear();
460     saveconsecutiveduplicatelines = FALSE;
461     afterhowmanylineshistoryissaved = 0;
462     numberoflinesbeforehistoryissaved = 0;
463
464     CommandHistoryInitialize();
465 }
466
467 /*------------------------------------------------------------------------*/
468 HistoryManager::~HistoryManager()
469 {
470     CommandsList.clear();
471 }
472
473 /*------------------------------------------------------------------------*/
474 BOOL HistoryManager::appendLine(char *cline)
475 {
476     BOOL bOK = FALSE;
477
478     if (cline)
479     {
480         if (!saveconsecutiveduplicatelines)
481         {
482             char *previousline = getLastLine();
483
484             if ((previousline) && (strcmp(previousline, cline) == 0))
485             {
486                 bOK = FALSE;
487             }
488             else
489             {
490                 CommandLine Line(cline);
491
492                 CommandsList.push_back(Line);
493                 numberoflinesbeforehistoryissaved++;
494                 bOK = TRUE;
495
496                 CommandHistoryAppendLine(cline);
497             }
498             if (previousline)
499             {
500                 FREE(previousline);
501                 previousline = NULL;
502             }
503         }
504         else
505         {
506             CommandLine Line(cline);
507
508             CommandsList.push_back(Line);
509
510             numberoflinesbeforehistoryissaved++;
511             bOK = TRUE;
512
513             CommandHistoryAppendLine(cline);
514         }
515     }
516
517     if (afterhowmanylineshistoryissaved != 0)
518     {
519         if (afterhowmanylineshistoryissaved == numberoflinesbeforehistoryissaved)
520         {
521             my_file.setHistory(CommandsList);
522             my_file.writeToFile();
523             numberoflinesbeforehistoryissaved = 0;
524         }
525     }
526     else
527     {
528         numberoflinesbeforehistoryissaved = 0;
529     }
530
531     return bOK;
532 }
533
534 /*------------------------------------------------------------------------*/
535 BOOL HistoryManager::appendLines(char **lines, int nbrlines)
536 {
537     BOOL bOK = TRUE;
538     int i = 0;
539
540     for (i = 0; i < nbrlines; i++)
541     {
542         if ((lines[i] == NULL) || (!appendLine(lines[i])))
543         {
544             bOK = FALSE;
545         }
546     }
547     return bOK;
548 }
549
550 /*------------------------------------------------------------------------*/
551 void HistoryManager::displayHistory(void)
552 {
553     int nbline = 0;
554
555     list < CommandLine >::iterator it_commands;
556     for (it_commands = CommandsList.begin(); it_commands != CommandsList.end(); ++it_commands)
557     {
558         std::string line = (*it_commands).get();
559         if (!line.empty())
560         {
561             sciprint("%d : %s\n", nbline, line.c_str());
562             nbline++;
563         }
564     }
565 }
566
567 /*------------------------------------------------------------------------*/
568 char *HistoryManager::getFilename(void)
569 {
570     char *filename = NULL;
571
572     if (!my_file.getFilename().empty())
573     {
574         filename = strdup(my_file.getFilename().c_str());
575     }
576     return filename;
577 }
578
579 /*------------------------------------------------------------------------*/
580 void HistoryManager::setFilename(char *filename)
581 {
582     if (filename)
583     {
584         std::string name;
585         name.assign(filename);
586         my_file.setFilename(name);
587     }
588 }
589
590 /*------------------------------------------------------------------------*/
591 BOOL HistoryManager::setDefaultFilename(void)
592 {
593     return my_file.setDefaultFilename();
594 }
595
596 /*------------------------------------------------------------------------*/
597 BOOL HistoryManager::writeToFile(char *filename)
598 {
599     if (filename)
600     {
601         std::string name;
602         name.assign(filename);
603
604         my_file.setHistory(CommandsList);
605         return my_file.writeToFile(name);
606     }
607     return FALSE;
608 }
609
610 /*------------------------------------------------------------------------*/
611 BOOL HistoryManager::loadFromFile(char *filename)
612 {
613
614     if (filename)
615     {
616         char *commentbeginsession = NULL;
617
618         std::string name;
619         name.assign(filename);
620
621         if (my_file.loadFromFile(name) == HISTORY_TRUNCATED)
622         {
623             bTruncated = TRUE;
624         }
625
626         CommandsList.clear();
627         CommandsList = my_file.getHistory();
628
629         if (CommandsList.size() > 0)
630         {
631             char *firstLine = getFirstLine();
632
633             if (firstLine)
634             {
635                 if (!isBeginningSessionLine(firstLine))
636                 {
637                     fixHistorySession();
638                 }
639                 FREE(firstLine);
640                 firstLine = NULL;
641             }
642         }
643
644         /* add date & time @ begin session */
645         commentbeginsession = getCommentDateSession(FALSE);
646         appendLine(commentbeginsession);
647         FREE(commentbeginsession);
648         commentbeginsession = NULL;
649
650         CommandHistoryLoadFromFile();
651
652         return TRUE;
653     }
654     return FALSE;
655 }
656
657 /*--------------------------------------------------------------------------*/
658 void HistoryManager::reset(void)
659 {
660     char *commentbeginsession = NULL;
661
662     CommandsList.clear();
663
664     my_file.reset();
665     my_file.setDefaultFilename();
666
667     my_search.reset();
668
669     saveconsecutiveduplicatelines = FALSE;
670     afterhowmanylineshistoryissaved = 0;
671     numberoflinesbeforehistoryissaved = 0;
672
673     CommandHistoryReset();
674
675     /* Add date & time begin session */
676     commentbeginsession = getCommentDateSession(FALSE);
677     if (commentbeginsession)
678     {
679         appendLine(commentbeginsession);
680         FREE(commentbeginsession);
681         commentbeginsession = NULL;
682     }
683
684 }
685
686 /*--------------------------------------------------------------------------*/
687 char **HistoryManager::getAllLines(int *numberoflines)
688 {
689     char **lines = NULL;
690
691     *numberoflines = 0;
692
693     if (CommandsList.empty())
694     {
695         return lines;
696     }
697     else
698     {
699         list < CommandLine >::iterator it_commands;
700         int i = 0;
701
702         lines = (char **)MALLOC((int)CommandsList.size() * (sizeof(char *)));
703         for (it_commands = CommandsList.begin(); it_commands != CommandsList.end(); ++it_commands)
704         {
705             string line = (*it_commands).get();
706
707             if (!line.empty())
708             {
709                 lines[i] = strdup(line.c_str());
710                 i++;
711             }
712         }
713         *numberoflines = i;
714     }
715     return lines;
716 }
717
718 /*--------------------------------------------------------------------------*/
719 char *HistoryManager::getFirstLine(void)
720 {
721     char *line = NULL;
722
723     if (!CommandsList.empty())
724     {
725         std::string str;
726         list < CommandLine >::iterator it_commands = CommandsList.begin();
727         str = (*it_commands).get();
728         if (!str.empty())
729         {
730             line = strdup(str.c_str());
731         }
732     }
733     return line;
734 }
735
736 /*--------------------------------------------------------------------------*/
737 char *HistoryManager::getLastLine(void)
738 {
739     char *line = NULL;
740
741     if (!CommandsList.empty())
742     {
743         std::string str;
744         list < CommandLine >::iterator it_commands = CommandsList.end();
745         it_commands--;
746         str = (*it_commands).get();
747         if (!str.empty())
748         {
749             line = strdup(str.c_str());
750         }
751     }
752     return line;
753 }
754
755 /*--------------------------------------------------------------------------*/
756 int HistoryManager::getNumberOfLines(void)
757 {
758     return (int)CommandsList.size();
759 }
760
761 /*--------------------------------------------------------------------------*/
762 char *HistoryManager::getNthLine(int N)
763 {
764     char *line = NULL;
765
766     if (N < 0)
767     {
768         N = getNumberOfLines() + N;
769     }
770
771     if ((N >= 0) && (N <= getNumberOfLines()))
772     {
773         int i = 0;
774
775         list < CommandLine >::iterator it_commands;
776         for (it_commands = CommandsList.begin(); it_commands != CommandsList.end(); ++it_commands)
777         {
778             if (i == N)
779             {
780                 string str;
781
782                 str = (*it_commands).get();
783                 if (!str.empty())
784                 {
785                     return strdup(str.c_str());
786                 }
787             }
788             i++;
789         }
790     }
791     return line;
792 }
793
794 /*--------------------------------------------------------------------------*/
795 BOOL HistoryManager::deleteNthLine(int N)
796 {
797     if ((N >= 0) && (N <= getNumberOfLines()))
798     {
799         int i = 0;
800
801         list<CommandLine>::iterator it_start, it_end;
802         for (it_start = CommandsList.begin(); it_start != CommandsList.end(); ++it_start)
803         {
804             if (i == N)
805             {
806                 it_end = it_start;
807                 it_end++;
808                 if (isBeginningSessionLine(*it_start))
809                 {
810                     for (; it_end != CommandsList.end(); ++it_end)
811                     {
812                         if (isBeginningSessionLine(*it_end))
813                         {
814                             break;
815                         }
816                     }
817                 }
818
819                 CommandsList.erase(it_start, it_end);
820
821                 my_search.setHistory(CommandsList);
822                 my_search.setToken(std::string());
823
824                 CommandHistoryDeleteLine(N);
825                 return TRUE;
826             }
827             i++;
828         }
829     }
830     return FALSE;
831 }
832
833 /*--------------------------------------------------------------------------*/
834 void HistoryManager::setSaveConsecutiveDuplicateLines(BOOL doit)
835 {
836     saveconsecutiveduplicatelines = doit;
837 }
838
839 /*--------------------------------------------------------------------------*/
840 BOOL HistoryManager::getSaveConsecutiveDuplicateLines(void)
841 {
842     return saveconsecutiveduplicatelines;
843 }
844
845 /*--------------------------------------------------------------------------*/
846 void HistoryManager::setAfterHowManyLinesHistoryIsSaved(int num)
847 {
848     if (num >= 0)
849     {
850         afterhowmanylineshistoryissaved = num;
851         numberoflinesbeforehistoryissaved = 0;
852     }
853 }
854
855 /*--------------------------------------------------------------------------*/
856 int HistoryManager::getAfterHowManyLinesHistoryIsSaved(void)
857 {
858     return afterhowmanylineshistoryissaved;
859 }
860
861 /*--------------------------------------------------------------------------*/
862 char *HistoryManager::getPreviousLine(void)
863 {
864     char *returnedline = NULL;
865
866     if (my_search.getSize() > 0)
867     {
868         std::string line = my_search.getPreviousLine();
869         if (!line.empty())
870         {
871             returnedline = strdup(line.c_str());
872         }
873     }
874     return returnedline;
875 }
876
877 /*--------------------------------------------------------------------------*/
878 char *HistoryManager::getNextLine(void)
879 {
880     char *returnedline = NULL;
881
882     if (my_search.getSize() > 0)
883     {
884         std::string line = my_search.getNextLine();
885         returnedline = strdup(line.c_str());
886     }
887     return returnedline;
888 }
889
890 /*--------------------------------------------------------------------------*/
891 BOOL HistoryManager::setToken(char *token)
892 {
893     std::string Token;
894     if (token)
895     {
896         Token.assign(token);
897     }
898     my_search.setHistory(CommandsList);
899     return my_search.setToken(Token);
900 }
901
902 /*--------------------------------------------------------------------------*/
903 char *HistoryManager::getToken(void)
904 {
905     char *returnedtoken = NULL;
906
907     std::string token = my_search.getToken();
908
909     if (!token.empty())
910     {
911         returnedtoken = strdup(token.c_str());
912     }
913     return returnedtoken;
914 }
915
916 /*--------------------------------------------------------------------------*/
917 BOOL HistoryManager::resetToken(void)
918 {
919     return my_search.reset();
920 }
921
922 BOOL HistoryManager::isBeginningSessionLine(CommandLine& line)
923 {
924     std::string str = line.get();
925     return isBeginningSessionLine(str.c_str());
926 }
927
928 /*--------------------------------------------------------------------------*/
929 BOOL HistoryManager::isBeginningSessionLine(const char *line)
930 {
931     if (line)
932     {
933         size_t len_begin = strlen(SESSION_PRAGMA_BEGIN);
934         size_t len_end = strlen(SESSION_PRAGMA_END);
935         size_t len_line = strlen(line);
936
937         if (len_line > len_begin + len_end)
938         {
939             if ((strncmp(line, SESSION_PRAGMA_BEGIN, len_begin) == 0) &&
940                     (strncmp(line + len_line - len_end, SESSION_PRAGMA_END, len_end) == 0))
941             {
942                 return TRUE;
943             }
944         }
945     }
946     return FALSE;
947 }
948
949
950
951 /*--------------------------------------------------------------------------*/
952 void HistoryManager::fixHistorySession(void)
953 {
954     /* add date & time @ begin session */
955     char *commentbeginsession = getCommentDateSession(FALSE);
956
957     if (commentbeginsession)
958     {
959         CommandLine Line(commentbeginsession);
960
961         CommandsList.push_front(Line);
962         FREE(commentbeginsession);
963         commentbeginsession = NULL;
964     }
965 }
966
967 /*--------------------------------------------------------------------------*/
968 BOOL HistoryManager::isTruncated(void)
969 {
970     return bTruncated;
971 }
972 /*--------------------------------------------------------------------------*/
973 BOOL HistoryManager::setNumberOfLinesMax(int nbLinesMax)
974 {
975     return my_file.setDefaultMaxNbLines(nbLinesMax);
976 }
977 /*--------------------------------------------------------------------------*/
978 int HistoryManager::getNumberOfLinesMax(void)
979 {
980     return my_file.getDefaultMaxNbLines();
981 }
982 /*--------------------------------------------------------------------------*/