Skip to content

Commit

Permalink
Merge pull request alexflint#36 from alexflint/notitie_related_fixes
Browse files Browse the repository at this point in the history
Add cut, copy, paste, etc to window API
  • Loading branch information
alexflint committed Nov 12, 2016
2 parents ffe0959 + c5d7720 commit aec7cef
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 9 deletions.
55 changes: 50 additions & 5 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ import (
"unsafe"
)

var (
errZeroWidth = errors.New("window width was zero")
errZeroHeight = errors.New("window height was zero")
)

// cerr holds a C-allocated error, which must be freed explicitly.
type cerr struct {
c *C.struct_gallium_error
Expand Down Expand Up @@ -155,11 +160,6 @@ type Window struct {
c *C.gallium_window_t
}

var (
errZeroWidth = errors.New("window width was zero")
errZeroHeight = errors.New("window height was zero")
)

// OpenWindow creates a window that will load the given URL.
func (app *App) OpenWindow(url string, opt WindowOptions) (*Window, error) {
if opt.Shape.Width == 0 {
Expand Down Expand Up @@ -241,6 +241,51 @@ func (w *Window) Miniaturize() {
C.GalliumWindowMiniaturize(w.c)
}

// Undo undoes the last text editing action
func (w *Window) Undo() {
C.GalliumWindowUndo(w.c)
}

// Redo redoes the last text editing action
func (w *Window) Redo() {
C.GalliumWindowRedo(w.c)
}

// Cut cuts the current text selection to the pastboard
func (w *Window) Cut() {
C.GalliumWindowCut(w.c)
}

// Copy copies the current text selection to the pasteboard
func (w *Window) Copy() {
C.GalliumWindowCopy(w.c)
}

// Paste pastes from the pasteboard
func (w *Window) Paste() {
C.GalliumWindowPaste(w.c)
}

// PasteAndMatchStyle pastes from the pasteboard, matching style to the current element
func (w *Window) PasteAndMatchStyle() {
C.GalliumWindowPasteAndMatchStyle(w.c)
}

// Delete deletes the current text selection
func (w *Window) Delete() {
C.GalliumWindowDelete(w.c)
}

// SelectAll selects all text in the current element
func (w *Window) SelectAll() {
C.GalliumWindowSelectAll(w.c)
}

// Unselect unselects any text selection
func (w *Window) Unselect() {
C.GalliumWindowUnselect(w.c)
}

// OpenDevTools opens the developer tools for this window.
func (w *Window) OpenDevTools() {
C.GalliumWindowOpenDevTools(w.c)
Expand Down
3 changes: 1 addition & 2 deletions cocoa.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ static inline gallium_nsmenuitem_t* helper_NSMenu_AddMenuItem(
&cgo_onMenuClicked,
callbackArg);
}
*/
import "C"
import (
Expand Down Expand Up @@ -111,7 +110,7 @@ func parseShortcut(s string) (key string, modifiers int, err error) {
case "cmd":
modifiers |= int(C.GalliumCmdModifier)
case "ctrl":
modifiers |= int(C.GalliumCmdModifier)
modifiers |= int(C.GalliumCtrlModifier)
case "cmdctrl":
modifiers |= int(C.GalliumCmdOrCtrlModifier)
case "alt":
Expand Down
4 changes: 2 additions & 2 deletions dist/Gallium.framework/Versions/A/Gallium
Git LFS file not shown
27 changes: 27 additions & 0 deletions dist/include/gallium/browser.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,33 @@ GALLIUM_EXPORT void GalliumWindowClose(gallium_window_t* window);
// GalliumWindowClose miniaturizes the window
GALLIUM_EXPORT void GalliumWindowMiniaturize(gallium_window_t* window);

// GalliumWindowUndo undoes the last text editing action
GALLIUM_EXPORT void GalliumWindowUndo(gallium_window_t* window);

// GalliumWindowRedo redoes the last text editing action
GALLIUM_EXPORT void GalliumWindowRedo(gallium_window_t* window);

// GalliumWindow cuts the current text selection to the pastboard
GALLIUM_EXPORT void GalliumWindowCut(gallium_window_t* window);

// GalliumWindow copies the current text selection to the pasteboard
GALLIUM_EXPORT void GalliumWindowCopy(gallium_window_t* window);

// GalliumWindow pastes from the pasteboard
GALLIUM_EXPORT void GalliumWindowPaste(gallium_window_t* window);

// GalliumWindow pastes from the pasteboard, matching style to the current element
GALLIUM_EXPORT void GalliumWindowPasteAndMatchStyle(gallium_window_t* window);

// GalliumWindow deletes the current text selection
GALLIUM_EXPORT void GalliumWindowDelete(gallium_window_t* window);

// GalliumWindow selects all text in the current element
GALLIUM_EXPORT void GalliumWindowSelectAll(gallium_window_t* window);

// GalliumWindowUnselect unselects any text selection
GALLIUM_EXPORT void GalliumWindowUnselect(gallium_window_t* window);

// GalliumWindowOpenDevTools opens the developer tools for the given window
GALLIUM_EXPORT void GalliumWindowOpenDevTools(gallium_window_t* window);

Expand Down

0 comments on commit aec7cef

Please sign in to comment.