Subversion Repositories Kolibri OS

Rev

Rev 4544 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. struct path_string {
  2.         char Item[sizeof(URL)];
  3.         int was_first;
  4. };
  5.  
  6. #define MAX_HISTORY_NUM 40
  7. path_string history_list[MAX_HISTORY_NUM];
  8.  
  9. struct UrlsHistory {
  10.         int links_count;
  11.         int current;
  12.         dword CurrentUrl();
  13.         dword GetUrl();
  14.         dword GetFirstLine();
  15.         void AddUrl();
  16.         byte GoBack();
  17.         byte GoForward();
  18. };
  19.  
  20. dword UrlsHistory::CurrentUrl() {
  21.         return #history_list[current].Item;
  22. }
  23.  
  24. dword UrlsHistory::GetUrl(int id) {
  25.         return #history_list[id].Item;
  26. }
  27.  
  28. dword UrlsHistory::GetFirstLine(int id) {
  29.         return history_list[id].was_first;
  30. }
  31.  
  32. void UrlsHistory::AddUrl() {
  33.         int i;
  34.         if (links_count>0) && (!strcmp(#URL,#history_list[current].Item)) return;
  35.  
  36.         if (current>=MAX_HISTORY_NUM-1)
  37.         {
  38.                 current/=2;
  39.                 for (i=0; i<current; i++;)
  40.                 {
  41.                         strlcpy(#history_list[i].Item, #history_list[MAX_HISTORY_NUM-i].Item, sizeof(URL));
  42.                 }      
  43.         }
  44.         current++;
  45.         // history_list[i].was_first = WB1.list.first;
  46.         strlcpy(#history_list[current].Item, #URL, sizeof(URL));
  47.         links_count=current;
  48. }
  49.  
  50.  
  51. byte UrlsHistory::GoBack() {
  52.         if (current<=1) return 0;
  53.         current--;
  54.         strlcpy(#URL, #history_list[current].Item, sizeof(URL));
  55.         // stroka = history_list[current].was_first;
  56.         return 1;
  57. }
  58.  
  59.  
  60. byte UrlsHistory::GoForward() {
  61.         if (current==links_count) return 0;
  62.         current++;
  63.         strlcpy(#URL, #history_list[current].Item, sizeof(URL));
  64.         return 1;
  65. }
  66.  
  67. UrlsHistory BrowserHistory;