X-Git-Url: https://ecere.com/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=extras%2Fhtml%2FHTMLView.ec;h=6a467de01c58496fe0adc74c107217443695b91c;hb=4430f4acb3fa94835b3fe734a6f47dc472086660;hp=c706dfbeecb0bf0d38a812df19e4f2066bd13604;hpb=9985aaa9c0f469f9d6c012b32cb4fcd59426e34b;p=sdk diff --git a/extras/html/HTMLView.ec b/extras/html/HTMLView.ec index c706dfb..6a467de 100644 --- a/extras/html/HTMLView.ec +++ b/extras/html/HTMLView.ec @@ -595,6 +595,41 @@ class HTMLView : Window } } + void NormalizeSelection(Block * startBlock, int * startSel, Block * endBlock, int * endSel) + { + bool selAfter = false; + Block b; + for(b = selBlock; b; b = GetNextBlock(b)) + { + if(b != selBlock && b == textBlock) + { + selAfter = true; + break; + } + } + + if(textBlock == selBlock) + { + *startSel = Min(selPosition, curPosition); + *endSel = Max(selPosition, curPosition); + *startBlock = *endBlock = textBlock; + } + else if(!selAfter) + { + *startBlock = textBlock; + *startSel = curPosition; + *endSel = selPosition; + *endBlock = selBlock; + } + else + { + *startBlock = selBlock; + *startSel = selPosition; + *endSel = curPosition; + *endBlock = textBlock; + } + } + void PositionForms() { Block block = html.body; @@ -913,6 +948,11 @@ class HTMLView : Window } } + // For text selection + Block textBlock, selBlock; + int curPosition, selPosition; + bool isSelected; // Persistent state changed by RenderLine + void OnRedraw(Surface surface) { Block block = html.body; @@ -934,6 +974,7 @@ class HTMLView : Window if(html.defaultFont.font) // TOFIX: Null! (No font set?) surface.TextFont(html.defaultFont.font.font); surface.SetForeground(html.defaultFont.textColor); + isSelected = false; for(;block;) { @@ -978,6 +1019,7 @@ class HTMLView : Window //h = Max(h, newH); RenderLine(this, surface, x - scroll.x, y - scroll.y, maxW, newH, block, textPos, nextBlock, nextTextPos, left - scroll.x, right - scroll.x); + if(changeLine) { // y += h;