Skip to content

Commit 81a8558

Browse files
committed
Expose spell checking support API in the Browser object (#274).
See also Issue #274 to see command line switches related to spell checking support. Run wxpython example after compile. Fix linux make-setup.py. Update tools/toc.py.
1 parent be10dba commit 81a8558

File tree

7 files changed

+46
-2
lines changed

7 files changed

+46
-2
lines changed

api/API-index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
* [user_data_path](ApplicationSettings.md#user_data_path)
3636
* [windowless_rendering_enabled](ApplicationSettings.md#windowless_rendering_enabled)
3737
* [Browser (object)](Browser.md)
38+
* [AddWordToDictionary](Browser.md#addwordtodictionary)
3839
* [CanGoBack](Browser.md#cangoback)
3940
* [CanGoForward](Browser.md#cangoforward)
4041
* [CloseBrowser](Browser.md#closebrowser)
@@ -84,6 +85,7 @@
8485
* [ParentWindowWillClose](Browser.md#parentwindowwillclose)
8586
* [Reload](Browser.md#reload)
8687
* [ReloadIgnoreCache](Browser.md#reloadignorecache)
88+
* [ReplaceMisspelling](Browser.md#replacemisspelling)
8789
* [SetBounds](Browser.md#setbounds)
8890
* [SendKeyEvent](Browser.md#sendkeyevent)
8991
* [SendMouseClickEvent](Browser.md#sendmouseclickevent)

api/Browser.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ just assign a None value to a "browser" variable.
1212
Table of contents:
1313
* [Notes](#notes)
1414
* [Methods](#methods)
15+
* [AddWordToDictionary](#addwordtodictionary)
1516
* [CanGoBack](#cangoback)
1617
* [CanGoForward](#cangoforward)
1718
* [CloseBrowser](#closebrowser)
@@ -61,6 +62,7 @@ Table of contents:
6162
* [ParentWindowWillClose](#parentwindowwillclose)
6263
* [Reload](#reload)
6364
* [ReloadIgnoreCache](#reloadignorecache)
65+
* [ReplaceMisspelling](#replacemisspelling)
6466
* [SetBounds](#setbounds)
6567
* [SendKeyEvent](#sendkeyevent)
6668
* [SendMouseClickEvent](#sendmouseclickevent)
@@ -99,6 +101,16 @@ Methods available in upstream CEF which were not yet exposed in CEF Python
99101
## Methods
100102

101103

104+
### AddWordToDictionary
105+
106+
| Parameter | Type |
107+
| --- | --- |
108+
| word | string |
109+
| __Return__ | void |
110+
111+
Add the specified |word| to the spelling dictionary.
112+
113+
102114
### CanGoBack
103115

104116
| | |
@@ -658,6 +670,17 @@ Reload the current page.
658670
Reload the current page ignoring any cached data.
659671

660672

673+
### ReplaceMisspelling
674+
675+
| Parameter | Type |
676+
| --- | --- |
677+
| word | string |
678+
| __Return__ | void |
679+
680+
If a misspelled word is currently selected in an editable node calling
681+
this method will replace it with the specified |word|.
682+
683+
661684
### SetBounds
662685

663686
| Parameter | Type |

src/browser.pyx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,11 @@ cdef class PyBrowser:
251251
# CEF API.
252252
# --------------
253253

254+
cpdef py_void AddWordToDictionary(self, py_string word):
255+
cdef CefString cef_word
256+
PyToCefString(word, cef_word)
257+
self.GetCefBrowserHost().get().AddWordToDictionary(cef_word)
258+
254259
cpdef py_bool CanGoBack(self):
255260
return self.GetCefBrowser().get().CanGoBack()
256261

@@ -404,6 +409,11 @@ cdef class PyBrowser:
404409
cpdef py_void ReloadIgnoreCache(self):
405410
self.GetCefBrowser().get().ReloadIgnoreCache()
406411

412+
cpdef py_void ReplaceMisspelling(self, py_string word):
413+
cdef CefString cef_word
414+
PyToCefString(word, cef_word)
415+
self.GetCefBrowserHost().get().ReplaceMisspelling(cef_word)
416+
407417
cpdef py_void SetBounds(self, int x, int y, int width, int height):
408418
if platform.system() == "Linux":
409419
x11.SetX11WindowBounds(self.GetCefBrowser(), x, y, width, height)

src/extern/cef/cef_browser.pxd

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ cdef extern from "include/cef_browser.h":
7979
void DragSourceEndedAt(int x, int y, cef_types.cef_drag_operations_mask_t op)
8080
void DragSourceSystemDragEnded()
8181

82+
# Spell checking
83+
void ReplaceMisspelling(const CefString& word)
84+
void AddWordToDictionary(const CefString& word)
85+
8286

8387
cdef cppclass CefBrowser:
8488

src/linux/compile.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ def check_cython_version():
303303
run_examples = " && {python} ../src/linux/binaries_64bit/kivy_.py"
304304
else:
305305
run_examples = (" && {python} hello_world.py"
306+
" && {python} wxpython.py"
306307
" && {python} gtk2.py"
307308
" && {python} gtk2.py --message-loop-timer"
308309
# " && {python} gtk3.py"

src/linux/installer/make-setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,9 @@ def main():
189189
# assert ret == 0
190190

191191
print("Copying wx/ to package dir")
192-
wx_subpackage_dir = os.path.abspath(INSTALLER_DIR+"/../../wx/")
192+
wx_subpackage_dir = os.path.abspath(INSTALLER_DIR+"/../../cefpython3.wx/")
193193
ret = os.system("cp -rf " + wx_subpackage_dir + "/* " + package_dir
194-
+ "/cefpython3.wx/")
194+
+ "/wx/")
195195
assert ret == 0
196196

197197
# print("Moving wx examples from wx/examples to examples/wx")

tools/toc.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,13 @@
1414
import re
1515
import glob
1616

17+
API_DIR = os.path.join(os.path.dirname(__file__), "..", "api")
18+
1719

1820
def main():
1921
"""Main entry point."""
22+
if len(sys.argv) == 1:
23+
sys.argv.append(API_DIR)
2024
if (len(sys.argv) == 1 or
2125
"-h" in sys.argv or
2226
"--help" in sys.argv or

0 commit comments

Comments
 (0)