bool ViewerConfig::loadFromStorage(SettingsManager *storage) { bool loadAllOk = true; TEST_FAIL(storage->getInt(_T("LogLevel"), &m_logLevel), loadAllOk); setLogLevel(m_logLevel); TEST_FAIL(storage->getInt(_T("ListenPort"), &m_listenPort), loadAllOk); TEST_FAIL(storage->getInt(_T("HistoryLimit"), &m_historyLimit), loadAllOk); setHistoryLimit(m_historyLimit); // // FIXME: Why registry entry has "NoToolbar" name but // meaning of code in what, that is this flag is set then // toolbar become visible. // TEST_FAIL(storage->getBoolean(_T("NoToolbar"), &m_showToolbar), loadAllOk); if (storage->getBoolean(_T("SkipFullScreenPrompt"), &m_promptOnFullscreen)) { m_promptOnFullscreen = !m_promptOnFullscreen; } else { loadAllOk = false; } return loadAllOk; }
/* * Newest item always gets added to index 0 */ short addHistoryItem(historyItem *h) { /* In case we get called before being initialized */ if (maxitems == 0) { setHistoryLimit(32); } if (h == NULL || history == NULL) return 1; /* Delete first item to make room for this one */ if (nitems == maxitems) { delHistoryItem(nitems-1); } else { nitems++; } printf("addHistoryItem: I am now holding %d (max=%d) items\n", nitems, maxitems); memmove(history+1, history, ((nitems-1)*sizeof(historyItem *))); history[0] = h; return 0; }
int main(int argc, char *argv[]) { int i, *a; historyItem *h; setHistoryLimit(15); for (i=0;i < 6; i++) { a = (int *)malloc(sizeof(int)); *a = i; h = newHistoryItem(a); addHistoryItem(h); } /* Start at the beginning */ setHistoryIndex(numHistoryItems()); while ((h = nextHistoryItem(0)) != NULL) { printf("h[%d]->a is %d\n", getHistoryIndex(), *(int *)h->data); } printf("Doing the reverse now...\n"); setHistoryIndex(3); for (i=0;i<6;i++) { h = prevHistoryItem(1); if (h) printf("h[%d]->a is %d\n", getHistoryIndex(), *(int *)h->data); } return 0; }
short addHistoryItem2(historyItem *h) { if (maxitems == 0) { setHistoryLimit(32); } if (h == NULL || history == NULL) return 1; while (nitems >= maxitems) { // Delete oldest item(s) delHistoryItem2(0); nitems--; } history[(nitems % maxitems)] = h; nitems++; return 0; }