Console_internal.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /* Copyright (c) 2002-2012 Croteam Ltd.
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of version 2 of the GNU General Public License as published by
  4. the Free Software Foundation
  5. This program is distributed in the hope that it will be useful,
  6. but WITHOUT ANY WARRANTY; without even the implied warranty of
  7. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  8. GNU General Public License for more details.
  9. You should have received a copy of the GNU General Public License along
  10. with this program; if not, write to the Free Software Foundation, Inc.,
  11. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
  12. #ifndef SE_INCL_CONSOLE_INTERNAL_H
  13. #define SE_INCL_CONSOLE_INTERNAL_H
  14. #ifdef PRAGMA_ONCE
  15. #pragma once
  16. #endif
  17. #include <Engine/Base/Synchronization.h>
  18. // Object that takes care of game console.
  19. #define CONSOLE_MAXLASTLINES 15 // how many last-line times to remember
  20. class CConsole {
  21. public:
  22. // implementation:
  23. CTCriticalSection con_csConsole; // critical section for access to console data
  24. char *con_strBuffer; // the allocated buffer
  25. char *con_strCurrent; // next char to print
  26. char *con_strLastLine; // start of last line in buffer
  27. char *con_strLineBuffer; // one-line-sized buffer for temp usage
  28. INDEX con_ctCharsPerLine; // number of characters per line
  29. INDEX con_ctLines; // number of total lines
  30. TIME *con_atmLines; // time stamp for each line
  31. INDEX con_ctLinesPrinted; // number of lines printed
  32. FILE *con_fLog; // log file for streaming the console to
  33. // clear line buffer
  34. void ClearLineBuffer();
  35. // clear one given line in buffer
  36. void ClearLine(INDEX iLine);
  37. // scroll buffer up, discarding lines at the start
  38. void ScrollBufferUp(INDEX ctBytesToFree);
  39. // Move last line times one place back and add new time
  40. void NewLastTime(TIME tmNew);
  41. // interface:
  42. // Constructor.
  43. CConsole(void);
  44. // Destructor.
  45. ~CConsole(void);
  46. // Initialize the console.
  47. void Initialize(const CTFileName &fnmLog, INDEX ctCharsPerLine, INDEX ctLines);
  48. // Get current console buffer.
  49. ENGINE_API const char *GetBuffer(void);
  50. ENGINE_API INDEX GetBufferSize(void);
  51. // Add a string of text to console
  52. void PutString(const char *strString);
  53. // Close console log file buffers (call only when force-exiting!)
  54. void CloseLog(void);
  55. // Get number of lines newer than given time
  56. INDEX NumberOfLinesAfter(TIME tmLast);
  57. // Get one of last lines
  58. CTString GetLastLine(INDEX iLine);
  59. // Discard timing info for last lines
  60. void DiscardLastLineTimes(void);
  61. };
  62. ENGINE_API extern CConsole *_pConsole;
  63. #endif /* include-once check. */