pluginlocalhistorybase.c 999 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. class PluginLocalHistoryBase extends PluginFileHandler
  2. {
  3. void PluginLocalHistoryBase()
  4. {
  5. m_ReadOnly = false;
  6. }
  7. void ~PluginLocalHistoryBase()
  8. {
  9. }
  10. override void OnInit()
  11. {
  12. super.OnInit();
  13. }
  14. override string GetFileName()
  15. {
  16. Error( "Cannot call GetFileName on Base class PluginLocalHistoryBase" );
  17. return STRING_EMPTY;
  18. }
  19. void AddNewLine(string text)
  20. {
  21. // replace newline to \\n
  22. text.Replace("\n", "\\n" );
  23. m_FileContent.Insert(text);
  24. SaveFile();
  25. }
  26. TStringArray GetAllLines()
  27. {
  28. // replace \\n to new line
  29. TStringArray console_history = new TStringArray;
  30. for ( int i = 0; i < m_FileContent.Count(); i++)
  31. {
  32. string history_record = m_FileContent.Get(i);
  33. history_record.Replace("\\n", "\n");
  34. console_history.Insert( history_record );
  35. }
  36. return console_history;
  37. }
  38. TStringArray GetLastLine()
  39. {
  40. int count = m_FileContent.Count();
  41. string ret = "";
  42. if ( count > 0 )
  43. {
  44. ret = m_FileContent.Get(count - 1);
  45. }
  46. return NULL;
  47. }
  48. }