summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-06-10 14:33:48 -0400
committerPietro Gagliardi <[email protected]>2014-06-10 14:33:48 -0400
commit66f9f13ca2e4b3d45a9bf14aa06967edf21a50d6 (patch)
tree5b76540e0d7a4b8691811e5654f4f7b8baeb6260
parenta9a07c5cc89c2cf7a17516ff8430a760ab9f6cb4 (diff)
More go fmt.
-rw-r--r--events_notdarwin.go144
-rw-r--r--grid.go34
2 files changed, 89 insertions, 89 deletions
diff --git a/events_notdarwin.go b/events_notdarwin.go
index 3401fc4..be9515a 100644
--- a/events_notdarwin.go
+++ b/events_notdarwin.go
@@ -24,32 +24,32 @@ TODO - technically a GDK_BUTTON_3PRESS is detected in half the time as a GDK_BUT
// the zero value is a reset clickCounter ready for use
// it doesn't matter that all the non-count fields are zero: the first click will fail the curButton test straightaway, so it'll return 1 and set the rest of the structure accordingly
type clickCounter struct {
- curButton uint
- rect image.Rectangle
- prevTime uintptr
- count uint
+ curButton uint
+ rect image.Rectangle
+ prevTime uintptr
+ count uint
}
// x, y, xdist, ydist, and c.rect must have the same units
// so must time, maxTime, and c.prevTime
func (c *clickCounter) click(button uint, x int, y int, time uintptr, maxTime uintptr, xdist int, ydist int) uint {
- if button != c.curButton { // different button; start over
+ if button != c.curButton { // different button; start over
c.count = 0
}
- if !image.Pt(x, y).In(c.rect) { // not in the allowed region for a double-click; don't count
+ if !image.Pt(x, y).In(c.rect) { // not in the allowed region for a double-click; don't count
c.count = 0
}
- if (time - c.prevTime) > maxTime { // too slow; don't count
+ if (time - c.prevTime) > maxTime { // too slow; don't count
// note the above expression; time > (c.prevTime + maxTime) can overflow!
c.count = 0
}
- c.count++ // if either of the above ifs happened, this will make the click count 1; otherwise it will make the click count 2, 3, 4, 5, ...
+ c.count++ // if either of the above ifs happened, this will make the click count 1; otherwise it will make the click count 2, 3, 4, 5, ...
// now we need to update the internal structures for the next test
c.curButton = button
c.prevTime = time
- c.rect = image.Rect(x - xdist, y - ydist,
- x + xdist, y + ydist)
+ c.rect = image.Rect(x-xdist, y-ydist,
+ x+xdist, y+ydist)
return c.count
}
@@ -74,71 +74,71 @@ Because GTK+ keysyms may or may not obey Num Lock, we also handle the 0-9 and .
// use uintptr to be safe; the size of the scancode/hardware key code field on each platform is different
var scancodeKeys = map[uintptr]byte{
- 0x02: '1',
- 0x03: '2',
- 0x04: '3',
- 0x05: '4',
- 0x06: '5',
- 0x07: '6',
- 0x08: '7',
- 0x09: '8',
- 0x0A: '9',
- 0x0B: '0',
- 0x0C: '-',
- 0x0D: '=',
- 0x0E: '\b', // seems to be safe on GTK+; TODO safe on windows?
- 0x0F: '\t', // seems to be safe on GTK+; TODO safe on windows?
- 0x10: 'q',
- 0x11: 'w',
- 0x12: 'e',
- 0x13: 'r',
- 0x14: 't',
- 0x15: 'y',
- 0x16: 'u',
- 0x17: 'i',
- 0x18: 'o',
- 0x19: 'p',
- 0x1A: '[',
- 0x1B: ']',
- 0x1C: '\n', // seems to be safe on GTK+; TODO safe on windows?
- 0x1E: 'a',
- 0x1F: 's',
- 0x20: 'd',
- 0x21: 'f',
- 0x22: 'g',
- 0x23: 'h',
- 0x24: 'j',
- 0x25: 'k',
- 0x26: 'l',
- 0x27: ';',
- 0x28: '\'',
- 0x29: '`',
- 0x2B: '\\',
- 0x2C: 'z',
- 0x2D: 'x',
- 0x2E: 'c',
- 0x2F: 'v',
- 0x30: 'b',
- 0x31: 'n',
- 0x32: 'm',
- 0x33: ',',
- 0x34: '.',
- 0x35: '/',
- 0x39: ' ',
+ 0x02: '1',
+ 0x03: '2',
+ 0x04: '3',
+ 0x05: '4',
+ 0x06: '5',
+ 0x07: '6',
+ 0x08: '7',
+ 0x09: '8',
+ 0x0A: '9',
+ 0x0B: '0',
+ 0x0C: '-',
+ 0x0D: '=',
+ 0x0E: '\b', // seems to be safe on GTK+; TODO safe on windows?
+ 0x0F: '\t', // seems to be safe on GTK+; TODO safe on windows?
+ 0x10: 'q',
+ 0x11: 'w',
+ 0x12: 'e',
+ 0x13: 'r',
+ 0x14: 't',
+ 0x15: 'y',
+ 0x16: 'u',
+ 0x17: 'i',
+ 0x18: 'o',
+ 0x19: 'p',
+ 0x1A: '[',
+ 0x1B: ']',
+ 0x1C: '\n', // seems to be safe on GTK+; TODO safe on windows?
+ 0x1E: 'a',
+ 0x1F: 's',
+ 0x20: 'd',
+ 0x21: 'f',
+ 0x22: 'g',
+ 0x23: 'h',
+ 0x24: 'j',
+ 0x25: 'k',
+ 0x26: 'l',
+ 0x27: ';',
+ 0x28: '\'',
+ 0x29: '`',
+ 0x2B: '\\',
+ 0x2C: 'z',
+ 0x2D: 'x',
+ 0x2E: 'c',
+ 0x2F: 'v',
+ 0x30: 'b',
+ 0x31: 'n',
+ 0x32: 'm',
+ 0x33: ',',
+ 0x34: '.',
+ 0x35: '/',
+ 0x39: ' ',
}
var scancodeExtKeys = map[uintptr]ExtKey{
- 0x47: N7,
- 0x48: N8,
- 0x49: N9,
- 0x4B: N4,
- 0x4C: N5,
- 0x4D: N6,
- 0x4F: N1,
- 0x50: N2,
- 0x51: N3,
- 0x52: N0,
- 0x53: NDot,
+ 0x47: N7,
+ 0x48: N8,
+ 0x49: N9,
+ 0x4B: N4,
+ 0x4C: N5,
+ 0x4D: N6,
+ 0x4F: N1,
+ 0x50: N2,
+ 0x51: N3,
+ 0x52: N0,
+ 0x53: NDot,
}
func fromScancode(scancode uintptr) (ke KeyEvent, ok bool) {
diff --git a/grid.go b/grid.go
index b54aafe..ca2d5b9 100644
--- a/grid.go
+++ b/grid.go
@@ -16,13 +16,13 @@ import (
// A stretchy Control implicitly fills its cell.
// All cooridnates in a Grid are given in (row,column) form with (0,0) being the top-left cell.
type Grid struct {
- lock sync.Mutex
- created bool
- controls [][]Control
- filling [][]bool
- stretchyrow, stretchycol int
- widths, heights [][]int // caches to avoid reallocating each time
- rowheights, colwidths []int
+ lock sync.Mutex
+ created bool
+ controls [][]Control
+ filling [][]bool
+ stretchyrow, stretchycol int
+ widths, heights [][]int // caches to avoid reallocating each time
+ rowheights, colwidths []int
}
// NewGrid creates a new Grid with the given Controls.
@@ -34,7 +34,7 @@ type Grid struct {
// control10, control11, control12,
// control20, control21, control22)
func NewGrid(nPerRow int, controls ...Control) *Grid {
- if len(controls) % nPerRow != 0 {
+ if len(controls)%nPerRow != 0 {
panic(fmt.Errorf("incomplete grid given to NewGrid() (not enough controls to evenly divide %d controls into rows of %d controls each)", len(controls), nPerRow))
}
nRows := len(controls) / nPerRow
@@ -54,14 +54,14 @@ func NewGrid(nPerRow int, controls ...Control) *Grid {
}
}
return &Grid{
- controls: cc,
- filling: cf,
- stretchyrow: -1,
- stretchycol: -1,
- widths: cw,
- heights: ch,
- rowheights: make([]int, nRows),
- colwidths: make([]int, nPerRow),
+ controls: cc,
+ filling: cf,
+ stretchyrow: -1,
+ stretchycol: -1,
+ widths: cw,
+ heights: ch,
+ rowheights: make([]int, nRows),
+ colwidths: make([]int, nPerRow),
}
}
@@ -108,7 +108,7 @@ func (g *Grid) make(window *sysData) error {
// commit filling for the stretchy control now (see SetStretchy() above)
if g.stretchyrow != -1 && g.stretchycol != -1 {
g.filling[g.stretchyrow][g.stretchycol] = true
- } else if (g.stretchyrow == -1 && g.stretchycol != -1) || // sanity check
+ } else if (g.stretchyrow == -1 && g.stretchycol != -1) || // sanity check
(g.stretchyrow != -1 && g.stretchycol == -1) {
panic(fmt.Errorf("internal inconsistency in Grid: stretchy (%d,%d) impossible (one component, not both, is -1/no stretchy control) in Grid.make()", g.stretchyrow, g.stretchycol))
}