CtrlCore: Fixed workares issue in X11/GTK, various cosmetics

git-svn-id: svn://ultimatepp.org/upp/trunk@7336 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2014-04-28 16:55:48 +00:00
parent f59fe47620
commit e2b5d44cc8
32 changed files with 87 additions and 56 deletions

View file

@ -323,11 +323,12 @@ void CodeEditor::IndentEnter(int count) {
const wchar *s = pl;
while(*s == '\t' || *s == ' ')
InsertChar(*s++, 1);
if(st.stmtline == cl || st.blk.GetCount() && st.blk.Top() == cl)
if(st.stmtline == cl || st.blk.GetCount() && st.blk.Top() == cl) {
if(indent_spaces || (s > pl && s[-1] == ' '))
InsertChar(' ', indent_amount);
else
InsertChar('\t', 1);
}
}
}
@ -512,7 +513,7 @@ void CodeEditor::MoveNextBrk(bool sel) {
void CodeEditor::MovePrevBrk(bool sel) {
int p = GetCursor();
if(p < 2) return;
if(!isrbrkt(GetChar(p - 1)))
if(!isrbrkt(GetChar(p - 1))) {
if(p < GetLength() - 1 && isrbrkt(GetChar(p)))
p++;
else {
@ -520,6 +521,7 @@ void CodeEditor::MovePrevBrk(bool sel) {
PlaceCaret(p, sel);
return;
}
}
int lvl = 1;
p -= 2;
for(;;) {

View file

@ -160,7 +160,7 @@ bool CodeEditor::FindFrom(int pos, bool back, const wchar *text, bool wholeword,
ft.Cat(c);
}
else
if(c >= ' ')
if(c >= ' ') {
if(wildcards)
ft.Cat(c == '*' ? WILDANY :
c == '?' ? WILDONE :
@ -171,6 +171,7 @@ bool CodeEditor::FindFrom(int pos, bool back, const wchar *text, bool wholeword,
);
else
ft.Cat(c);
}
}
bool wb = wholeword ? iscidl(*ft) : false;
bool we = wholeword ? iscidl(*ft.Last()) : false;

View file

@ -161,8 +161,8 @@ void CodeEditor::SyntaxState::ScanSyntax(const wchar *ln, const wchar *e, int ta
break;
case 4:
if(id[0] == 'e' && id[1] == 'l')
if(id[2] == 'i' && id[3] == 'f')
if(id[0] == 'e' && id[1] == 'l') {
if(id[2] == 'i' && id[3] == 'f') {
if(ifstack.GetCount() == 0) {
IfState& ifstate = ifstack.Add();
ifstate.ifline = 0;
@ -177,8 +177,9 @@ void CodeEditor::SyntaxState::ScanSyntax(const wchar *ln, const wchar *e, int ta
else
ifstate.state = IfState::ELSE_ERROR;
}
}
else
if(id[2] == 's' && id[3] == 'e')
if(id[2] == 's' && id[3] == 'e') {
if(ifstack.GetCount() == 0) {
IfState& ifstate = ifstack.Add();
ifstate.ifline = 0;
@ -193,6 +194,8 @@ void CodeEditor::SyntaxState::ScanSyntax(const wchar *ln, const wchar *e, int ta
else
ifstate.state = IfState::ELSE_ERROR;
}
}
}
break;
case 5:

View file

@ -110,8 +110,8 @@ inline void LOGF(const char *format, ...) {}
#define NEVER() LOG_NOP
#define NEVER_(msg) LOG_NOP
#define XNEVER(d) LOG_NOP
#define CHECK(c) (c)
#define XCHECK(c, d) (c)
#define CHECK(c) (void)(c)
#define XCHECK(c, d) (void)(c)
#define TIMING(x) LOG_NOP
#define HITCOUNT(x) LOG_NOP

View file

@ -13,7 +13,7 @@ void SystemDraw::BeginOp()
Vector<Rect> newclip;
newclip <<= clip.Top();
f.clipi = clip.GetCount();
clip.Add() = newclip;
clip.Add() = pick(newclip);
cloff.Add(f);
}
@ -35,7 +35,7 @@ bool SystemDraw::ClipOp(const Rect& r)
Vector<Rect> newclip = Intersect(clip.Top(), r + actual_offset, ch);
if(ch) {
f.clipi = clip.GetCount();
clip.Add() = newclip;
clip.Add() = pick(newclip);
}
cloff.Add(f);
if(ch)
@ -51,7 +51,7 @@ bool SystemDraw::ClipoffOp(const Rect& r)
Vector<Rect> newclip = Intersect(clip.Top(), r + actual_offset, ch);
if(ch) {
f.clipi = clip.GetCount();
clip.Add() = newclip;
clip.Add() = pick(newclip);
}
f.offseti = offset.GetCount();
actual_offset += r.TopLeft();
@ -80,7 +80,7 @@ bool SystemDraw::ExcludeClipOp(const Rect& r)
bool ch = false;
Vector<Rect> ncl = Subtract(cl, r + actual_offset, ch);
if(ch) {
cl = ncl;
cl = pick(ncl);
SetClip();
}
return clip.Top().GetCount();
@ -93,7 +93,7 @@ bool SystemDraw::IntersectClipOp(const Rect& r)
bool ch = false;
Vector<Rect> ncl = Intersect(cl, r + actual_offset, ch);
if(ch) {
cl = ncl;
cl = pick(ncl);
SetClip();
}
return clip.Top().GetCount();

View file

@ -58,7 +58,7 @@ void TopWindow::SyncCaption()
void TopWindow::CenterRect(Ctrl *owner)
{
GuiLock __;
SetupRect();
SetupRect(owner);
if(owner && center == 1 || center == 2) {
Size sz = GetRect().Size();
Rect r, wr;

View file

@ -157,10 +157,10 @@ void TopWindow::SyncCaption()
#endif
}
void TopWindow::CenterRect(HWND hwnd, int center)
void TopWindow::CenterRect(HWND hwnd, int center, Ctrl *owner)
{
GuiLock __;
SetupRect();
SetupRect(owner);
if(hwnd && center == 1 || center == 2) {
Size sz = GetRect().Size();
Rect frmrc(sz);

View file

@ -145,14 +145,14 @@ void TopWindow::RejectBreak(int ID)
Break(ID);
}
void TopWindow::SetupRect()
void TopWindow::SetupRect(Ctrl *owner)
{
Rect r = GetRect();
if(r.IsEmpty())
SetRect(GetDefaultWindowRect());
else
if(r.left == 0 && r.top == 0 && center == 1) {
Rect area = Ctrl::GetWorkArea();
Rect area = owner ? owner->GetWorkArea() : Ctrl::GetWorkArea();
SetRect(area.CenterRect(min(area.Size(), r.Size())));
}
}

View file

@ -59,7 +59,7 @@ private:
void SyncTitle();
void SyncCaption();
void SetupRect();
void SetupRect(Ctrl *owner);
void FixIcons();

View file

@ -8,7 +8,7 @@ private:
HICON ico, lico;
void DeleteIco();
void CenterRect(HWND owner, int center);
void CenterRect(HWND owner, int center, Ctrl *owner);
public:
void Open(HWND ownerhwnd);

View file

@ -97,12 +97,12 @@ void Ctrl::EventProc(XWindow& w, XEvent *event)
if(top) {
Window DestW = (parent ? GetParentWindow() : Xroot);
XTranslateCoordinates(Xdisplay, top->window, DestW, 0, 0, &x, &y, &dummy);
Rect rect = RectC(x, y, e.width, e.height);
LLOG("CongigureNotify " << rect);
if(GetRect() != rect)
SetWndRect(rect);
// Synchronizes native windows (NOT the main one)
}
Rect rect = RectC(x, y, e.width, e.height);
LLOG("CongigureNotify " << rect);
if(GetRect() != rect)
SetWndRect(rect);
// Synchronizes native windows (NOT the main one)
SyncNativeWindows();
// 01/12/2007 - END

View file

@ -237,8 +237,8 @@ Buffer<unsigned long> TopWindow::PreperIcon(const Image& icon, int& len) {
void TopWindow::CenterRect(Ctrl *owner)
{
GuiLock __;
SetupRect();
if((owner&& center == 1) || center == 2) {
SetupRect(owner);
if((owner && center == 1) || center == 2) {
Rect r, wr;
wr = Ctrl::GetWorkArea();
Size sz = GetRect().Size();

View file

@ -328,7 +328,7 @@ void Ctrl::TimerAndPaint() {
if(xw.ctrl) {
LLOG("..and paint " << UPP::Name(xw.ctrl));
xw.ctrl->SyncScroll();
Vector<Rect> x = xw.invalid;
Vector<Rect> x = pick(xw.invalid);
xw.invalid.Clear();
xw.ctrl->DoPaint(x);
}

View file

@ -67,11 +67,12 @@ void TextCompareCtrl::LeftDouble(Point pt, dword keyflags)
void TextCompareCtrl::MouseMove(Point pt, dword flags)
{
if(HasCapture())
if(HasCapture()) {
if(gutter_capture)
LeftDown(pt, flags);
else
DoSelection(pt.y, true);
}
}
void TextCompareCtrl::LeftUp(Point pt, dword keyflags)

View file

@ -383,7 +383,7 @@ bool AssistEditor::IncludeAssist()
FindFile ff(AppendFileName(AppendFileName(include[i], include_path), "*.*"));
while(ff) {
String fn = ff.GetName();
if(!ff.IsHidden())
if(!ff.IsHidden()) {
if(ff.IsFolder()) {
folder.Add(fn);
upper_folder.Add(ToUpper(fn));
@ -396,6 +396,7 @@ bool AssistEditor::IncludeAssist()
upper_file.Add(ToUpper(fn));
}
}
}
ff.Next();
}
}
@ -577,7 +578,7 @@ void AssistEditor::Complete2()
Vector<String> id = GetFileIds();
for(int i = 0; i < id.GetCount(); i++) {
String s = id[i];
if(s.StartsWith(q))
if(s.StartsWith(q)) {
if(IsNull(h))
h = s;
else {
@ -588,6 +589,7 @@ void AssistEditor::Complete2()
break;
}
}
}
}
if(h.GetCount() > q.GetCount())
Paste(h.Mid(q.GetCount()).ToWString());
@ -742,20 +744,22 @@ bool AssistEditor::Key(dword key, int count)
if(popup.IsOpen()) {
int k = key & ~K_CTRL;
ArrayCtrl& kt = key & K_CTRL ? type : assist;
if(k == K_UP || k == K_PAGEUP || k == K_CTRL_PAGEUP || k == K_CTRL_END)
if(k == K_UP || k == K_PAGEUP || k == K_CTRL_PAGEUP || k == K_CTRL_END) {
if(kt.IsCursor())
return kt.Key(k, count);
else {
kt.SetCursor(kt.GetCount() - 1);
return true;
}
if(k == K_DOWN || k == K_PAGEDOWN || k == K_CTRL_PAGEDOWN || k == K_CTRL_HOME)
}
if(k == K_DOWN || k == K_PAGEDOWN || k == K_CTRL_PAGEDOWN || k == K_CTRL_HOME) {
if(kt.IsCursor())
return kt.Key(k, count);
else {
kt.SetCursor(0);
return true;
}
}
if(key == K_ENTER && assist.IsCursor()) {
AssistInsert();
return true;
@ -950,7 +954,7 @@ void AssistEditor::DCopy()
decl = false;
for(int j = 0; j < n.GetCount(); j++) {
const CppItem& m = n[j];
if(m.IsCode())
if(m.IsCode()) {
if(decl)
r << MakeDefinition(cls, m.natural) << "\n{\n}\n\n";
else {
@ -958,6 +962,7 @@ void AssistEditor::DCopy()
r << String('\t', Split(cpp.GetKey(i), ':').GetCount());
r << m.natural << ";\n";
}
}
if(m.IsData()) {
if(cls.GetCount()) {
const char *s = m.natural;

View file

@ -52,7 +52,7 @@ struct ScopeLess {
String CodeBrowser::GetPm()
{
String pm;
if(TheIde() && range)
if(TheIde() && range) {
if(range == 1)
pm = TheIde()->IdeGetNestFolder();
else {
@ -60,6 +60,7 @@ String CodeBrowser::GetPm()
if(range == 2)
pm = GetFileFolder(pm);
}
}
return pm;
}

View file

@ -146,11 +146,12 @@ void SaveGroupInc(const String& grouppath)
gh << "END_TOPIC\r\n\r\n";
}
String fn = AppendFileName(AppendFileName(packagedir, group + ".tpp"), "all.i");
if(LoadFile(fn) != gh)
if(LoadFile(fn) != gh) {
if(IsNull(gh))
DeleteFile(fn);
else
SaveFile(fn, gh);
}
}
void SetTopicGroupIncludeable(const char *path, bool set)

View file

@ -121,12 +121,13 @@ void TopicEditor::SaveTopic()
WString t;
for(int i = 0; i < para.GetCount(); i++)
if(para[i].IsText())
for(const wchar *s = para[i].text; *s; s++)
for(const wchar *s = para[i].text; *s; s++) {
if(*s == '\t' || *s == 160)
t.Cat(' ');
else
if(*s >= ' ')
t.Cat(*s);
}
if(!IsNull(t))
title <<= t;
}

View file

@ -61,11 +61,12 @@ void Ide::EndBuilding(bool ok)
PutConsole("");
PutConsole((ok ? "OK. " : "There were errors. ") + GetPrintTime(build_time));
SetIdeState(EDITING);
if(GetTopWindow()->IsOpen())
if(GetTopWindow()->IsOpen()) {
if(ok)
BeepMuteInformation();
else
BeepMuteExclamation();
}
ShowConsole();
}

View file

@ -633,11 +633,11 @@ void MakeBuild::SaveMakeFile(const String& fn, bool exporting)
<< "\tif [ -d $(UPPOUT) ]; then rm -rf $(UPPOUT); fi;\n";
bool sv = ::SaveFile(fn, makefile);
if(!exporting)
if(!exporting) {
if(sv)
PutConsole(NFormat("%s(1): makefile generation complete", fn));
else
PutConsole(NFormat("%s: error writing makefile", fn));
}
EndBuilding(true);
}

View file

@ -473,11 +473,12 @@ bool GccBuilder::Link(const Vector<String>& linkfile, const String& linkoptions,
lnk << ' ' << GetHostPathQ(FindInDirs(libpath, lib[i]));
}
else
if(ext != ".a")
if(ext != ".a") {
if(ext == ".so" || ext == ".dll" || ext == ".lib")
lnk << ' ' << GetHostPathQ(FindInDirs(libpath, lib[i]));
else
lnk << " -l" << ln;
}
}
}
PutConsole("Linking...");

View file

@ -149,11 +149,12 @@ bool JavaBuilder::BuildPackage(const String& package, Vector<String>& linkfile,
String linkcmd;
linkcmd << "javac";
linkcmd << (HasFlag("DEBUG") ? " -g" : " -g:none");
if(!HasFlag("DEBUG"))
if(!HasFlag("DEBUG")) {
if(!IsNull(release_options))
linkcmd << ' ' << release_options;
else
linkcmd << " -O";
}
linkcmd << " -deprecation" << linkoptions << " -sourcepath ";
bool win32 = HasFlag("WIN32");
for(i = 0; i < linkfile.GetCount(); i++) {

View file

@ -146,7 +146,7 @@ void LayoutItem::ReadProperties(CParser& p, bool addunknown)
else {
String name = p.ReadId();
int q = FindProperty(name);
if(q < 0)
if(q < 0) {
if(addunknown) {
q = property.GetCount();
ItemProperty& new_prop = property.Add(new RawProperty);
@ -158,6 +158,7 @@ void LayoutItem::ReadProperties(CParser& p, bool addunknown)
ReadPropertyParam(p);
p.PassChar(')');
}
}
if(q >= 0) {
ItemProperty& ip = property[q];
ip.SetCharset(charset);

View file

@ -509,11 +509,12 @@ void SelectPackageDlg::SyncBase(String initvars)
Sort(varlist, &PackageLess);
base.Clear();
Append(base, varlist);
if(!base.FindSetCursor(initvars))
if(!base.FindSetCursor(initvars)) {
if(base.GetCount() > 0)
base.SetCursor(0);
else
OnBase();
}
}
bool SelectPackageDlg::Pless(const SelectPackageDlg::PkInfo& a, const SelectPackageDlg::PkInfo& b)

View file

@ -255,11 +255,12 @@ void WorkspaceWork::LoadActualPackage()
}
}
Image m = IdeFileImage(f, f.optimize_speed);
if(GetFileExt(p) == ".tpp" && IsFolder(p))
if(GetFileExt(p) == ".tpp" && IsFolder(p)) {
if(FileExists(AppendFileName(p, "all.i")))
m = TopicImg::IGroup();
else
m = TopicImg::Group();
}
#ifdef PLATFORM_WIN32
p = ToLower(p);
#endif

View file

@ -738,12 +738,13 @@ void Ide::SetIcon()
return;
}
else
if((GetTimeClick() / 800) & 1)
if((GetTimeClick() / 800) & 1) {
if(debugger)
new_state_icon = 2;
else
if(idestate == BUILDING)
new_state_icon = 3;
}
if(state_icon == new_state_icon)
return;
state_icon = new_state_icon;

View file

@ -98,7 +98,7 @@ mainconfig
"" = "GUI CHECKCLIPBOARD",
"" = "GUI SVO_VALUE",
"" = "GUI GTK",
"" = "GUI X11",
"" = "GUI MT X11",
"" = "GUI MT NOGTK",
"" = "GUI NOGTK";

View file

@ -252,11 +252,12 @@ void Ide::MacroMenu(Bar& menu)
VectorMap< String, Vector<int> > submenu_map;
for(int i = 0; i < mlist.GetCount(); i++) {
const IdeMacro& m = mlist[i];
if(!IsNull(m.menu))
if(!IsNull(m.menu)) {
if(IsNull(m.submenu))
submenu_map.GetAdd(Null).Add(i);
else
submenu_map.GetAdd(m.menu).Add(i);
}
}
if(!submenu_map.IsEmpty()) {
Vector<int> order = GetSortOrder(submenu_map.GetKeys());
@ -331,13 +332,14 @@ void Ide::Setup(Bar& menu) {
menu.Add("Source managment..", THISBACK(AutoSetup))
.Help("Source code updater settings..");
menu.Separator();
if(UpdaterCfg().method%2==0) //local copy or svn
if(UpdaterCfg().method%2==0) { //local copy or svn
if(UpdaterCfg().available)
menu.Add("Install updates..", IdeImg::install_updates(), THISBACK(CheckUpdatesManual))
.Help("Install newer version of source codes..");
else
menu.Add("Check for updates..", IdeImg::check_updates(), THISBACK(CheckUpdatesManual))
.Help("Check for availability of newer source codes..");
}
#endif
}
@ -378,11 +380,12 @@ void Ide::Project(Bar& menu) {
if(OldLang())
menu.Add("Convert s_ -> t_", THISBACK(ConvertST));
FilePropertiesMenu(menu);
if(SvnDirs(true).GetCount())
if(SvnDirs(true).GetCount()) {
if(menu.IsMenuBar())
menu.Add("SVN", THISBACK(ProjectSvn));
else
menu.Add("SVN Synchronize everything..", IdeImg::svn(), THISBACK(SyncSvn));
}
}
void Ide::FilePropertiesMenu(Bar& menu)

View file

@ -85,11 +85,12 @@ bool LngParseTFile(const String& fn, VectorMap<String, LngEntry>& lng)
CParser p(data, fn);
try {
if(p.Char('#'))
while(!p.IsEof())
while(!p.IsEof()) {
if(p.IsChar2('T', '_'))
break;
else
p.SkipTerm();
}
String id;
while(!p.IsEof()) {
if(p.Id("T_")) {

View file

@ -991,7 +991,7 @@ WString ASBeautifier::beautify(const WString &originalLine)
}
// handle quotes (such as 'x' and "Hello Dolly")
if (!(isInComment || isInLineComment) && (ch == '"' || ch == '\''))
if (!(isInComment || isInLineComment) && (ch == '"' || ch == '\'')) {
if (!isInQuote)
{
quoteChar = ch;
@ -1003,6 +1003,7 @@ WString ASBeautifier::beautify(const WString &originalLine)
isInStatement = true;
continue;
}
}
if (isInQuote)
continue;
@ -1621,11 +1622,12 @@ WString ASBeautifier::beautify(const WString &originalLine)
// that both an assignment op and a non-assignment op where found,
// e.g. '>>' and '>>='. If this is the case, treat the LONGER one as the
// found operator.
if (foundAssignmentOp != NULL && foundNonAssignmentOp != NULL)
if (foundAssignmentOp != NULL && foundNonAssignmentOp != NULL) {
if (foundAssignmentOp->GetCount() < foundNonAssignmentOp->GetCount())
foundAssignmentOp = NULL;
else
foundNonAssignmentOp = NULL;
}
if (foundNonAssignmentOp != NULL)
{

View file

@ -217,7 +217,7 @@ void ASEnhancer::enhance(WString &line)
}
// handle quotes (such as 'x' and "Hello Dolly")
if (!(isInComment) && (ch == '"' || ch == '\''))
if (!(isInComment) && (ch == '"' || ch == '\'')) {
if (!isInQuote)
{
quoteChar = ch;
@ -228,6 +228,7 @@ void ASEnhancer::enhance(WString &line)
isInQuote = false;
continue;
}
}
if (isInQuote)
continue;
@ -335,11 +336,12 @@ void ASEnhancer::enhance(WString &line)
}
for (; i < lineLength; i++) // bypass colon
{
if (line[i] == ':')
if (line[i] == ':') {
if ((i + 1 < lineLength) && (line[i + 1] == ':'))
i++; // bypass scope resolution operator
else
break;
}
}
i++;
for (; i < lineLength; i++) // bypass whitespace

View file

@ -237,11 +237,12 @@ void MoveSvn(const String& path, const String& tp)
String nm = ff.GetName();
String s = AppendFileName(path, nm);
String t = AppendFileName(tp, nm);
if(ff.IsFolder())
if(ff.IsFolder()) {
if(nm == ".svn")
FileMove(s, t);
else
MoveSvn(s, t);
}
ff.Next();
}
}