diff options
author | Karl Kurbjun <kkurbjun@gmail.com> | 2006-06-03 07:04:02 +0000 |
---|---|---|
committer | Karl Kurbjun <kkurbjun@gmail.com> | 2006-06-03 07:04:02 +0000 |
commit | ca8fa65ab7489e3bfca84af8fb242e60846c6412 (patch) | |
tree | 166994f97348f8540a1a5622d1066eb317ddf63c /apps/plugins | |
parent | fcd65e56db510ddb5abc30e3f978ce14104a46ac (diff) | |
download | rockbox-ca8fa65ab7489e3bfca84af8fb242e60846c6412.tar.gz rockbox-ca8fa65ab7489e3bfca84af8fb242e60846c6412.zip |
Fix wide view mode on viewer
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10036 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins')
-rw-r--r-- | apps/plugins/viewer.c | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/apps/plugins/viewer.c b/apps/plugins/viewer.c index ebb8865ff9..4e72aa13bf 100644 --- a/apps/plugins/viewer.c +++ b/apps/plugins/viewer.c | |||
@@ -265,8 +265,9 @@ unsigned char* get_ucs(const unsigned char* str, unsigned short* ch) | |||
265 | bool done = false; | 265 | bool done = false; |
266 | int col = 0; | 266 | int col = 0; |
267 | 267 | ||
268 | #define ADVANCE_COUNTERS(c) do { width += glyph_width(c); k++; } while(0) | 268 | #define ADVANCE_COUNTERS(c) { width += glyph_width(c); k++; } |
269 | #define LINE_IS_FULL ((k>MAX_COLUMNS-1) || (width > draw_columns)) | 269 | #define LINE_IS_FULL ((k<MAX_COLUMNS-1) ||( width > draw_columns)) |
270 | #define LINE_IS_NOT_FULL ((k<MAX_COLUMNS-1) &&( width < draw_columns)) | ||
270 | static unsigned char* crop_at_width(const unsigned char* p) | 271 | static unsigned char* crop_at_width(const unsigned char* p) |
271 | { | 272 | { |
272 | int k,width; | 273 | int k,width; |
@@ -275,7 +276,7 @@ static unsigned char* crop_at_width(const unsigned char* p) | |||
275 | 276 | ||
276 | k=width=0; | 277 | k=width=0; |
277 | 278 | ||
278 | while (!LINE_IS_FULL) { | 279 | while (LINE_IS_NOT_FULL) { |
279 | oldp = p; | 280 | oldp = p; |
280 | p = get_ucs(p, &ch); | 281 | p = get_ucs(p, &ch); |
281 | ADVANCE_COUNTERS(ch); | 282 | ADVANCE_COUNTERS(ch); |
@@ -738,7 +739,7 @@ static void viewer_draw(int col) | |||
738 | if (col != -1) { | 739 | if (col != -1) { |
739 | scratch_buffer[k] = 0; | 740 | scratch_buffer[k] = 0; |
740 | endptr = rb->iso_decode(scratch_buffer + col, utf8_buffer, | 741 | endptr = rb->iso_decode(scratch_buffer + col, utf8_buffer, |
741 | prefs.encoding, k-col); | 742 | prefs.encoding, draw_columns/glyph_width('a')); |
742 | *endptr = 0; | 743 | *endptr = 0; |
743 | } | 744 | } |
744 | } | 745 | } |
@@ -836,18 +837,26 @@ static void viewer_draw(int col) | |||
836 | if (line_width > col) { | 837 | if (line_width > col) { |
837 | str = oldstr = line_begin; | 838 | str = oldstr = line_begin; |
838 | k = col; | 839 | k = col; |
839 | while (k > draw_columns) { | 840 | while (k > 0) { |
840 | str = crop_at_width(str); | 841 | str = crop_at_width(str); |
841 | k -= draw_columns; | 842 | k-=draw_columns; |
842 | } | 843 | } |
844 | |||
845 | oldstr=line_begin=str; | ||
846 | |||
843 | width = 0; | 847 | width = 0; |
844 | while (width <= k) { | 848 | while( (width<draw_columns) && (oldstr<line_end) ) |
845 | oldstr = str; | 849 | { |
846 | str = get_ucs(str, &ch); | 850 | oldstr = get_ucs(oldstr, &ch); |
847 | width += glyph_width(ch); | 851 | width += glyph_width(ch); |
848 | } | 852 | } |
849 | endptr = rb->iso_decode(oldstr, utf8_buffer, | 853 | |
850 | prefs.encoding, line_end-oldstr); | 854 | if(prefs.view_mode==WIDE) |
855 | endptr = rb->iso_decode(line_begin, utf8_buffer, | ||
856 | prefs.encoding, oldstr-line_begin); | ||
857 | else | ||
858 | endptr = rb->iso_decode(line_begin, utf8_buffer, | ||
859 | prefs.encoding, line_end-line_begin); | ||
851 | *endptr = 0; | 860 | *endptr = 0; |
852 | } | 861 | } |
853 | } | 862 | } |