diff --git a/uppsrc/Core/App.cpp b/uppsrc/Core/App.cpp index 6d37a697b..468ab0a0f 100644 --- a/uppsrc/Core/App.cpp +++ b/uppsrc/Core/App.cpp @@ -173,11 +173,25 @@ String ConfigFile() { return ConfigFile(GetExeTitle() + ".cfg"); } -GLOBAL_VAR(Vector, coreCmdLine__) +GLOBAL_VAR(Vector, coreCmdLine__) const Vector& CommandLine() { - return coreCmdLine__(); + Vector *ptr; + INTERLOCKED { + static ArrayMap< byte, Vector > charset_cmd; + byte cs = GetDefaultCharset(); + int f = charset_cmd.Find(cs); + if(f >= 0) + ptr = &charset_cmd[f]; + else { + ptr = &charset_cmd.Add(cs); + const Vector& src = coreCmdLine__(); + for(int i = 0; i < src.GetCount(); i++) + ptr->Add(src[i].ToString()); + } + } + return *ptr; } VectorMap& EnvMap() @@ -188,16 +202,18 @@ VectorMap& EnvMap() const VectorMap& Environment() { - static VectorMap *ptr = NULL; + VectorMap *ptr; INTERLOCKED { - static VectorMap env; - static int echrset; - if(!ptr || GetDefaultCharset() != echrset) { - env.Clear(); - echrset = GetDefaultCharset(); - for(int i = 0; i < EnvMap().GetCount(); i++) - env.Add(EnvMap().GetKey(i).ToString(), EnvMap()[i].ToString()); - ptr = &env; + static ArrayMap< byte, VectorMap > charset_env; + byte cs = GetDefaultCharset(); + int f = charset_env.Find(cs); + if(f >= 0) + ptr = &charset_env[f]; + else { + ptr = &charset_env.Add(cs); + const VectorMap& env_map = EnvMap(); + for(int i = 0; i < env_map.GetCount(); i++) + ptr->Add(env_map.GetKey(i).ToString(), env_map[i].ToString()); } } return *ptr; @@ -231,9 +247,12 @@ void CommonInit() LoadLangFiles(GetHomeDirectory()); #endif - Vector& cmd = coreCmdLine__(); + Vector& cmd = coreCmdLine__(); + static WString exp_cmd = "--export-tr"; + static WString brk_cmd = "--memory-breakpoint__"; + for(int i = 0; i < cmd.GetCount();) { - if(cmd[i] == "--export-tr") { + if(cmd[i] == exp_cmd) { { i++; int lang = 0; @@ -243,8 +262,8 @@ void CommonInit() if(cmd[i].GetLength() != 4 && cmd[i].GetLength() != 5) lang = 0; else { - lang = LNGFromText(cmd[i]); - fn = cmd[i]; + lang = LNGFromText(cmd[i].ToString()); + fn = cmd[i].ToString(); int c = cmd[i][4]; if(c >= '0' && c <= '8') charset = c - '0' + CHARSET_WIN1250; @@ -268,8 +287,8 @@ void CommonInit() exit(0); } #if defined(_DEBUG) && defined(UPP_HEAP) - if(cmd[i] == "--memory-breakpoint__" && i + 1 < cmd.GetCount()) { - MemoryBreakpoint(atoi(cmd[i + 1])); + if(cmd[i] == brk_cmd && i + 1 < cmd.GetCount()) { + MemoryBreakpoint(atoi(cmd[i + 1].ToString())); cmd.Remove(i, 2); } else @@ -312,9 +331,9 @@ void AppInit__(int argc, const char **argv, const char **envptr) var++; EnvMap().Add(varname.ToWString(), String(var).ToWString()); } - Vector& cmd = coreCmdLine__(); + Vector& cmd = coreCmdLine__(); for(int i = 1; i < argc; i++) - cmd.Add(argv[i]); + cmd.Add(FromSystemCharset(argv[i])); CommonInit(); signal(SIGILL, s_ill_handler); signal(SIGSEGV, s_segv_handler); @@ -352,7 +371,7 @@ void AppInitEnvironment__() void AppInit__(int argc, const char **argv) { SetLanguage(LNG_ENGLISH); - Vector& cmd = coreCmdLine__(); + Vector& cmd = coreCmdLine__(); for(int i = 1; i < argc; i++) cmd.Add(argv[i]); AppInitEnvironment__(); diff --git a/uppsrc/CtrlCore/CtrlCore.h b/uppsrc/CtrlCore/CtrlCore.h index 8723b65c0..443b65970 100644 --- a/uppsrc/CtrlCore/CtrlCore.h +++ b/uppsrc/CtrlCore/CtrlCore.h @@ -1744,8 +1744,8 @@ RichText ParseRTF(const char *rtf); #ifdef PLATFORM_WIN32 -Vector& coreCmdLine__(); -Vector SplitCmdLine__(const char *cmd); +Vector& coreCmdLine__(); +Vector SplitCmdLine__(const char *cmd); #ifdef PLATFORM_WINCE diff --git a/uppsrc/CtrlCore/Win32Wnd.cpp b/uppsrc/CtrlCore/Win32Wnd.cpp index 724529e1b..4408ad0f7 100644 --- a/uppsrc/CtrlCore/Win32Wnd.cpp +++ b/uppsrc/CtrlCore/Win32Wnd.cpp @@ -1251,25 +1251,23 @@ ViewDraw::~ViewDraw() LeaveGuiMutex(); } -Vector SplitCmdLine__(const char *cmd) +Vector SplitCmdLine__(const char *cmd) { - Vector out; + Vector out; while(*cmd) if((byte)*cmd <= ' ') cmd++; - else if(*cmd == '\"') - { - String quoted; + else if(*cmd == '\"') { + WString quoted; while(*++cmd && (*cmd != '\"' || *++cmd == '\"')) - quoted.Cat(*cmd); + quoted.Cat(FromSystemCharset(String(cmd, 1)).ToWString()); out.Add(quoted); } - else - { + else { const char *begin = cmd; while((byte)*cmd > ' ') cmd++; - out.Add(String(begin, cmd)); + out.Add(String(begin, cmd).ToWString()); } return out; } diff --git a/uppsrc/CtrlLib/TreeCtrl.cpp b/uppsrc/CtrlLib/TreeCtrl.cpp index 3a2c18c74..bc7926d44 100644 --- a/uppsrc/CtrlLib/TreeCtrl.cpp +++ b/uppsrc/CtrlLib/TreeCtrl.cpp @@ -836,19 +836,21 @@ void TreeCtrl::SyncInfo() Size sz = GetSize(); Point p = GetMouseViewPos(); Point org = sb; - if(p.y + org.y > sb.GetTotal().cy) - return; +// if(p.y + org.y > sb.GetTotal().cy) +// return; int i = FindLine(p.y + org.y); - const Line& l = line[i]; - const Item& m = item[l.itemi]; - int x = levelcx + l.level * levelcx - org.x + m.image.GetSize().cx; - Rect r = RectC(x, l.y - org.y, sz.cx - x, m.GetSize(display).cy); - if(r.Contains(p)) { - Color fg, bg; - dword st; - const Display *d = GetStyle(i, fg, bg, st); - info.Set(this, r, m.value, d, fg, bg, st, m.margin); - return; + if(i < line.GetCount()) { + const Line& l = line[i]; + const Item& m = item[l.itemi]; + int x = levelcx + l.level * levelcx - org.x + m.image.GetSize().cx; + Rect r = RectC(x, l.y - org.y, sz.cx - x, m.GetSize(display).cy); + if(r.Contains(p)) { + Color fg, bg; + dword st; + const Display *d = GetStyle(i, fg, bg, st); + info.Set(this, r, m.value, d, fg, bg, st, m.margin); + return; + } } } info.Cancel(); diff --git a/uppsrc/Geom/Draw/plotter.cpp b/uppsrc/Geom/Draw/plotter.cpp index cf5072b68..924b2b574 100644 --- a/uppsrc/Geom/Draw/plotter.cpp +++ b/uppsrc/Geom/Draw/plotter.cpp @@ -618,7 +618,8 @@ void Plotter::Set(Draw& _draw, const Matrixf& _transform, const Rect& _clip, dou { physical = _transform; logical = MatrixfInverse(_transform); - measure = fabs(MatrixfMeasure(physical)); + signed_measure = MatrixfMeasure(physical); + measure = fabs(signed_measure); logprec = 1.0 / measure; ortho = (physical.x.y == 0 && physical.y.x == 0); ltop = (ortho ? &Plotter::LtoPOrtho : &Plotter::LtoPFull); @@ -1210,7 +1211,8 @@ bool PathTool::ArcToRaw(Pointf pt, double bulge) return true; } Pointf pt_phys = plotter.LtoP(pt); - pathdraw.Arc(PointfToPoint(last_phys), PointfToPoint(pt_phys), fround(bulge * fabs(plotter.measure))); + pathdraw.Arc(PointfToPoint(last_phys), PointfToPoint(pt_phys), + fround(bulge * plotter.signed_measure)); last_point = pt; last_phys = pt_phys; return true; diff --git a/uppsrc/Geom/Draw/plotter.h b/uppsrc/Geom/Draw/plotter.h index 6d15678d8..0b9d13e31 100644 --- a/uppsrc/Geom/Draw/plotter.h +++ b/uppsrc/Geom/Draw/plotter.h @@ -179,6 +179,7 @@ public: Rect clip; double logdiag; double logprec; + double signed_measure; double measure; double physical_scale; bool ortho;