Created
May 21, 2014 12:44
-
-
Save atomicules/a0c3d297af2495ccc894 to your computer and use it in GitHub Desktop.
Patches for Snownews to add simplistic undo for "mark all read"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$NetBSD$ | |
--- config.h.orig 2009-09-17 06:44:28.000000000 +0000 | |
+++ config.h | |
@@ -61,6 +61,7 @@ struct newsitem { | |
struct newsdata { | |
struct feed *parent; | |
int readstatus; /* 0: unread, 1: read */ | |
+ int prevreadstatus; /* 0: unread, 1: read */ | |
char *title; | |
char *link; | |
char *description; | |
@@ -78,7 +79,9 @@ struct keybindings { | |
char deletefeed; | |
char markread; | |
char markunread; | |
+ char undoread; | |
char markallread; | |
+ char undoallread; | |
char dfltbrowser; | |
char moveup; | |
char movedown; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$NetBSD$ | |
--- dialog.c.orig 2009-09-17 06:44:27.000000000 +0000 | |
+++ dialog.c | |
@@ -409,12 +409,13 @@ void UIHelpScreen (void) { | |
attron (WA_REVERSE); | |
/* Keys */ | |
- mvprintw (centery-9, centerx-offset, "%c:", keybindings.addfeed); | |
- mvprintw (centery-8, centerx-offset, "%c:", keybindings.deletefeed); | |
- mvprintw (centery-7, centerx-offset, "%c:", keybindings.changefeedname); | |
- mvprintw (centery-6, centerx-offset, "%c:", keybindings.reloadall); | |
- mvprintw (centery-5, centerx-offset, "%c:", keybindings.reload); | |
- mvprintw (centery-4, centerx-offset, "%c:", keybindings.markallread); | |
+ mvprintw (centery-10, centerx-offset, "%c:", keybindings.addfeed); | |
+ mvprintw (centery-9, centerx-offset, "%c:", keybindings.deletefeed); | |
+ mvprintw (centery-8, centerx-offset, "%c:", keybindings.changefeedname); | |
+ mvprintw (centery-7, centerx-offset, "%c:", keybindings.reloadall); | |
+ mvprintw (centery-6, centerx-offset, "%c:", keybindings.reload); | |
+ mvprintw (centery-5, centerx-offset, "%c:", keybindings.markallread); | |
+ mvprintw (centery-4, centerx-offset, "%c:", keybindings.undoallread); | |
mvprintw (centery-3, centerx-offset, "%c:", keybindings.dfltbrowser); | |
mvprintw (centery-2, centerx-offset, "%c, %c:", keybindings.moveup, keybindings.movedown); | |
mvprintw (centery-1, centerx-offset, "%c:", keybindings.sortfeeds); | |
@@ -429,12 +430,13 @@ void UIHelpScreen (void) { | |
mvprintw (centery+8, centerx-offset, "%c:", 'E'); | |
mvprintw (centery+9, centerx-offset, "%c:", keybindings.quit); | |
/* Descriptions */ | |
- mvaddstr (centery-9, centerx-offsetstr, _("Add RSS feed...")); | |
- mvaddstr (centery-8, centerx-offsetstr, _("Delete highlighted RSS feed...")); | |
- mvaddstr (centery-7, centerx-offsetstr, _("Rename feed...")); | |
- mvaddstr (centery-6, centerx-offsetstr, _("Reload all feeds")); | |
- mvaddstr (centery-5, centerx-offsetstr, _("Reload this feed")); | |
- mvaddstr (centery-4, centerx-offsetstr, _("Mark all read")); | |
+ mvaddstr (centery-10, centerx-offsetstr, _("Add RSS feed...")); | |
+ mvaddstr (centery-9, centerx-offsetstr, _("Delete highlighted RSS feed...")); | |
+ mvaddstr (centery-8, centerx-offsetstr, _("Rename feed...")); | |
+ mvaddstr (centery-7, centerx-offsetstr, _("Reload all feeds")); | |
+ mvaddstr (centery-6, centerx-offsetstr, _("Reload this feed")); | |
+ mvaddstr (centery-5, centerx-offsetstr, _("Mark all read")); | |
+ mvaddstr (centery-4, centerx-offsetstr, _("Unod mark all read")); | |
mvaddstr (centery-3, centerx-offsetstr, _("Change default browser...")); | |
mvaddstr (centery-2, centerx-offsetstr, _("Move item up, down")); | |
mvaddstr (centery-1, centerx-offsetstr, _("Sort feed list alphabetically")); | |
@@ -480,10 +482,11 @@ void UIDisplayFeedHelp (void) { | |
mvprintw (centery, centerx-offset, "%c:", keybindings.urljump); | |
mvprintw (centery+1, centerx-offset, "%c:", keybindings.urljump2); | |
mvprintw (centery+2, centerx-offset, "%c:", keybindings.markread); | |
- mvprintw (centery+3, centerx-offset, "%c:", keybindings.markunread); | |
- mvprintw (centery+4, centerx-offset, "%c:", keybindings.feedinfo); | |
- mvaddstr (centery+5, centerx-offset, _("tab:")); | |
- mvprintw (centery+6, centerx-offset, "%c:", keybindings.prevmenu); | |
+ mvprintw (centery+3, centerx-offset, "%c:", keybindings.undoread); | |
+ mvprintw (centery+4, centerx-offset, "%c:", keybindings.markunread); | |
+ mvprintw (centery+5, centerx-offset, "%c:", keybindings.feedinfo); | |
+ mvaddstr (centery+6, centerx-offset, _("tab:")); | |
+ mvprintw (centery+7, centerx-offset, "%c:", keybindings.prevmenu); | |
/* Descriptions */ | |
mvprintw (centery-5, centerx-offsetstr, _("Previous item")); | |
mvprintw (centery-4, centerx-offsetstr, _("Next item")); | |
@@ -493,10 +496,11 @@ void UIDisplayFeedHelp (void) { | |
mvprintw (centery, centerx-offsetstr, _("Open homepage")); | |
mvprintw (centery+1, centerx-offsetstr, _("Open link")); | |
mvprintw (centery+2, centerx-offsetstr, _("Mark all read")); | |
- mvprintw (centery+3, centerx-offsetstr, _("Toggle item read status")); | |
- mvprintw (centery+4, centerx-offsetstr, _("Show feed info...")); | |
- mvaddstr (centery+5, centerx-offsetstr, _("Type Ahead Find")); | |
- mvprintw (centery+6, centerx-offsetstr, _("Return to main menu")); | |
+ mvprintw (centery+3, centerx-offsetstr, _("Undo mark all read")); | |
+ mvprintw (centery+4, centerx-offsetstr, _("Toggle item read status")); | |
+ mvprintw (centery+5, centerx-offsetstr, _("Show feed info...")); | |
+ mvaddstr (centery+6, centerx-offsetstr, _("Type Ahead Find")); | |
+ mvprintw (centery+7, centerx-offsetstr, _("Return to main menu")); | |
attroff (WA_REVERSE); | |
UIStatus (_("Press the any(tm) key to exit help screen."), 0, 0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$NetBSD$ | |
--- interface.c.orig 2009-09-17 06:44:27.000000000 +0000 | |
+++ interface.c | |
@@ -289,7 +289,7 @@ void UIDisplayItem (struct newsitem * cu | |
(uiinput == '?')) | |
UIDisplayItemHelp(); | |
if ((uiinput == '\n') || | |
- (uiinput == keybindings.prevmenu) || (uiinput == keybindings.enter)) { | |
+ (uiinput == keybindings.prevmenu)) { | |
/* Free the wrapped text linked list. | |
Why didn't valgrind find this? Counted as "still reachable". | |
Strange voodoo magic may be going on here! Maybe we just append | |
@@ -722,8 +722,7 @@ int UIDisplayFeed (struct feed * current | |
} | |
} | |
/* Move highlight one page up/down == LINES-9 */ | |
- if ((uiinput == KEY_NPAGE) || (uiinput == 32) || | |
- (uiinput == keybindings.pdown)) { | |
+ if ((uiinput == KEY_NPAGE) || (uiinput == keybindings.pdown)) { | |
if (highlighted != NULL) { | |
for (i = highlightnum; i <= LINES-8; i++) { | |
if (highlighted->next_ptr != NULL) { | |
@@ -795,9 +794,17 @@ int UIDisplayFeed (struct feed * current | |
if (uiinput == keybindings.markread) { | |
/* Mark everything read. */ | |
for (markasread = current_feed->items; markasread != NULL; markasread = markasread->next_ptr) { | |
+ /* backup previous value */ | |
+ markasread->data->prevreadstatus = markasread->data->readstatus; | |
markasread->data->readstatus = 1; | |
} | |
} | |
+ if (uiinput == keybindings.undoread) { | |
+ for (markasread = current_feed->items; markasread != NULL; markasread = markasread->next_ptr) { | |
+ /* markasread is a bit of a naff name for the pointer here, but see no need to create new one */ | |
+ markasread->data->readstatus = markasread->data->prevreadstatus; | |
+ } | |
+ } | |
if (uiinput == keybindings.markunread) { | |
/* highlighted->data->readstatus = 0; */ | |
/* Works as toggle function now. */ | |
@@ -1436,8 +1443,7 @@ void UIMainInterface (void) { | |
} | |
} | |
/* Move highlight one page up/down == LINES-6 */ | |
- if ((uiinput == KEY_NPAGE) || (uiinput == 32) || | |
- (uiinput == keybindings.pdown)) { | |
+ if ((uiinput == KEY_NPAGE) || (uiinput == keybindings.pdown)) { | |
if (highlighted != NULL) { | |
for (i = highlightnum; i <= LINES-5; i++) { | |
if (highlighted->next_ptr != NULL) { | |
@@ -1527,10 +1533,18 @@ void UIMainInterface (void) { | |
if a filter is applied since we are using a copy of the main data. */ | |
for (cur_ptr = first_ptr; cur_ptr != NULL; cur_ptr = cur_ptr->next_ptr) { | |
for (markasread = cur_ptr->items; markasread != NULL; markasread = markasread->next_ptr) { | |
+ markasread->data->prevreadstatus = markasread->data->readstatus; | |
markasread->data->readstatus = 1; | |
} | |
} | |
} | |
+ if (uiinput == keybindings.undoallread) { | |
+ for (cur_ptr = first_ptr; cur_ptr != NULL; cur_ptr = cur_ptr->next_ptr) { | |
+ for (markasread = cur_ptr->items; markasread != NULL; markasread = markasread->next_ptr) { | |
+ markasread->data->readstatus = markasread->data->prevreadstatus; | |
+ } | |
+ } | |
+ } | |
if (uiinput == keybindings.about) | |
UIAbout(); | |
if (uiinput == keybindings.changefeedname) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$NetBSD$ | |
--- setup.c.orig 2009-09-17 06:44:27.000000000 +0000 | |
+++ setup.c | |
@@ -158,7 +158,9 @@ void SetupKeybindings (const char * file | |
keybindings.addfeed = 'a'; | |
keybindings.deletefeed = 'D'; | |
keybindings.markread = 'm'; | |
+ keybindings.undoread = 'U'; | |
keybindings.markallread = 'm'; | |
+ keybindings.undoallread = 'U'; | |
keybindings.markunread = 'M'; | |
keybindings.dfltbrowser = 'B'; | |
keybindings.moveup = 'P'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment