Just some atom-beautify to make code look better
This commit is contained in:
parent
8c7071f8e0
commit
09168fc8ea
|
@ -2,14 +2,14 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"github.com/tombh/termbox-go"
|
||||||
"strconv"
|
"math"
|
||||||
"path/filepath"
|
|
||||||
"time"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"math"
|
"path/filepath"
|
||||||
"github.com/tombh/termbox-go"
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Import the xzoom C code that creates an X window that zooms
|
// Import the xzoom C code that creates an X window that zooms
|
||||||
|
@ -201,8 +201,8 @@ func zoom(direction string) {
|
||||||
C.magnification--
|
C.magnification--
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
C.width[C.SRC] = (C.desktop_width + C.magnification - 1) / C.magnification;
|
C.width[C.SRC] = (C.desktop_width + C.magnification - 1) / C.magnification
|
||||||
C.height[C.SRC] = (C.desktop_height + C.magnification - 1) / C.magnification;
|
C.height[C.SRC] = (C.desktop_height + C.magnification - 1) / C.magnification
|
||||||
|
|
||||||
moveViewportForZoom(oldZoom)
|
moveViewportForZoom(oldZoom)
|
||||||
keepViewportInDesktop()
|
keepViewportInDesktop()
|
||||||
|
@ -294,7 +294,6 @@ func mouseEvent() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func pan() {
|
func pan() {
|
||||||
if panNeedsSetup {
|
if panNeedsSetup {
|
||||||
panStartingX = desktopXFloat
|
panStartingX = desktopXFloat
|
||||||
|
@ -427,8 +426,8 @@ func parseInput() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run the xzoom window in a background go routine
|
// Run the xzoom window in a background go routine
|
||||||
func xzoomBackground(){
|
func xzoomBackground() {
|
||||||
go func(){
|
go func() {
|
||||||
defer close(xZoomStoppedChannel)
|
defer close(xZoomStoppedChannel)
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
|
@ -443,7 +442,7 @@ func xzoomBackground(){
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
func teardown(){
|
func teardown() {
|
||||||
termbox.Close()
|
termbox.Close()
|
||||||
close(stopXZoomChannel)
|
close(stopXZoomChannel)
|
||||||
<-xZoomStoppedChannel
|
<-xZoomStoppedChannel
|
||||||
|
|
|
@ -26,11 +26,11 @@ var _ = Describe("Mouse Input", func() {
|
||||||
setCurrentDesktopCoords()
|
setCurrentDesktopCoords()
|
||||||
})
|
})
|
||||||
|
|
||||||
AfterEach(func(){
|
AfterEach(func() {
|
||||||
termbox.Close()
|
termbox.Close()
|
||||||
})
|
})
|
||||||
|
|
||||||
Describe("Mouse position", func(){
|
Describe("Mouse position", func() {
|
||||||
It("Should work in the top left", func() {
|
It("Should work in the top left", func() {
|
||||||
curev.MouseX = 30
|
curev.MouseX = 30
|
||||||
curev.MouseY = 10
|
curev.MouseY = 10
|
||||||
|
@ -55,7 +55,7 @@ var _ = Describe("Mouse Input", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
Describe("Zooming", func() {
|
Describe("Zooming", func() {
|
||||||
BeforeEach(func(){
|
BeforeEach(func() {
|
||||||
curev.MouseX = 30
|
curev.MouseX = 30
|
||||||
curev.MouseY = 10
|
curev.MouseY = 10
|
||||||
setCurrentDesktopCoords()
|
setCurrentDesktopCoords()
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
/* scale image from SRC to DST - parameterized by type T */
|
/* scale image from SRC to DST - parameterized by type T */
|
||||||
|
|
||||||
/* get pixel address of point (x,y) in image t */
|
/* get pixel address of point (x,y) in image t */
|
||||||
#define getP(t,x,y) \
|
#define getP(t, x, y) \
|
||||||
(T *) (&ximage[t]->data[(ximage[t]->xoffset+(x))*sizeof(T) + \
|
(T *)(&ximage[t]->data[(ximage[t]->xoffset + (x)) * sizeof(T) + \
|
||||||
(y)*ximage[t]->bytes_per_line])
|
(y) * ximage[t]->bytes_per_line])
|
||||||
|
|
||||||
{
|
{
|
||||||
int i, j, k;
|
int i, j, k;
|
||||||
|
|
||||||
/* copy scaled lines from SRC to DST */
|
/* copy scaled lines from SRC to DST */
|
||||||
j = height[SRC] - 1;
|
j = height[SRC] - 1;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
T *p1;
|
T *p1;
|
||||||
T *p2;
|
T *p2;
|
||||||
|
@ -19,13 +20,17 @@
|
||||||
/* p1 point to begining of scanline j*magnification in DST */
|
/* p1 point to begining of scanline j*magnification in DST */
|
||||||
p1 = getP(DST, 0, j * magnification);
|
p1 = getP(DST, 0, j * magnification);
|
||||||
p1_save = p1;
|
p1_save = p1;
|
||||||
|
|
||||||
/* p2 point to begining of scanline j in SRC */
|
/* p2 point to begining of scanline j in SRC */
|
||||||
p2 = getP(SRC, 0, j);
|
p2 = getP(SRC, 0, j);
|
||||||
|
|
||||||
i = width[SRC];
|
i = width[SRC];
|
||||||
|
|
||||||
do {
|
do {
|
||||||
T c = *p2++;
|
T c = *p2++;
|
||||||
k = magnification; do *p1++ = c; while (--k > 0);
|
k = magnification;
|
||||||
|
|
||||||
|
do *p1++ = c; while (--k > 0);
|
||||||
} while (--i > 0);
|
} while (--i > 0);
|
||||||
|
|
||||||
/* duplicate that line as needed */
|
/* duplicate that line as needed */
|
||||||
|
@ -33,12 +38,14 @@
|
||||||
{
|
{
|
||||||
/* p1 point to begining of scanline j*magnification in DST */
|
/* p1 point to begining of scanline j*magnification in DST */
|
||||||
p1 = p1_save;
|
p1 = p1_save;
|
||||||
|
|
||||||
/* p2 points to begining of next line */
|
/* p2 points to begining of next line */
|
||||||
p2 = p1;
|
p2 = p1;
|
||||||
p2step = ximage[DST]->bytes_per_line / sizeof(T);
|
p2step = ximage[DST]->bytes_per_line / sizeof(T);
|
||||||
|
|
||||||
i = width[DST] * sizeof(T);
|
i = width[DST] * sizeof(T);
|
||||||
k = magnification - 1;
|
k = magnification - 1;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
p2 += p2step;
|
p2 += p2step;
|
||||||
memcpy(p2, p1, i);
|
memcpy(p2, p1, i);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
This code largely comes from Itai Nahshon's xzoom, see:
|
This code largely comes from Itai Nahshon's xzoom, see:
|
||||||
http://git.r-36.net/xzoom
|
http://git.r-36.net/xzoom
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
Loading…
Reference in a new issue