diff options
| author | Nicolas "Pixel" Noble <pixel@nobis-crew.org> | 2010-09-09 10:17:40 +0200 | 
|---|---|---|
| committer | Nicolas "Pixel" Noble <pixel@nobis-crew.org> | 2010-09-09 10:17:40 +0200 | 
| commit | 92f54bc5b92fcd5490260e277e3f33eb63f83c19 (patch) | |
| tree | 0d45c6b5bad7ff2e83bdafe701ddab49293b994c /iup | |
| parent | 547c17bb1c2d3ae6c187bf2082b6b5ada3f124c1 (diff) | |
Trying to improve the addformattag behavior in order to avoid scrolling physically and destrying the selection.
Diffstat (limited to 'iup')
| -rwxr-xr-x | iup/src/win/iupwin_text.c | 14 | 
1 files changed, 9 insertions, 5 deletions
| diff --git a/iup/src/win/iupwin_text.c b/iup/src/win/iupwin_text.c index c0e7115..bb325b4 100755 --- a/iup/src/win/iupwin_text.c +++ b/iup/src/win/iupwin_text.c @@ -1177,6 +1177,8 @@ void iupdrvTextAddFormatTag(Ihandle* ih, Ihandle* formattag)    char *selection, *units;    PARAFORMAT2 paraformat;    CHARFORMAT2 charformat; +  CHARRANGE oldRange; +  DWORD line0, line1;    /* one twip is 1/1440 inch */    /* twip = (pixel*1440)/(pixel/inch) */ @@ -1194,12 +1196,14 @@ void iupdrvTextAddFormatTag(Ihandle* ih, Ihandle* formattag)        convert2twips = val;    } +  /* saves current selection / scroll position before doing anything */ +  line0 = SendMessage(ih->handle, EM_GETFIRSTVISIBLELINE, 0, 0); +  SendMessage(hWnd, EM_EXGETSEL, 0, LPARAM(&oldrange));    selection = iupAttribGet(formattag, "SELECTION");    if (selection)    {      /* In Windows, the format message use the current selection */      winTextSetSelectionAttrib(ih, selection); -    iupAttribSetStr(ih, "SELECTION", NULL);    }    else    { @@ -1208,7 +1212,6 @@ void iupdrvTextAddFormatTag(Ihandle* ih, Ihandle* formattag)      {        /* In Windows, the format message use the current selection */        winTextSetSelectionPosAttrib(ih, selectionpos); -      iupAttribSetStr(ih, "SELECTIONPOS", NULL);      }    } @@ -1223,9 +1226,10 @@ void iupdrvTextAddFormatTag(Ihandle* ih, Ihandle* formattag)    if (charformat.dwMask != 0)      SendMessage(ih->handle, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&charformat); -  /* reset the selection, if changed here */ -  if (selection) -    winTextSetSelectionAttrib(ih, NULL); +  /* restores selection / scroll position */ +  SendMessage(ih->handle, EX_EXSETSEL, 0, LPARAL(&oldRange)); +  line1 = SendMessage(ih->handle, EM_GETFIRSTVISIBLELINE, 0, 0); +  SendMessage(ih->handle, EX_LINESCROLL, 0, Line0 - Line1);  }  static int winTextSetRemoveFormattingAttrib(Ihandle* ih, const char* value) | 
