Re: Why is Scintilla doing this?
Andrew Truckle <[email protected]>
| Newsgroups | gmane.comp.lib.scintilla.devel |
|---|---|
| Message-ID | <[email protected]> |
If I call this before showing the file dialog:
const auto line = m_edit.GetFirstVisibleLine();
const auto pos = m_edit.GetCurrentPos();
And then at the end, wther they click OK or cancel to that dialog, I call:
m_edit.SetFirstVisibleLine(line);
m_edit.SetCurrentPos(pos);
m_edit.ClearSelections();
It works. Position stays the file, nothing selected. But the caret is right
at the start of the document.
If I swap the lines:
m_edit.SetFirstVisibleLine(line);
m_edit.ClearSelections();
m_edit.SetCurrentPos(pos);
The caret ends up at the right place, but now everything is selected from
the start of the document to the caret.
I can't win.
Is there no way to get the editor to temporarily stop doing anything ?
Tried SetRedraw with false and true and it didn't quite work.
On Sunday 5 May 2024 at 20:39:26 UTC+1 Andrew Truckle wrote:
> Firstly, I apologise by my wording "why is scintilla doing this". That was
> a bold assumption!
>
> Upon closer inspecting I can confirm that saving an existing file does as
> it should. Cursor says in the same place and nothing gets selected.
>
> It is when I show my file dialog and then click either OK or cancel that
> this issue happens.
>
>
> On Sunday 5 May 2024 at 19:02:33 UTC+1 Andrew Truckle wrote:
>
>> Here is my saving code:
>>
>> Scintilla::Position nBytesToWrite{ m_edit.GetLength() };
>> const char* CharacterPointer = m_edit.GetCharacterPointer();
>> while (nBytesToWrite > 0)
>> {
>> Scintilla::Position nDataToWrite{ nBytesToWrite };
>> if (nDataToWrite > UINT_MAX)
>> nDataToWrite = UINT_MAX;
>> #pragma warning(suppress: 26472)
>> file.Write(CharacterPointer, static_cast<UINT>(nDataToWrite));
>>
>> // Prepare for the next loop around
>> #pragma warning(suppress: 26481)
>> CharacterPointer += nDataToWrite;
>> nBytesToWrite -= nDataToWrite;
>> }
>>
>>
>>
>> It works really well. But I have two annoying side effects:
>>
>>
>> 1. It selects all the text.
>> 2. It scrolls all the way to the bottom.
>>
>> I don't want it to do any of this. The cursor should stay where it was
>> and it shouldn't select all the text.
>>
>> Why is it doing this?
>>
>
--
You received this message because you are subscribed to the Google Groups "scintilla-interest" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/scintilla-interest/a3b5f6ec-6303-489b-81e8-976137d4c659n%40googlegroups.com.