Re: [wikireader] Border interactions

2009-12-26 Thread Ron Hale-Evans
Tim,

This sounds awesome! I hope it becomes standard.

Could you please attach a complete kernel for those of us who are too
lazy to set up a toolchain right now? :)

Happy holidays and thanks,

Ron H-E

On Thu, Dec 24, 2009 at 4:13 AM, Tim Besard tim.bes...@gmail.com wrote:
 Seems like patch didn't get through, reposting bzipped.

 -Tim

 Op woensdag 16-12-2009 om 22:28 uur [tijdzone +0100], schreef Tim
 Besard:
 Hi all,

 Attached to this mail is a small patch I wrote a while ago, introducing
 border interactions. It quite simply hacks in a 15px magical border
 which when tapped induces certain actions:
   * upper border: page up;
   * lower border: page down;
   * left border: history back;
   * right border: history forward.

 I've added page up  down because it reads far faster and scrolling
 (at least on my wikireader) turned out to be quite unreadable. History
 back and forward are handy shortcuts while clicking through links of an
 article.

 -Tim



 ___
 Openmoko community mailing list
 community@lists.openmoko.org
 http://lists.openmoko.org/mailman/listinfo/community





-- 
Ron Hale-Evans ... r...@ludism.org ... http://ron.ludism.org/ ... (206) 201-1768
Mind Performance Hacks book: http://oreilly.com/catalog/9780596101534/
 The proteiform graph itself is a polyhedron of scripture. (Finnegans
Wake 107:08)

___
Openmoko community mailing list
community@lists.openmoko.org
http://lists.openmoko.org/mailman/listinfo/community


Re: [wikireader] Border interactions

2009-12-24 Thread Tim Besard
Seems like patch didn't get through, reposting bzipped.

-Tim

Op woensdag 16-12-2009 om 22:28 uur [tijdzone +0100], schreef Tim
Besard:
 Hi all,
 
 Attached to this mail is a small patch I wrote a while ago, introducing
 border interactions. It quite simply hacks in a 15px magical border
 which when tapped induces certain actions:
   * upper border: page up;
   * lower border: page down;
   * left border: history back;
   * right border: history forward.
 
 I've added page up  down because it reads far faster and scrolling
 (at least on my wikireader) turned out to be quite unreadable. History
 back and forward are handy shortcuts while clicking through links of an
 article.
 
 -Tim
 



binx47P1LNsiF.bin
Description: application/bzip
___
Openmoko community mailing list
community@lists.openmoko.org
http://lists.openmoko.org/mailman/listinfo/community


[wikireader] Border interactions

2009-12-16 Thread Tim Besard
Hi all,

Attached to this mail is a small patch I wrote a while ago, introducing
border interactions. It quite simply hacks in a 15px magical border
which when tapped induces certain actions:
  * upper border: page up;
  * lower border: page down;
  * left border: history back;
  * right border: history forward.

I've added page up  down because it reads far faster and scrolling
(at least on my wikireader) turned out to be quite unreadable. History
back and forward are handy shortcuts while clicking through links of an
article.

-Tim

From b10b2a9fbd6e91910f1f0012520f9cbcbc987c91 Mon Sep 17 00:00:00 2001
From: Tim Besard tim.bes...@gmail.com
Date: Sat, 28 Nov 2009 16:37:35 +0100
Subject: [PATCH] Border interactions (history navigation and page up/down).

---
 wiki-app/history.c  |   39 +++---
 wiki-app/history.h  |7 ++-
 wiki-app/lcd_buf_draw.c |  101 +++---
 wiki-app/lcd_buf_draw.h |3 +
 wiki-app/wikilib.c  |   23 ++-
 5 files changed, 140 insertions(+), 33 deletions(-)

diff --git a/wiki-app/history.c b/wiki-app/history.c
index 7548b06..d6ebef7 100644
--- a/wiki-app/history.c
+++ b/wiki-app/history.c
@@ -44,6 +44,7 @@ int history_count = 0;
 int rendered_history_count = -1;
 int history_changed = HISTORY_SAVE_NONE;
 extern int display_mode;
+int history_index = 0;
 
 static inline unsigned int history_modulus(int modulus) {
 	return modulus % HISTORY_MAX_DISPLAY_ITEM;
@@ -55,10 +56,14 @@ void history_reload()
 	render_history_with_pcf();
 }
 
-void history_add(const long idx_article, const char *title, int b_keep_pos)
+void history_add(const long idx_article, const char *title, int b_keep_pos, int b_shift)
 {
 	int i = 0;
 	int bFound = 0;
+	
+	if (b_shift)
+		history_shift(history_index);
+	history_index = 0;
 
 	history_changed = HISTORY_SAVE_NORMAL;
 	while (!bFound  i  history_count)
@@ -89,11 +94,23 @@ void history_add(const long idx_article, const char *title, int b_keep_pos)
 	history_count++;
 }
 
-void history_log_y_pos(const long y_pos)
-{
-	if (history_changed != HISTORY_SAVE_NORMAL)
-		history_changed = HISTORY_SAVE_POWER_OFF;
-	history_list[0].last_y_pos = y_pos;
+long history_get_article() {
+	return history_list[history_index].idx_article;	
+}
+
+void history_shift(int amount) {
+	if (amount = 0)
+		return;
+	if (amount = history_count) {
+		history_clear();
+		return;
+	}
+	history_count -= amount;
+	memcpy((void*)history_list[0],(void*)history_list[amount],sizeof(HISTORY)*history_count);
+}
+
+void history_set_y_pos(const long y_pos) {
+	history_list[history_index].last_y_pos = y_pos;
 }
 
 long history_get_y_pos(const long idx_article)
@@ -164,6 +181,16 @@ int history_list_save(int level)
 	return rc;
 }
 
+void history_navigate(int articles) {
+	int index = history_index - articles;
+	if (index  0 || index = history_count)
+		return;
+	history_index -= articles;
+	long idx_article = history_get_article();
+	
+	display_revisited_article(idx_article);
+}
+
 void draw_clear_history(int bClear)
 {
 	int i;
diff --git a/wiki-app/history.h b/wiki-app/history.h
index 6117783..d10c756 100644
--- a/wiki-app/history.h
+++ b/wiki-app/history.h
@@ -34,15 +34,18 @@
 
 void history_clear(void);
 
-void history_add(const long idx_article, const char *title, int b_keep_pos);
+void history_add(const long idx_article, const char *title, int b_keep_pos, int b_shift);
 unsigned int history_get_count();
 void history_list_init(void);
 int history_list_save(int level);
 
 void history_open_article(int new_selection);
 void history_reload();
-void history_log_y_pos(const long y_pos);
+long history_get_article();
+void history_shift(int amount);
+void history_set_y_pos(const long y_pos);
 long history_get_y_pos(const long idx_article);
+void history_navigate(int articles);
 void draw_clear_history(int bFlag);
 
 typedef struct _HISTORY {
diff --git a/wiki-app/lcd_buf_draw.c b/wiki-app/lcd_buf_draw.c
index 51bceb1..9d80619 100644
--- a/wiki-app/lcd_buf_draw.c
+++ b/wiki-app/lcd_buf_draw.c
@@ -106,6 +106,8 @@ int stop_render_article = 0;
 int b_show_scroll_bar = 0;
 long saved_idx_article;
 
+bool hist_revisit = false;
+
 #define MIN_BAR_LEN 20
 void show_scroll_bar(int bShow)
 {
@@ -1199,7 +1201,7 @@ void display_article_with_pcf(int start_y)
 	if (lcd_draw_cur_y_pos  0)
 		lcd_draw_cur_y_pos = 0;
 	if (display_mode == DISPLAY_MODE_ARTICLE)
-		history_log_y_pos(lcd_draw_cur_y_pos);
+		history_set_y_pos(lcd_draw_cur_y_pos);
 
 	pos = (lcd_draw_cur_y_pos*LCD_VRAM_WIDTH_PIXELS)/8;
 
@@ -1223,7 +1225,7 @@ float scroll_speed()
 void scroll_article(void)
 {
 	unsigned long time_now, delay_time;
-	long pos;
+	int article_scroll_actual;
 
 	if(finger_move_speed == 0)
 	  return;
@@ -1244,26 +1246,13 @@ void scroll_article(void)
 		time_scroll_article_last = time_now;
 
 		article_scroll_increment = (float)finger_move_speed * ((float)delay_time / (float)seconds_to_ticks(1));
-
-		lcd_draw_cur_y_pos += article_scroll_increment;