Merge pull request #113 from SunTrustDev/bugfix/text-fields-improvements

This commit is contained in:
rtw1x1
2026-02-18 15:50:53 +00:00
committed by GitHub
5 changed files with 52 additions and 3 deletions

View File

@@ -1280,9 +1280,12 @@ int CGraphicTextInstance::PixelPositionToCharacterPosition(int iPixelPosition)
if (adv <= 0)
adv = pCurCharInfo->width;
int charStart = icurPosition;
icurPosition += adv;
if (adjustedPixelPos < icurPosition)
int charMid = charStart + adv / 2;
if (adjustedPixelPos < charMid)
{
visualPos = i;
break;

View File

@@ -134,6 +134,9 @@ int GetTextTagInternalPosFromRenderPos(const wchar_t * src, int src_len, int off
i += len;
}
if (offset >= output_len)
return src_len;
return internal_offset;
}

View File

@@ -2,6 +2,8 @@
#include "PythonIME.h"
#include "AbstractApplication.h"
bool CPythonIME::ms_bSecretMode = false;
CPythonIME::CPythonIME()
: CIME()
{
@@ -99,7 +101,10 @@ bool CPythonIME::OnWM_CHAR(WPARAM wParam, LPARAM lParam)
case 0x03: // Ctrl+C
if (ms_bCaptureInput)
{
CopySelectionToClipboard();
if (!ms_bSecretMode)
{
CopySelectionToClipboard();
}
return true;
}
return false;
@@ -184,12 +189,18 @@ void CPythonIME::DeleteSelection()
void CPythonIME::CopySelectionToClipboard()
{
if (ms_bSecretMode)
return;
CIME::CopySelectionToClipboard(ms_hWnd);
}
void CPythonIME::CutSelection()
{
CIME::CopySelectionToClipboard(ms_hWnd);
if (!ms_bSecretMode)
{
CIME::CopySelectionToClipboard(ms_hWnd);
}
CIME::DeleteSelection();
}
@@ -197,3 +208,13 @@ void CPythonIME::PasteTextFromClipBoard()
{
CIME::PasteTextFromClipBoard();
}
void CPythonIME::SetSecretMode(bool bSecret)
{
ms_bSecretMode = bSecret;
}
bool CPythonIME::IsSecretMode()
{
return ms_bSecretMode;
}

View File

@@ -27,6 +27,9 @@ public:
void Create(HWND hWnd);
static void SetSecretMode(bool bSecret);
static bool IsSecretMode();
protected:
virtual void OnTab();
virtual void OnReturn();
@@ -39,4 +42,6 @@ protected:
virtual void OnOpenReadingWnd();
virtual void OnCloseReadingWnd();
private:
static bool ms_bSecretMode;
};

View File

@@ -251,6 +251,21 @@ PyObject* imePasteReturn(PyObject * poSelf, PyObject * poArgs)
return Py_BuildNone();
}
PyObject* imeSetSecretMode(PyObject * poSelf, PyObject * poArgs)
{
int iFlag;
if (!PyTuple_GetInteger(poArgs, 0, &iFlag))
return Py_BuildException();
CPythonIME::SetSecretMode(iFlag != 0);
return Py_BuildNone();
}
PyObject* imeIsSecretMode(PyObject * poSelf, PyObject * poArgs)
{
return Py_BuildValue("i", CPythonIME::IsSecretMode() ? 1 : 0);
}
void initime()
{
static PyMethodDef s_methods[] =
@@ -293,6 +308,8 @@ void initime()
{ "CutSelection", imeCutSelection, METH_VARARGS },
{ "CopySelection", imeCopySelectionToClipboard,METH_VARARGS },
{ "EnablePaste", imeEnablePaste, METH_VARARGS },
{ "SetSecretMode", imeSetSecretMode, METH_VARARGS },
{ "IsSecretMode", imeIsSecretMode, METH_VARARGS },
{ NULL, NULL, NULL },
};