Skip to content

Commit

Permalink
Attempt at fixing font width problem by making the selection code use…
Browse files Browse the repository at this point in the history
… floats, too
  • Loading branch information
ctrlaltca committed Nov 29, 2023
1 parent 7916bf0 commit 7c56944
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/kvirc/ui/KviIrcView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2692,7 +2692,7 @@ int KviIrcView::getVisibleCharIndexAt(KviIrcViewLine *, int xPos, int yPos)
* iTop is the line start y coordinate. Now we have to go through this line's text and find the exact text under the mouse.
* The line start x posistion is iLeft; we save iTop to firstRowTop (many rows can be part of this lingle line of text)
*/
int iLeft = KVI_IRCVIEW_HORIZONTAL_BORDER;
float iLeft = KVI_IRCVIEW_HORIZONTAL_BORDER;

if(KVI_OPTION_BOOL(KviOption_boolIrcViewShowImages))
iLeft += KVI_IRCVIEW_PIXMAP_AND_SEPARATOR;
Expand Down Expand Up @@ -2755,7 +2755,8 @@ int KviIrcView::getVisibleCharIndexAt(KviIrcViewLine *, int xPos, int yPos)
return l->szText.size();
}
// now, get the right character inside the block
int retValue = 0, oldIndex = 0, oldLeft = iLeft;
int retValue = 0, oldIndex = 0;
float oldLeft = iLeft;
QChar curChar;
// add the width of each single character until we get the right one
while(iLeft < xPos && retValue < l->pBlocks[i].block_len)
Expand All @@ -2778,7 +2779,7 @@ int KviIrcView::getVisibleCharIndexAt(KviIrcViewLine *, int xPos, int yPos)
// Make the horizontal point delimiting which characters are to be selected be in the middle of the character,
// i.e. if the user starts selecting from the left half of a character, select that character too.
// This mimics the behavior of most other GUI applications.
int iMid = (oldLeft + iLeft) / 2;
float iMid = (oldLeft + iLeft) / 2;
if (xPos <= iMid)
retValue = oldIndex;

Expand Down

0 comments on commit 7c56944

Please sign in to comment.