From e84b5ff78a366dd87a07cff3fb451d2ddf50daff Mon Sep 17 00:00:00 2001 From: Jinhao Date: Sun, 12 Apr 2015 23:26:27 +0800 Subject: [PATCH] code reviews --- source/gui/widgets/listbox.cpp | 22 +-- source/unicode_bidi.cpp | 295 ++++++++------------------------- 2 files changed, 76 insertions(+), 241 deletions(-) diff --git a/source/gui/widgets/listbox.cpp b/source/gui/widgets/listbox.cpp index 7d1bec1b..b7109af9 100644 --- a/source/gui/widgets/listbox.cpp +++ b/source/gui/widgets/listbox.cpp @@ -572,9 +572,9 @@ namespace nana struct category_t { - typedef std::deque container; + using container = std::deque; - nana::string text; + ::nana::string text; std::vector sorted; container items; bool expand{true}; @@ -584,14 +584,10 @@ namespace nana category_t() = default; - category_t(nana::string&& str) + category_t(nana::string str) :text(std::move(str)) {} - - category_t(const nana::string& str) - :text(str) - {} - + bool selected() const { for (auto & m : items) @@ -605,10 +601,10 @@ namespace nana class es_lister { public: - typedef std::list container; + using container = std::list; - std::function(std::size_t) > fetch_ordering_comparer; + std::function(std::size_t) > fetch_ordering_comparer; es_lister() { @@ -620,8 +616,6 @@ namespace nana { ess_ = ess; widget_ = dynamic_cast(&wd); - if(nullptr == widget_) - throw std::bad_cast(); } nana::listbox* wd_ptr() const @@ -771,7 +765,7 @@ namespace nana return &list_.back(); } - void create_cat(const std::initializer_list & args) + void create_cat(const std::initializer_list& args) { for (auto & arg : args) list_.emplace_back(arg); diff --git a/source/unicode_bidi.cpp b/source/unicode_bidi.cpp index ab90f538..5ef940ec 100644 --- a/source/unicode_bidi.cpp +++ b/source/unicode_bidi.cpp @@ -36,7 +36,6 @@ namespace nana if(ch <= 0x02D1) return L; //N = 2 if(ch <= 0x02DF) return ON; //N = 14 if(ch <= 0x02E4) return L; //N = 5 - if(ch <= 0x02ED) return ON; //N = 9 if(0x02EE == ch) return L; if(ch <= 0x02FF) return ON; //N = 17 if(ch <= 0x036F) return NSM; //N = 112 @@ -44,24 +43,14 @@ namespace nana if(ch <= 0x0375) return ON; //N = 2 if(ch <= 0x037D) return L; //N = 8 if(ch <= 0x0385) return ON; //N = 8 - if(0x0386 == ch) return L; - if(0x0387 == ch) return ON; - if(ch <= 0x03F5) return L; //N = 110 - if(0x03F6 == ch) return ON; + if(0x0387 == ch || 0x03F6 == ch) return ON; if(ch <= 0x0482) return L; //N = 140 if(ch <= 0x0489) return NSM; //N = 7 if(ch <= 0x0589) return L; //N = 256 if(0x058A == ch) return ON; if(0x058F == ch) return ET; - if(ch <= 0x05BD) return NSM; //N = 45 - if(0x05BE == ch) return R; - if(0x05BF == ch) return NSM; - if(0x05C0 == ch) return R; - if(ch <= 0x05C2) return NSM; //N = 2 - if(0x05C3 == ch) return R; - if(ch <= 0x05C5) return NSM; //N = 2 - if(0x05C6 == ch) return R; - if(0x05C7 == ch) return NSM; + if(0x05BE == ch || 0x05C0 == ch || 0x05C3 == ch || 0x05C6 == ch) return R; + if(ch <= 0x05C7) return NSM; if(ch <= 0x05F4) return R; //N = 37 if(ch <= 0x0604) return AN; //N = 5 if(ch <= 0x0607) return ON; //N = 2 @@ -70,27 +59,22 @@ namespace nana if(0x060B == ch) return AL; if(0x060C == ch) return CS; if(0x060D == ch) return AL; - if(ch <= 0x060F) return ON; //N = 2 + if(ch <= 0x060F) return ON; //N = 2 if(ch <= 0x061A) return NSM; //N = 11 - if(ch <= 0x064A) return AL; //N = 48 + if(ch <= 0x064A) return AL; //N = 48 if(ch <= 0x065F) return NSM; //N = 21 - if(ch <= 0x0669) return AN; //N = 10 - if(0x066A == ch) return ET; + if (0x066A == ch) return ET; if(ch <= 0x066C) return AN; //N = 2 - if(ch <= 0x066F) return AL; //N = 3 - if(0x0670 == ch) return NSM; + if (0x0670 == ch) return NSM; if(ch <= 0x06D5) return AL; //N = 101 - if(ch <= 0x06DC) return NSM; //N = 7 if(0x06DD == ch) return AN; if(0x06DE == ch) return ON; if(ch <= 0x06E4) return NSM; //N = 6 if(ch <= 0x06E6) return AL; //N = 2 - if(ch <= 0x06E8) return NSM; //N = 2 if(0x06E9 == ch) return ON; if(ch <= 0x06ED) return NSM; //N = 4 if(ch <= 0x06EF) return AL; //N = 2 if(ch <= 0x06F9) return EN; //N = 10 - if(ch <= 0x0710) return AL; //N = 23 if(0x0711 == ch) return NSM; if(ch <= 0x072F) return AL; //N = 30 if(ch <= 0x074A) return NSM; //N = 27 @@ -102,37 +86,24 @@ namespace nana if(ch <= 0x07F5) return R; //N = 2 if(ch <= 0x07F9) return ON; //N = 4 if(ch <= 0x0815) return R; //N = 28 - if(ch <= 0x0819) return NSM; //N = 4 - if(0x081A == ch) return R; - if(ch <= 0x0823) return NSM; //N = 9 - if(0x0824 == ch) return R; - if(ch <= 0x0827) return NSM; //N = 3 - if(0x0828 == ch) return R; + if(0x081A == ch || 0x0824 == ch || 0x0828 == ch) return R; if(ch <= 0x082D) return NSM; //N = 5 if(ch <= 0x0858) return R; //N = 41 if(ch <= 0x085B) return NSM; //N = 3 if(0x085E == ch) return R; if(ch <= 0x08AC) return AL; //N = 13 if(ch <= 0x0902) return NSM; //N = 31 - if(ch <= 0x0939) return L; //N = 55 - if(0x093A == ch) return NSM; - if(0x093B == ch) return L; - if(0x093C == ch) return NSM; + if(0x093A == ch || 0x093C == ch) return NSM; if(ch <= 0x0940) return L; //N = 4 if(ch <= 0x0948) return NSM; //N = 8 - if(ch <= 0x094C) return L; //N = 4 if(0x094D == ch) return NSM; if(ch <= 0x0950) return L; //N = 3 if(ch <= 0x0957) return NSM; //N = 7 if(ch <= 0x0961) return L; //N = 10 if(ch <= 0x0963) return NSM; //N = 2 - if(ch <= 0x097F) return L; //N = 28 - if(0x0981 == ch) return NSM; - if(ch <= 0x09B9) return L; //N = 56 - if(0x09BC == ch) return NSM; + if(0x0981 == ch || 0x09BC == ch) return NSM; if(ch <= 0x09C0) return L; //N = 4 if(ch <= 0x09C4) return NSM; //N = 4 - if(ch <= 0x09CC) return L; //N = 6 if(0x09CD == ch) return NSM; if(ch <= 0x09E1) return L; //N = 20 if(ch <= 0x09E3) return NSM; //N = 2 @@ -141,7 +112,6 @@ namespace nana if(ch <= 0x09FA) return L; //N = 7 if(0x09FB == ch) return ET; if(ch <= 0x0A02) return NSM; //N = 2 - if(ch <= 0x0A39) return L; //N = 55 if(0x0A3C == ch) return NSM; if(ch <= 0x0A40) return L; //N = 3 if(ch <= 0x0A51) return NSM; //N = 17 @@ -149,37 +119,24 @@ namespace nana if(ch <= 0x0A71) return NSM; //N = 2 if(ch <= 0x0A74) return L; //N = 3 if(ch <= 0x0A82) return NSM; //N = 14 - if(ch <= 0x0AB9) return L; //N = 55 if(0x0ABC == ch) return NSM; if(ch <= 0x0AC0) return L; //N = 4 if(ch <= 0x0AC8) return NSM; //N = 8 - if(ch <= 0x0ACC) return L; //N = 4 if(0x0ACD == ch) return NSM; if(ch <= 0x0AE1) return L; //N = 18 if(ch <= 0x0AE3) return NSM; //N = 2 - if(ch <= 0x0AF0) return L; //N = 11 if(0x0AF1 == ch) return ET; - if(0x0B01 == ch) return NSM; - if(ch <= 0x0B39) return L; //N = 56 - if(0x0B3C == ch) return NSM; - if(ch <= 0x0B3E) return L; //N = 2 - if(0x0B3F == ch) return NSM; - if(0x0B40 == ch) return L; + if(0x0B01 == ch || 0x0B3C == ch || 0x0B3F == ch) return NSM; + if(ch <= 0x0B40) return L; if(ch <= 0x0B44) return NSM; //N = 4 if(ch <= 0x0B4C) return L; //N = 6 if(ch <= 0x0B56) return NSM; //N = 10 if(ch <= 0x0B61) return L; //N = 11 if(ch <= 0x0B63) return NSM; //N = 2 - if(ch <= 0x0B77) return L; //N = 18 - if(0x0B82 == ch) return NSM; - if(ch <= 0x0BBF) return L; //N = 61 - if(0x0BC0 == ch) return NSM; - if(ch <= 0x0BCC) return L; //N = 12 - if(0x0BCD == ch) return NSM; + if(0x0B82 == ch || 0x0BC0 == ch || 0x0BCD == ch) return NSM; if(ch <= 0x0BF2) return L; //N = 35 - if(ch <= 0x0BF8) return ON; //N = 6 if(0x0BF9 == ch) return ET; - if(0x0BFA == ch) return ON; + if(ch <= 0x0BFA) return ON; if(ch <= 0x0C3D) return L; //N = 61 if(ch <= 0x0C40) return NSM; //N = 3 if(ch <= 0x0C44) return L; //N = 4 @@ -188,7 +145,6 @@ namespace nana if(ch <= 0x0C63) return NSM; //N = 2 if(ch <= 0x0C6F) return L; //N = 10 if(ch <= 0x0C7E) return ON; //N = 7 - if(ch <= 0x0CB9) return L; //N = 59 if(0x0CBC == ch) return NSM; if(ch <= 0x0CCB) return L; //N = 15 if(ch <= 0x0CCD) return NSM; //N = 2 @@ -196,22 +152,18 @@ namespace nana if(ch <= 0x0CE3) return NSM; //N = 2 if(ch <= 0x0D40) return L; //N = 91 if(ch <= 0x0D44) return NSM; //N = 4 - if(ch <= 0x0D4C) return L; //N = 7 if(0x0D4D == ch) return NSM; if(ch <= 0x0D61) return L; //N = 20 if(ch <= 0x0D63) return NSM; //N = 2 - if(ch <= 0x0DC6) return L; //N = 97 if(0x0DCA == ch) return NSM; if(ch <= 0x0DD1) return L; //N = 3 if(ch <= 0x0DD6) return NSM; //N = 5 - if(ch <= 0x0E30) return L; //N = 89 if(0x0E31 == ch) return NSM; if(ch <= 0x0E33) return L; //N = 2 if(ch <= 0x0E3A) return NSM; //N = 7 if(0x0E3F == ch) return ET; if(ch <= 0x0E46) return L; //N = 7 if(ch <= 0x0E4E) return NSM; //N = 8 - if(ch <= 0x0EB0) return L; //N = 98 if(0x0EB1 == ch) return NSM; if(ch <= 0x0EB3) return L; //N = 2 if(ch <= 0x0EBC) return NSM; //N = 9 @@ -223,10 +175,7 @@ namespace nana if(ch <= 0x0F39) return (ch & 1 ? NSM : L); if(ch <= 0x0F3D) return ON; //N = 4 if(ch <= 0x0F6C) return L; //N = 47 - if(ch <= 0x0F7E) return NSM; //N = 14 - if(0x0F7F == ch) return L; - if(ch <= 0x0F84) return NSM; //N = 5 - if(0x0F85 == ch) return L; + if(0x0F7F == ch || 0x0F85 == ch) return L; if(ch <= 0x0F87) return NSM; //N = 2 if(ch <= 0x0F8C) return L; //N = 5 if(ch <= 0x0FBC) return NSM; //N = 48 @@ -237,10 +186,7 @@ namespace nana if(ch <= 0x1FFE) { if(ch <= 0x102C) return L; //N = 102 - if(ch <= 0x1030) return NSM; //N = 4 - if(0x1031 == ch) return L; - if(ch <= 0x1037) return NSM; //N = 6 - if(0x1038 == ch) return L; + if(0x1031 == ch || 0x1038 == ch) return L; if(ch <= 0x103A) return NSM; //N = 2 if(ch <= 0x103C) return L; //N = 2 if(ch <= 0x103E) return NSM; //N = 2 @@ -250,21 +196,15 @@ namespace nana if(ch <= 0x1060) return NSM; //N = 3 if(ch <= 0x1070) return L; //N = 16 if(ch <= 0x1074) return NSM; //N = 4 - if(ch <= 0x1081) return L; //N = 13 if(0x1082 == ch) return NSM; if(ch <= 0x1084) return L; //N = 2 if(ch <= 0x1086) return NSM; //N = 2 - if(ch <= 0x108C) return L; //N = 6 - if(0x108D == ch) return NSM; - if(ch <= 0x109C) return L; //N = 15 - if(0x109D == ch) return NSM; + if(0x108D == ch || 0x109D == ch) return NSM; if(ch <= 0x135A) return L; //N = 701 if(ch <= 0x135F) return NSM; //N = 3 if(ch <= 0x138F) return L; //N = 48 if(ch <= 0x1399) return ON; //N = 10 - if(ch <= 0x13F4) return L; //N = 85 if(0x1400 == ch) return ON; - if(ch <= 0x167F) return L; //N = 639 if(0x1680 == ch) return WS; if(ch <= 0x169A) return L; //N = 26 if(ch <= 0x169C) return ON; //N = 2 @@ -277,28 +217,22 @@ namespace nana if(ch <= 0x1770) return L; //N = 17 if(ch <= 0x1773) return NSM; //N = 2 if(ch <= 0x17B3) return L; //N = 52 - if(ch <= 0x17B5) return NSM; //N = 2 if(0x17B6 == ch) return L; if(ch <= 0x17BD) return NSM; //N = 7 - if(ch <= 0x17C5) return L; //N = 8 if(0x17C6 == ch) return NSM; if(ch <= 0x17C8) return L; //N = 2 if(ch <= 0x17D3) return NSM; //N = 11 - if(ch <= 0x17DA) return L; //N = 7 if(0x17DB == ch) return ET; - if(0x17DC == ch) return L; if(0x17DD == ch) return NSM; if(ch <= 0x17E9) return L; //N = 10 if(ch <= 0x180A) return ON; //N = 27 if(ch <= 0x180D) return NSM; //N = 3 if(0x180E == ch) return WS; - if(ch <= 0x18A8) return L; //N = 153 if(0x18A9 == ch) return NSM; if(ch <= 0x191C) return L; //N = 115 if(ch <= 0x1922) return NSM; //N = 3 if(ch <= 0x1926) return L; //N = 4 if(ch <= 0x1928) return NSM; //N = 2 - if(ch <= 0x1931) return L; //N = 9 if(0x1932 == ch) return NSM; if(ch <= 0x1938) return L; //N = 6 if(ch <= 0x193B) return NSM; //N = 3 @@ -308,10 +242,8 @@ namespace nana if(ch <= 0x1A16) return L; //N = 23 if(ch <= 0x1A18) return NSM; //N = 2 if(ch <= 0x1A55) return L; //N = 61 - if(0x1A56 == ch) return NSM; - if(0x1A57 == ch) return L; + if(0x1A57 == ch) return L; if(ch <= 0x1A60) return NSM; //N = 9 - if(0x1A61 == ch) return L; if(0x1A62 == ch) return NSM; if(ch <= 0x1A64) return L; //N = 2 if(ch <= 0x1A6C) return NSM; //N = 8 @@ -320,12 +252,8 @@ namespace nana if(ch <= 0x1AAD) return L; //N = 46 if(ch <= 0x1B03) return NSM; //N = 4 if(ch <= 0x1B33) return L; //N = 48 - if(0x1B34 == ch) return NSM; - if(0x1B35 == ch) return L; - if(ch <= 0x1B3A) return NSM; //N = 5 - if(0x1B3B == ch) return L; - if(0x1B3C == ch) return NSM; - if(ch <= 0x1B41) return L; //N = 5 + if(0x1B35 == ch || 0x1B3B == ch) return L; + if(ch <= 0x1B3C) return NSM; if(0x1B42 == ch) return NSM; if(ch <= 0x1B6A) return L; //N = 40 if(ch <= 0x1B73) return NSM; //N = 9 @@ -335,14 +263,10 @@ namespace nana if(ch <= 0x1BA5) return NSM; //N = 4 if(ch <= 0x1BA7) return L; //N = 2 if(ch <= 0x1BA9) return NSM; //N = 2 - if(0x1BAA == ch) return L; - if(0x1BAB == ch) return NSM; - if(ch <= 0x1BE5) return L; //N = 58 - if(0x1BE6 == ch) return NSM; - if(0x1BE7 == ch) return L; + if(0x1BAB == ch || 0x1BE6 == ch) return NSM; + if(ch <= 0x1BE7) return L; if(ch <= 0x1BE9) return NSM; //N = 2 if(ch <= 0x1BEC) return L; //N = 3 - if(0x1BED == ch) return NSM; if(0x1BEE == ch) return L; if(ch <= 0x1BF1) return NSM; //N = 3 if(ch <= 0x1C2B) return L; //N = 58 @@ -350,19 +274,13 @@ namespace nana if(ch <= 0x1C35) return L; //N = 2 if(ch <= 0x1C37) return NSM; //N = 2 if(ch <= 0x1CC7) return L; //N = 141 - if(ch <= 0x1CD2) return NSM; //N = 3 - if(0x1CD3 == ch) return L; - if(ch <= 0x1CE0) return NSM; //N = 13 - if(0x1CE1 == ch) return L; + if(0x1CD3 == ch || 0x1CE1 == ch) return L; if(ch <= 0x1CE8) return NSM; //N = 7 - if(ch <= 0x1CEC) return L; //N = 4 if(0x1CED == ch) return NSM; - if(ch <= 0x1CF3) return L; //N = 6 if(0x1CF4 == ch) return NSM; if(ch <= 0x1DBF) return L; //N = 203 if(ch <= 0x1DFF) return NSM; //N = 64 if(ch <= 0x1FBC) return L; //N = 445 - if(0x1FBD == ch) return ON; if(0x1FBE == ch) return L; if(ch <= 0x1FC1) return ON; //N = 3 if(ch <= 0x1FCC) return L; //N = 11 @@ -405,19 +323,15 @@ namespace nana if(ch <= 0x209C) return L; //N = 13 if(ch <= 0x20B9) return ET; //N = 26 if(ch <= 0x20F0) return NSM; //N = 33 - if(ch <= 0x2101) return ON; //N = 2 if(0x2102 == ch) return L; - if(ch <= 0x2106) return ON; //N = 4 if(0x2107 == ch) return L; if(ch <= 0x2109) return ON; //N = 2 if(ch <= 0x2113) return L; //N = 10 - if(0x2114 == ch) return ON; if(0x2115 == ch) return L; if(ch <= 0x2118) return ON; //N = 3 if(ch <= 0x211D) return L; //N = 5 if(ch <= 0x2123) return ON; //N = 6 if(ch <= 0x2129) return (ch & 1 ? ON : L); - if(ch <= 0x212D) return L; //N = 4 if(0x212E == ch) return ET; if(ch <= 0x2139) return L; //N = 11 if(ch <= 0x213B) return ON; //N = 2 @@ -433,12 +347,10 @@ namespace nana if(0x2213 == ch) return ET; if(ch <= 0x2335) return ON; //N = 290 if(ch <= 0x237A) return L; //N = 69 - if(ch <= 0x2394) return ON; //N = 26 if(0x2395 == ch) return L; if(ch <= 0x2487) return ON; //N = 242 if(ch <= 0x249B) return EN; //N = 20 if(ch <= 0x24E9) return L; //N = 78 - if(ch <= 0x26AB) return ON; //N = 450 if(0x26AC == ch) return L; if(ch <= 0x27FF) return ON; //N = 339 if(ch <= 0x28FF) return L; //N = 256 @@ -449,18 +361,15 @@ namespace nana if(ch <= 0x2CF1) return NSM; //N = 3 if(ch <= 0x2CF3) return L; //N = 2 if(ch <= 0x2CFF) return ON; //N = 7 - if(ch <= 0x2D70) return L; //N = 113 if(0x2D7F == ch) return NSM; if(ch <= 0x2DDE) return L; //N = 95 if(ch <= 0x2DFF) return NSM; //N = 32 - if(ch <= 0x2FFB) return ON; //N = 508 if(0x3000 == ch) return WS; if(ch <= 0x3004) return ON; //N = 4 if(ch <= 0x3007) return L; //N = 3 if(ch <= 0x3020) return ON; //N = 25 if(ch <= 0x3029) return L; //N = 9 if(ch <= 0x302D) return NSM; //N = 4 - if(ch <= 0x302F) return L; //N = 2 if(0x3030 == ch) return ON; if(ch <= 0x3035) return L; //N = 5 if(ch <= 0x3037) return ON; //N = 2 @@ -469,9 +378,7 @@ namespace nana if(ch <= 0x3096) return L; //N = 86 if(ch <= 0x309A) return NSM; //N = 2 if(ch <= 0x309C) return ON; //N = 2 - if(ch <= 0x309F) return L; //N = 3 if(0x30A0 == ch) return ON; - if(ch <= 0x30FA) return L; //N = 90 if(0x30FB == ch) return ON; if(ch <= 0x31BA) return L; //N = 191 if(ch <= 0x31E3) return ON; //N = 36 @@ -489,7 +396,6 @@ namespace nana if(ch <= 0x337A) return ON; //N = 4 if(ch <= 0x33DD) return L; //N = 99 if(ch <= 0x33DF) return ON; //N = 2 - if(ch <= 0x33FE) return L; //N = 31 if(0x33FF == ch) return ON; if(ch <= 0x4DB5) return L; //N = 6582 if(ch <= 0x4DFF) return ON; //N = 64 @@ -498,23 +404,17 @@ namespace nana if(ch <= 0xA60C) return L; //N = 317 if(ch <= 0xA60F) return ON; //N = 3 if(ch <= 0xA66E) return L; //N = 95 - if(ch <= 0xA672) return NSM; //N = 4 if(0xA673 == ch) return ON; if(ch <= 0xA67D) return NSM; //N = 10 if(ch <= 0xA67F) return ON; //N = 2 - if(ch <= 0xA697) return L; //N = 24 if(0xA69F == ch) return NSM; if(ch <= 0xA6EF) return L; //N = 80 if(ch <= 0xA6F1) return NSM; //N = 2 if(ch <= 0xA6F7) return L; //N = 6 if(ch <= 0xA721) return ON; //N = 34 - if(ch <= 0xA787) return L; //N = 102 if(0xA788 == ch) return ON; - if(ch <= 0xA801) return L; //N = 121 if(0xA802 == ch) return NSM; - if(ch <= 0xA805) return L; //N = 3 if(0xA806 == ch) return NSM; - if(ch <= 0xA80A) return L; //N = 4 if(0xA80B == ch) return NSM; if(ch <= 0xA824) return L; //N = 25 if(ch <= 0xA826) return NSM; //N = 2 @@ -524,7 +424,6 @@ namespace nana if(ch <= 0xA839) return ET; //N = 2 if(ch <= 0xA873) return L; //N = 52 if(ch <= 0xA877) return ON; //N = 4 - if(ch <= 0xA8C3) return L; //N = 68 if(0xA8C4 == ch) return NSM; if(ch <= 0xA8D9) return L; //N = 12 if(ch <= 0xA8F1) return NSM; //N = 18 @@ -534,11 +433,9 @@ namespace nana if(ch <= 0xA951) return NSM; //N = 11 if(ch <= 0xA97C) return L; //N = 43 if(ch <= 0xA982) return NSM; //N = 3 - if(ch <= 0xA9B2) return L; //N = 48 if(0xA9B3 == ch) return NSM; if(ch <= 0xA9B5) return L; //N = 2 if(ch <= 0xA9B9) return NSM; //N = 4 - if(ch <= 0xA9BB) return L; //N = 2 if(0xA9BC == ch) return NSM; if(ch <= 0xAA28) return L; //N = 108 if(ch <= 0xAA2E) return NSM; //N = 6 @@ -546,34 +443,24 @@ namespace nana if(ch <= 0xAA32) return NSM; //N = 2 if(ch <= 0xAA34) return L; //N = 2 if(ch <= 0xAA36) return NSM; //N = 2 - if(ch <= 0xAA42) return L; //N = 3 if(0xAA43 == ch) return NSM; - if(ch <= 0xAA4B) return L; //N = 8 if(0xAA4C == ch) return NSM; - if(ch <= 0xAAAF) return L; //N = 99 if(0xAAB0 == ch) return NSM; - if(0xAAB1 == ch) return L; + if(ch <= 0xAAB1) return L; if(ch <= 0xAAB4) return NSM; //N = 3 if(ch <= 0xAAB6) return L; //N = 2 if(ch <= 0xAAB8) return NSM; //N = 2 if(ch <= 0xAABD) return L; //N = 5 if(ch <= 0xAABF) return NSM; //N = 2 - if(0xAAC0 == ch) return L; if(0xAAC1 == ch) return NSM; if(ch <= 0xAAEB) return L; //N = 42 if(ch <= 0xAAED) return NSM; //N = 2 - if(ch <= 0xAAF5) return L; //N = 8 if(0xAAF6 == ch) return NSM; - if(ch <= 0xABE4) return L; //N = 228 if(0xABE5 == ch) return NSM; - if(ch <= 0xABE7) return L; //N = 2 if(0xABE8 == ch) return NSM; - if(ch <= 0xABEC) return L; //N = 4 if(0xABED == ch) return NSM; if(ch <= 0xFB17) return L; //N = 20264 - if(0xFB1D == ch) return R; if(0xFB1E == ch) return NSM; - if(ch <= 0xFB28) return R; //N = 10 if(0xFB29 == ch) return ES; if(ch <= 0xFB4F) return R; //N = 38 if(ch <= 0xFD3D) return AL; //N = 494 @@ -585,9 +472,7 @@ namespace nana if(ch <= 0xFE26) return NSM; //N = 7 if(ch <= 0xFE4F) return ON; //N = 32 if(ch <= 0xFE52) return (ch & 1 ? ON : CS); - if(0xFE54 == ch) return ON; if(0xFE55 == ch) return CS; - if(ch <= 0xFE5E) return ON; //N = 9 if(0xFE5F == ch) return ET; if(ch <= 0xFE61) return ON; //N = 2 if(ch <= 0xFE63) return ES; //N = 2 @@ -616,14 +501,13 @@ namespace nana return ON; } - } //class unicode_bidi void unicode_bidi::linestr(const char_type* str, std::size_t len, std::vector & reordered) { levels_.clear(); - const char_type * end = str + len; + const char_type * const end = str + len; std::vector stack; @@ -632,84 +516,62 @@ namespace nana //First character type bidi_char begin_char_type; - const char_type * begin_character = 0; + const char_type * begin_character = nullptr; for(const char_type * c = str; c < end; ++c) { - switch(*c) + if (PDF == *c) { - case LRE: - stack.push_back(cur); - if(begin_character) + if (cur.level) { - _m_push_entity(begin_character, c, cur.level, begin_char_type); - begin_character = 0; - } - - cur.directional_override = directional_override_status::neutral; - if(cur.level & 1) - ++cur.level; - else - cur.level += 2; - continue; - case RLE: - stack.push_back(cur); - if(begin_character) - { - _m_push_entity(begin_character, c, cur.level, begin_char_type); - begin_character = 0; - } - - cur.directional_override = directional_override_status::neutral; - if(cur.level & 1) - cur.level += 2; - else - ++cur.level; - continue; - case PDF: - if(cur.level) - { - if(begin_character) + if (begin_character) { _m_push_entity(begin_character, c, cur.level, begin_char_type); - begin_character = 0; + begin_character = nullptr; } cur = stack.back(); stack.pop_back(); } continue; - case LRO: + } + else if (LRE <= *c && *c <= RLO) + { stack.push_back(cur); - if(begin_character) + if (begin_character) { _m_push_entity(begin_character, c, cur.level, begin_char_type); - begin_character = 0; + begin_character = nullptr; } - cur.directional_override = directional_override_status::left_to_right; - if(cur.level & 1) - ++cur.level; - else - cur.level += 2; - continue; - case RLO: - stack.push_back(cur); - if(begin_character) + + switch (*c) { - _m_push_entity(begin_character, c, cur.level, begin_char_type); - begin_character = 0; + case LRE: + cur.directional_override = directional_override_status::neutral; + cur.level += 2 - (cur.level & 1); + break; + case RLE: + cur.directional_override = directional_override_status::neutral; + cur.level += (cur.level & 1) + 1; + break; + case LRO: + cur.directional_override = directional_override_status::left_to_right; + cur.level += 2 - (cur.level & 1); + break; + case RLO: + cur.directional_override = directional_override_status::right_to_left; + cur.level = (cur.level & 1) + 1; + break; } - cur.directional_override = directional_override_status::right_to_left; - cur.level = (cur.level & 1) + 1; continue; } bidi_char type = _m_char_dir(*c); - if(0 == begin_character) + if (nullptr == begin_character) { begin_character = c; begin_char_type = type; } - else if(begin_char_type != type) + else if (begin_char_type != type) { _m_push_entity(begin_character, c, cur.level, begin_char_type); begin_char_type = type; @@ -762,15 +624,16 @@ namespace nana { const auto end = levels_.end(); unsigned level = i->level; - for(; i != end; ++i) + for (; i != end; ++i) { - if(i->level != level) + if (i->level != level) return i->bidi_char_type; } i = _m_search_first_character(); if(i != end) return (i->level & 1 ? bidi_char::R : bidi_char::L); + return bidi_char::L; } @@ -840,44 +703,25 @@ namespace nana switch(i->bidi_char_type) { case bidi_char::ES: + i->bidi_char_type = bidi_char::ON; //W6 if((false == head) && (i != last)) { - if(bidi_char::EN == (i - 1)->bidi_char_type && bidi_char::EN == (i + 1)->bidi_char_type) + if((bidi_char::EN == (i - 1)->bidi_char_type) && (bidi_char::EN == (i + 1)->bidi_char_type)) i->bidi_char_type = bidi_char::EN; - else - i->bidi_char_type = bidi_char::ON; //W6 } else - { head = false; - i->bidi_char_type = bidi_char::ON; //W6 - } break; case bidi_char::CS: + i->bidi_char_type = bidi_char::ON; //W6 if((false == head) && (i != last)) { - if((i-1)->bidi_char_type == (i + 1)->bidi_char_type) - { - switch((i + 1)->bidi_char_type) - { - case bidi_char::EN: - i->bidi_char_type = bidi_char::EN; - break; - case bidi_char::AN: - i->bidi_char_type = bidi_char::AN; - break; - default: - i->bidi_char_type = bidi_char::ON; //W6 - } - } - else - i->bidi_char_type = bidi_char::ON; //W6 + auto right_one = (i + 1)->bidi_char_type; + if(((i-1)->bidi_char_type == right_one) && (bidi_char::AN == right_one || bidi_char::EN == right_one)) + i->bidi_char_type = right_one; } else - { head = false; - i->bidi_char_type = bidi_char::ON; //W6 - } break; case bidi_char::ET: if((false == head) && (bidi_char::EN == (i-1)->bidi_char_type)) @@ -960,6 +804,7 @@ namespace nana bool head_of_run = true; auto begin_neutral = end; + //N1. A sequence of neutrals takes the direction of the surrounding strong text if the text on both sides has the same direction. //European and Arabic numbers act as if they were R in terms of their influence on neutrals. //Start-of-level-run (sor) and end-of-level-run (eor) are used at level run boundaries. @@ -1024,8 +869,7 @@ namespace nana switch(i.bidi_char_type) { case bidi_char::L: - if(i.level & 1) - ++(i.level); + i.level += (i.level & 1); break; case bidi_char::R: if(0 == (i.level & 1)) @@ -1033,10 +877,7 @@ namespace nana break; case bidi_char::EN: case bidi_char::AN: - if(i.level & 1) - ++(i.level); - else - i.level += 2; + i.level += 2 - (i.level & 1); break; default: break; @@ -1085,7 +926,7 @@ namespace nana unicode_bidi::bidi_char unicode_bidi::_m_char_dir(char_type ch) { - bidi_charmap::t type = bidi_charmap::bidi_char_type(ch); + auto type = bidi_charmap::bidi_char_type(ch); if (type < bidi_charmap::PDF) return static_cast(type); if (type < bidi_charmap::B)