diff options
Diffstat (limited to 'apps/plugins/lib')
-rw-r--r-- | apps/plugins/lib/simple_viewer.c | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/apps/plugins/lib/simple_viewer.c b/apps/plugins/lib/simple_viewer.c index 13fdc32c2f..09144b645b 100644 --- a/apps/plugins/lib/simple_viewer.c +++ b/apps/plugins/lib/simple_viewer.c | |||
@@ -39,6 +39,22 @@ struct view_info { | |||
39 | int start; /* possition of first line in text */ | 39 | int start; /* possition of first line in text */ |
40 | }; | 40 | }; |
41 | 41 | ||
42 | static bool isbrchr(const unsigned char *str, int len) | ||
43 | { | ||
44 | const unsigned char *p = "!,-.:;? 、。!,.:;?―"; | ||
45 | if (isspace(*str)) | ||
46 | return true; | ||
47 | |||
48 | while(*p) | ||
49 | { | ||
50 | int n = rb->utf8seek(p, 1); | ||
51 | if (len == n && !rb->strncmp(p, str, len)) | ||
52 | return true; | ||
53 | p += n; | ||
54 | } | ||
55 | return false; | ||
56 | } | ||
57 | |||
42 | static const char* get_next_line(const char *text, struct view_info *info) | 58 | static const char* get_next_line(const char *text, struct view_info *info) |
43 | { | 59 | { |
44 | const char *ptr = text; | 60 | const char *ptr = text; |
@@ -53,10 +69,13 @@ static const char* get_next_line(const char *text, struct view_info *info) | |||
53 | #else | 69 | #else |
54 | unsigned short ch; | 70 | unsigned short ch; |
55 | n = ((long)rb->utf8decode(ptr, &ch) - (long)ptr); | 71 | n = ((long)rb->utf8decode(ptr, &ch) - (long)ptr); |
56 | w = rb->font_get_width(info->pf, ch); | 72 | if (rb->is_diacritic(ch, NULL)) |
73 | w = 0; | ||
74 | else | ||
75 | w = rb->font_get_width(info->pf, ch); | ||
57 | #endif | 76 | #endif |
58 | if (isspace(*ptr)) | 77 | if (isbrchr(ptr, n)) |
59 | space = ptr+n; | 78 | space = ptr+(isspace(*ptr) || total + w <= info->vp.width? n: 0); |
60 | if (*ptr == '\n') | 79 | if (*ptr == '\n') |
61 | { | 80 | { |
62 | ptr += n; | 81 | ptr += n; |