RichEdit: Fixed selection with table issue

git-svn-id: svn://ultimatepp.org/upp/trunk@10447 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2016-11-16 09:10:01 +00:00
parent 1bf9777d78
commit 3f71f54ac9
6 changed files with 41 additions and 10 deletions

View file

@ -0,0 +1,25 @@
topic "";
[2 $$0,0#00000000000000000000000000000000:Default]
[i448;a25;kKO9;2 $$1,0#37138531426314131252341829483380:class]
[l288;2 $$2,2#27521748481378242620020725143825:desc]
[0 $$3,0#96390100711032703541132217272105:end]
[H6;0 $$4,0#05600065144404261032431302351956:begin]
[i448;a25;kKO9;2 $$5,0#37138531426314131252341829483370:item]
[l288;a4;*@5;1 $$6,6#70004532496200323422659154056402:requirement]
[l288;i1121;b17;O9;~~~.1408;2 $$7,0#10431211400427159095818037425705:param]
[i448;b42;O9;2 $$8,8#61672508125594000341940100500538:tparam]
[b42;2 $$9,9#13035079074754324216151401829390:normal]
[{_}%EN-US
[ {{10000@(113.42.0) [s0; [*@7;4 Title]]}}&]
[s1;O_; &]
[s0; Range is a concept&]
[s1;:noref: [@(0.0.255)3 template][3 _<][@(0.0.255)3 class][3 _][*@4;3 I][3 >]&]
[s1;:Upp`:`:SubRangeClass`:`:class: [@(0.0.255) class]_[* SubRangeClass]&]
[s2; &]
[s3; &]
[s0;i448;a25;kKO9;@(0.0.255) &]
[ {{10000F(128)G(128)@1 [s0; [* Function List]]}}&]
[s0;i448;a25;kKO9;:noref:@(0.0.255) &]
[ {{10000F(128)G(128)@1 [s0; [* Public Method List]]}}&]
[s0; &]
[ {{10000F(128)G(128)@1 [s0; [* Constructor detail]]}}]]

View file

@ -4,6 +4,8 @@ namespace Upp {
void RichEdit::FinishNF()
{
cursor = clamp(cursor, 0, text.GetLength());
anchor = clamp(anchor, 0, text.GetLength());
anchorp = text.GetRichPos(anchor);
cursorp = text.GetRichPos(cursor);
tablesel = 0;
@ -17,6 +19,8 @@ void RichEdit::FinishNF()
else
if(p.table != anchorp.table) {
if(anchor == 0 && anchorp.level == 1 && text.GetRichPos(anchor, 1).table == 1 && anchor < cursor) {
while(cursor > 0 && cursorp.level) // selection must at at plain text
cursorp = text.GetRichPos(--cursor);
begtabsel = true;
anchor = 0;
}

View file

@ -45,14 +45,15 @@ RichEdit::UndoRec * RichEdit::UndoBegSelUnFix::GetRedo(const RichText& txt)
return new RichEdit::UndoBegSelFix;
}
bool RichEdit::BegSelTabFix()
bool RichEdit::BegSelTabFix(int& count)
{
if(begtabsel) {
if(begtabsel) { // If selection starts with first table which is the first element in the text
int c = cursor;
AddUndo(new UndoBegSelFix);
BegSelFixRaw(text);
BegSelFixRaw(text); // adds an empty paragraph at the start
Move(0);
Move(c + 1, true);
Move(c + 1, true); // and changes the selection
count++;
begtabsel = false;
return true;
}
@ -60,7 +61,7 @@ bool RichEdit::BegSelTabFix()
}
void RichEdit::BegSelTabFixEnd(bool fix)
{
{ // removes empty paragraph added by BegSelTabFix
if(fix && GetLength() > 0) {
int c = cursor;
AddUndo(new UndoBegSelUnFix);
@ -121,7 +122,7 @@ void RichEdit::SaveFormat()
pos = cursor;
count = 0;
}
bool b = BegSelTabFix();
bool b = BegSelTabFix(count);
SaveFormat(pos, count);
BegSelTabFixEnd(b);
}
@ -137,7 +138,7 @@ void RichEdit::ModifyFormat(int pos, const RichText::FormatInfo& fi, int count)
{
if(IsReadOnly())
return;
bool b = BegSelTabFix();
bool b = BegSelTabFix(count);
Limit(pos, count);
SaveFormat(pos, count);
text.ApplyFormatInfo(pos, fi, count);

View file

@ -621,7 +621,8 @@ private:
void HeaderFooter();
bool EditHeaderFooter(String& header_qtf, String& footer_qtf);
bool BegSelTabFix();
bool BegSelTabFix(int& count);
bool BegSelTabFix() { int dummy; return BegSelTabFix(dummy); }
void BegSelTabFixEnd(bool fix);
Size GetPhysicalSize(const RichObject& obj);

View file

@ -297,7 +297,7 @@ struct RichPos {
int tabposintabtext;
int tabtextlen;
int table;
int table; // current level table index (unique in text) or zero if not in table
Size tabsize;
Point cell;

View file

@ -252,7 +252,7 @@ int RichTxt::GetPos(int x, PageY y, RichContext rc) const
}
}
return pos - 1;
return clamp(pos - 1, 0, GetLength());
}
RichHotPos RichTxt::GetHotPos(int x, PageY y, int tolerance, RichContext rc) const