-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use rc instead of sh for executing commands, and use the default DPI instead of the 0 value, since the driver doesn't send the correct DPI.
- Loading branch information
Showing
5 changed files
with
110 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
// +build !windows | ||
// +build !plan9 | ||
|
||
package actions | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package actions | ||
|
||
func getShellCmd() (cmd, args string) { | ||
return "rc", "-c" | ||
} |
5 changes: 0 additions & 5 deletions
5
issues/Keyboard-plumbing-should-include-click-attribute/Description
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
package main | ||
|
||
import ( | ||
"image" | ||
"image/draw" | ||
"sync" | ||
|
||
"github.com/driusan/de/demodel" | ||
"github.com/driusan/de/kbmap" | ||
"github.com/driusan/de/renderer" | ||
"github.com/driusan/de/viewer" | ||
"golang.org/x/exp/shiny/screen" | ||
"golang.org/x/mobile/event/size" | ||
) | ||
|
||
// dewindow encapsulates the shiny window of de. | ||
type dewindow struct { | ||
sync.Mutex | ||
screen.Window | ||
|
||
painting bool | ||
buffer screen.Buffer | ||
sz size.Event | ||
} | ||
|
||
func (w *dewindow) paint(buf *demodel.CharBuffer, viewport *viewer.Viewport) { | ||
if w.painting { | ||
return | ||
} | ||
w.realpaint(buf, viewport) | ||
} | ||
|
||
// paints buf into the viewport attached to this window | ||
func (w *dewindow) realpaint(buf *demodel.CharBuffer, viewport *viewer.Viewport) { | ||
w.Lock() | ||
defer w.Unlock() | ||
|
||
defer func() { | ||
w.painting = false | ||
}() | ||
w.painting = true | ||
|
||
if w.buffer == nil { | ||
return | ||
} | ||
dst := w.buffer.RGBA() | ||
|
||
// Fill the buffer with the window background colour before | ||
// drawing the web page on top of it. | ||
// This should logically be in the viewport code itself, but importing | ||
// kbmap to switch on the mode sentinals would result in a cyclical | ||
// import. | ||
if viewport.BackgroundMode != viewer.StableBackground { | ||
switch viewport.GetKeyboardMode() { | ||
case kbmap.InsertMode: | ||
draw.Draw(dst, dst.Bounds(), &image.Uniform{renderer.InsertBackground}, image.ZP, draw.Src) | ||
case kbmap.DeleteMode: | ||
draw.Draw(dst, dst.Bounds(), &image.Uniform{renderer.DeleteBackground}, image.ZP, draw.Src) | ||
default: | ||
draw.Draw(dst, dst.Bounds(), &image.Uniform{renderer.NormalBackground}, image.ZP, draw.Src) | ||
} | ||
} else { | ||
draw.Draw(dst, dst.Bounds(), &image.Uniform{renderer.NormalBackground}, image.ZP, draw.Src) | ||
} | ||
|
||
s := w.sz.Size() | ||
|
||
contentBounds := dst.Bounds() | ||
tagBounds := tagSize | ||
// ensure that the tag takes no more than half the window, so that the content doesn't get | ||
// drowned out by commands that output more to stderr than they should. | ||
if wHeight := s.Y; tagBounds.Max.Y > wHeight/2 { | ||
tagBounds.Max.Y = wHeight / 2 | ||
} | ||
contentBounds.Min.Y = tagBounds.Max.Y | ||
|
||
tagline.RenderInto(dst.SubImage(image.Rectangle{image.ZP, image.Point{s.X, tagBounds.Max.Y}}).(*image.RGBA), buf.Tagline, clipRectangle(w.sz, viewport)) | ||
viewport.RenderInto(dst.SubImage(image.Rectangle{image.Point{0, tagBounds.Max.Y}, s}).(*image.RGBA), buf, clipRectangle(w.sz, viewport)) | ||
|
||
w.Upload(image.Point{0, 0}, w.buffer, dst.Bounds()) | ||
w.Publish() | ||
return | ||
} | ||
|
||
func (w *dewindow) setSize(s size.Event, sc screen.Screen) error { | ||
w.Lock() | ||
defer w.Unlock() | ||
|
||
w.sz = s | ||
if w.buffer != nil { | ||
// Release the old buffer. | ||
w.buffer.Release() | ||
} | ||
|
||
sbuffer, err := sc.NewBuffer(s.Size()) | ||
w.buffer = sbuffer | ||
return err | ||
|
||
} |