diff options
-rw-r--r-- | src/app.c | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -179,6 +179,29 @@ static void saveHistory_App_(const iApp *d) { | |||
179 | iRelease(f); | 179 | iRelease(f); |
180 | } | 180 | } |
181 | 181 | ||
182 | static void loadHistory_App_(iApp *d) { | ||
183 | iFile *f = new_File(historyFileName_()); | ||
184 | if (open_File(f, readOnly_FileMode | text_FileMode)) { | ||
185 | iString *src = newBlock_String(collect_Block(readAll_File(f))); | ||
186 | const iRangecc range = range_String(src); | ||
187 | iRangecc line = iNullRange; | ||
188 | while (nextSplit_Rangecc(&range, "\n", &line)) { | ||
189 | int y, m, D, H, M, S; | ||
190 | sscanf(line.start, "%04d-%02d-%02dT%02d:%02d:%02d", &y, &m, &D, &H, &M, &S); | ||
191 | if (!y) break; | ||
192 | iHistoryItem item; | ||
193 | init_HistoryItem(&item); | ||
194 | init_Time( | ||
195 | &item.when, | ||
196 | &(iDate){ .year = y, .month = m, .day = D, .hour = H, .minute = M, .second = S }); | ||
197 | initCStrN_String(&item.url, line.start + 20, size_Range(&line) - 20); | ||
198 | pushBack_Array(&d->history, &item); | ||
199 | } | ||
200 | delete_String(src); | ||
201 | } | ||
202 | iRelease(f); | ||
203 | } | ||
204 | |||
182 | static void clearHistory_App_(iApp *d) { | 205 | static void clearHistory_App_(iApp *d) { |
183 | iForEach(Array, i, &d->history) { | 206 | iForEach(Array, i, &d->history) { |
184 | deinit_HistoryItem(i.value); | 207 | deinit_HistoryItem(i.value); |
@@ -196,6 +219,7 @@ static void init_App_(iApp *d, int argc, char **argv) { | |||
196 | d->retainWindowSize = iTrue; | 219 | d->retainWindowSize = iTrue; |
197 | d->pendingRefresh = iFalse; | 220 | d->pendingRefresh = iFalse; |
198 | loadPrefs_App_(d); | 221 | loadPrefs_App_(d); |
222 | loadHistory_App_(d); | ||
199 | d->window = new_Window(); | 223 | d->window = new_Window(); |
200 | /* Widget state init. */ { | 224 | /* Widget state init. */ { |
201 | iString *homePath = newCStr_String(dataDir_App_); | 225 | iString *homePath = newCStr_String(dataDir_App_); |