[dasher: 90/217] Implemented win32 version of GetTextAroundCursor.
- From: Patrick Welche <pwelche src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dasher: 90/217] Implemented win32 version of GetTextAroundCursor.
- Date: Sat, 27 Feb 2016 12:07:53 +0000 (UTC)
commit 4f0967158ad192a9b142860cdff5ac3b08f54ca8
Author: ipomoena <amajorek google com>
Date: Sat Oct 17 13:36:38 2015 -0700
Implemented win32 version of GetTextAroundCursor.
Src/Win32/Dasher.cpp | 4 ++++
Src/Win32/Dasher.h | 3 ++-
Src/Win32/Widgets/Edit.cpp | 15 +++++++++++++++
Src/Win32/Widgets/Edit.h | 2 ++
4 files changed, 23 insertions(+), 1 deletions(-)
---
diff --git a/Src/Win32/Dasher.cpp b/Src/Win32/Dasher.cpp
index bfa2a67..933b1af 100644
--- a/Src/Win32/Dasher.cpp
+++ b/Src/Win32/Dasher.cpp
@@ -352,3 +352,7 @@ std::string CDasher::GetContext(unsigned int iStart, unsigned int iLength) {
int CDasher::GetAllContextLenght(){
return m_pEdit->GetWindowTextLength();
}
+
+std::string CDasher::GetTextAroundCursor(CControlManager::EditDistance iDist) {
+ return m_pEdit->GetTextAroundCursor(iDist);
+}
diff --git a/Src/Win32/Dasher.h b/Src/Win32/Dasher.h
index 6afd0ea..50fe4e0 100644
--- a/Src/Win32/Dasher.h
+++ b/Src/Win32/Dasher.h
@@ -53,7 +53,8 @@ public:
virtual std::string GetAllContext();
std::string GetContext(unsigned int iStart, unsigned int iLength);
int GetAllContextLenght();
-
+ std::string GetTextAroundCursor(CControlManager::EditDistance iDist);
+
#ifdef WIN32_SPEECH
bool SupportsSpeech();
void Speak(const std::string &text, bool bInterrupt);
diff --git a/Src/Win32/Widgets/Edit.cpp b/Src/Win32/Widgets/Edit.cpp
index c4415ec..7d321d6 100644
--- a/Src/Win32/Widgets/Edit.cpp
+++ b/Src/Win32/Widgets/Edit.cpp
@@ -433,6 +433,21 @@ void CEdit::GetRange(bool bForwards, CControlManager::EditDistance iDist, int* p
}
}
+std::string CEdit::GetTextAroundCursor(CControlManager::EditDistance iDist) {
+ int iStart = 0;
+ int iEnd = 0;
+ SendMessage(EM_GETSEL, (WPARAM)&iStart, (LPARAM)&iEnd);
+ if (iStart == iEnd) { // Ignore distance if text is selected.
+ GetRange(true, iDist, &iStart, &iEnd);
+ iStart = iEnd;
+ GetRange(false, iDist, &iStart, &iEnd);
+ }
+ CString wideText;
+ GetWindowText(wideText);
+
+ return wstring_to_UTF8string(wideText.Mid(iStart, iEnd-iStart));
+}
+
int CEdit::Move(bool bForwards, CControlManager::EditDistance iDist) {
int iStart = 0;
int iEnd = 0;
diff --git a/Src/Win32/Widgets/Edit.h b/Src/Win32/Widgets/Edit.h
index 2c712ab..b5daf93 100644
--- a/Src/Win32/Widgets/Edit.h
+++ b/Src/Win32/Widgets/Edit.h
@@ -86,6 +86,8 @@ class CEdit : public ATL::CWindowImpl<CEdit> {
int Move(bool bForwards, Dasher::CControlManager::EditDistance iDist);
int Delete(bool bForwards, Dasher::CControlManager::EditDistance iDist);
+ std::string GetTextAroundCursor(Dasher::CControlManager::EditDistance iDist);
+
void SetKeyboardTarget(HWND hwnd);
bool ConfirmAndSaveIfNeeded();
bool Save();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]