EditField: Fixed X11 selection issue

git-svn-id: svn://ultimatepp.org/upp/trunk@7588 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2014-08-12 21:05:02 +00:00
parent b67920c1ca
commit 920704ab6c
6 changed files with 21 additions and 23 deletions

View file

@ -205,7 +205,7 @@ inline bool IsCppTemplate(int i) {
return i == STRUCTTEMPLATE || i >= FUNCTIONTEMPLATE && i <= CLASSFUNCTIONTEMPLATE;
}
enum AccessEnum {
enum CppAccess {
PUBLIC,
PROTECTED,
PRIVATE,

View file

@ -5,7 +5,7 @@
NAMESPACE_UPP
#define LLOG(x) // DLOG(x)
#define LLOG(x) // DLOG(x)
void Ctrl::GtkSelectionDataSet(GtkSelectionData *selection_data, const String& fmt, const String& data)
{

View file

@ -68,18 +68,13 @@ void TopWindow::CenterRect(Ctrl *owner)
SetupRect(owner);
if(owner && center == 1 || center == 2) {
Size sz = GetRect().Size();
DDUMP(sz);
DDUMP(center);
Rect r, wr;
wr = Ctrl::GetWorkArea();
Rect fm = GetFrameMargins();
DDUMP(wr);
DDUMP(fm);
if(center == 1)
r = owner->GetRect();
else
r = wr;
DDUMP(r);
Point p = r.CenterPos(sz);
r = RectC(p.x, p.y, sz.cx, sz.cy);
wr.left += fm.left;

View file

@ -127,6 +127,7 @@ protected:
int maxlen;
int autosize;
byte charset;
int fsell, fselh; // used to hold selection after LostFocus for X11 middle mouse copy
int dropcursor;
Rect dropcaret;
@ -142,7 +143,6 @@ protected:
bool errorbg:1;
bool showspaces:1;
bool no_internal_margin:1;
bool autoselection:1;
bool FrameIsEdge();
void SetEdge(int i);
@ -161,6 +161,7 @@ protected:
void DoAutoFormat();
int GetTy() const;
void StdPasteFilter(WString&);
void SelSource();
protected:
virtual void HighlightText(Vector<Highlight>& hl);

View file

@ -446,6 +446,14 @@ void EditField::Layout()
Finish();
}
void EditField::SelSource()
{
if(GetSelection(fsell, fselh))
SetSelectionSource(ClipFmtsText());
else
fsell = fselh = -1;
}
void EditField::GotFocus()
{
if(autoformat && IsEditable() && !IsNull(text) && inactive_convert) {
@ -458,11 +466,8 @@ void EditField::GotFocus()
if(!keep_selection && !IsSelection()) {
anchor = 0;
cursor = text.GetLength();
autoselection = true;
}
else
if(IsSelection())
SetSelectionSource(ClipFmtsText());
SelSource();
Finish();
SyncEdge();
}
@ -477,7 +482,7 @@ void EditField::LostFocus()
if(s != text) text = s;
}
}
if(!keep_selection/* && autoselection*/) {
if(!keep_selection) {
anchor = -1;
cursor = sc = 0;
}
@ -572,9 +577,7 @@ void EditField::Move(int newpos, bool select)
anchor = -1;
cursor = newpos;
Finish(refresh);
if(select)
SetSelectionSource(ClipFmtsText());
autoselection = false;
SelSource();
}
void EditField::SetSelection(int l, int h)
@ -587,7 +590,7 @@ void EditField::SetSelection(int l, int h)
cursor = l;
anchor = -1;
}
autoselection = false;
SelSource();
Finish();
}
@ -597,10 +600,10 @@ void EditField::CancelSelection()
if(GetSelection(l, h)) {
cursor = l;
anchor = -1;
fsell = fselh = -1;
sc = 0;
Finish();
}
autoselection = false;
}
bool EditField::RemoveSelection()
@ -787,9 +790,8 @@ void EditField::LeftDrag(Point p, dword flags)
String EditField::GetSelectionData(const String& fmt) const
{
int sell, selh;
if(GetSelection(sell, selh))
return GetTextClip(text.Mid(sell, selh - sell), fmt);
if(fsell >= 0 && fselh >= 0 && fsell <= text.GetCount() && fselh <= text.GetCount())
return GetTextClip(text.Mid(fsell, fselh - fsell), fmt);
return String();
}
@ -1041,7 +1043,7 @@ void EditField::Reset()
font = StdFont();
showspaces = false;
no_internal_margin = false;
autoselection = false;
fsell = fselh = -1;
}
EditField& EditField::SetFont(Font _font)

View file

@ -4,7 +4,7 @@
#include "ide\Common/init"
#include "PdfDraw/init"
#include "RichEdit/init"
#define BLITZ_INDEX__ F93222d80ec8e06ccbdf5f9e1c0bd4535
#define BLITZ_INDEX__ F09f1bfac1925f12219a612fc7165f5a9
#include "TopicI.icpp"
#undef BLITZ_INDEX__
#endif