Example #1
0
func (B *Imp) Edit(i *uint) {
	//
	xi, yi := scr.MousePosGr()
	x, y := xi, yi
	if scr.UnderMouseGr(int(B.x0), int(B.y0), int(B.x0+B.width-1), int(B.y0+B.height-1), 0) {
		if B.horizontal {
			B.value = (uint(int(x)-int(B.x0)) * B.max) / (B.width - 1)
		} else {
			B.value = B.max - (uint(int(y)-int(B.y0))*B.max)/(B.height-1)
		}
	}
	*i = B.value
	B.Write()
}
Example #2
0
func copyMarked() {
	//
	if !figures.ExPred(func(a Any) bool { return a.(*fig2.Imp).Marked() }, true) {
		return
	}
	figures.Filter(copiedFigures, func(a Any) bool { return a.(*fig2.Imp).Marked() })
	//  figures.Trav (func (a Any) { a.(*fig2.Imp).Demark() })
	copiedFigures.Trav(func(a Any) { a.(*fig2.Imp).Mark(false) })
	x, y := figures.Get().(*fig2.Imp).Pos()
	xm, ym := scr.MousePosGr()
	copiedFigures.Trav(func(a Any) { a.(*fig2.Imp).Move(xm-x, ym-y) })
	copiedFigures.Trav(func(a Any) { a.(*fig2.Imp).Write() })
	figures.Join(copiedFigures)
}
Example #3
0
func (x *Imp) UnterMaus() bool {
	//
	xm, ym := scr.MousePosGr()
	xx, yy := scale.Scale(x.breite, x.länge)
	dx, dy := xm-xx, ym-yy
	if dx < 0 {
		dx = -dx
	}
	if dy < 0 {
		dy = -dy
	}
	const d = 8 // pixel
	return dx <= d && dy <= d
}
Example #4
0
func (f *Imp) uM() uint {
	//
	const (
		r = 4
		t = 4
	)
	a, b := scr.MousePosGr()
	n := uint(len(f.x))
	for i := uint(0); i < n; i++ {
		if scr.OnCircle(f.x[i], f.y[i], r, a, b, t) {
			return uint(i)
		}
	}
	return n + 1 // ?
}
Example #5
0
func colour(FZ, B uint) col.Colour {
	//
	MausAn := scr.MouseCursorOn()
	if !MausAn {
		scr.MouseCursor(true)
	}
	xm, ym := scr.MousePosGr()
	X, Y = uint(xm), uint(ym)
	M := FZ * B / 2
	if X >= scr.NY()-M {
		X = scr.NX() - M
	}
	if X >= M {
		X -= M
	} else {
		X = 0
	}
	if Y >= H {
		Y -= H
	} else {
		Y = 0
	}
	scr.SaveGr(X, Y, X+2*FZ*B, Y+H)
	write(FZ, B, X, Y)
	clicked := false
	C := col.ScreenF
loop:
	for {
		scr.MouseCursor(true)
		K, _ := kbd.Command()
		switch K {
		case kbd.Esc, kbd.Back, kbd.There, kbd.This:
			break loop
		case kbd.Here:
			define(FZ, B, &C)
			clicked = true
		case kbd.Hither:
			if clicked {
				break loop
			}
		}
	}
	scr.RestoreGr(X, Y, X+2*FZ*B, Y+H)
	if !MausAn {
		scr.MouseCursor(false)
	}
	return C
}
Example #6
0
func define(FZ, B uint, C *col.Colour) {
	//
	xi, yi := scr.MousePosGr()
	x, y := uint(xi), uint(yi)
	x -= X
	x = x / B
	if x < FZ && Y <= y && y < Y+H {
		if FZ == 16 {
			*C = pattern16[x]
		} else {
			*C = pattern[x]
		}
		scr.Colour(*C)
	} else {
		*C = col.ScreenB
	}
}
Example #7
0
func (x *Imp) Locate() {
	//
	r := x.Radius()
	xm, ym := scr.MousePosGr()
	x.x, x.y = uint(xm), uint(ym)
	if x.x < r {
		x.x = r
	}
	if x.x+r >= scr.NY() {
		x.x = scr.NX() - 1 - r
	}
	if x.y < r {
		x.y = r
	}
	if x.y+r >= scr.NY() {
		x.y = scr.NY() - 1 - r
	}
}
Example #8
0
func main() {
	//
	if !scr.MouseEx() {
		return
	}
	var symbol [Nfigure]byte
	symbol[line] = 'S'      // "Strecke"
	symbol[rectangle] = 'R' // "Rechteck"
	symbol[circle] = 'K'    // "Kreis"
	symbol[ellipse] = 'E'   // "Ellipse"
	X, Y := 0, 0
	X1, Y1 := scr.NX(), scr.NY()
	//  Farbe, Papier:= col.LightWhite, col.Black
	Farbe, Papier := col.Black, col.LightWhite
	col.ScreenF, col.ScreenB = Farbe, Papier
	scr.Cls()
	paintColour := Farbe
	scr.Colour(paintColour)
	//  Staerke = 3
	bx := box.New()
	bx.Wd(20)
	bx.Colours(Papier, Farbe)
	Name := env.Par(1)
	if str.Empty(Name) {
		Name = "temp"
	}
	scr.Save(0, 0, 20, 1)
	for {
		bx.Edit(&Name, 0, 0)
		if !str.Empty(Name) {
			str.RemSpaces(&Name)
			break
		}
	}
	scr.Restore(0, 0, 20, 1)
	img.Get(Name, uint(X), uint(Y))
	scr.MouseCursor(true)
	Figur := figure(rectangle)
	var x, y, x0, y0 int
loop:
	for {
		scr.Colour(paintColour)
		Zeichen, Kommando, T := kbd.Read()
		switch Kommando {
		case kbd.None:
			x, y = scr.MousePosGr()
			scr.SwitchTransparence(true)
			scr.Write1Gr(Zeichen, x, y-int(scr.NY1()))
			//    scr.WarpMouse (x + scr.NX1(), y)
		case kbd.Esc:
			break loop
		case kbd.Back:
			switch T {
			case 0:
				x, y = scr.MousePosGr()
				x -= int(scr.NX1())
				scr.Colour(Papier)
				scr.Write1Gr(' ', x, y-int(scr.NY1()))
				//        scr.RectangleFull (x, y - scr.NY1(), x + scr.NX1(), y)
				//        scr.WarpMouseGr (x, y)
				scr.Colour(paintColour)
			default:
				scr.Cls()
			}
			/*
			   case kbd.Ins:
			     img.Write (X, Y, X1, Y1 - 16, Name)
			     box.Edit (Feld, Name, scr.Zeilenzahl () - 1, 0)
			     img.Get (X, Y, Name)
			*/
		case kbd.Help:
			paintColour = sel.Colour()
			//    case kbd.LookFor:
			//      Staerke = Strichstaerken.Staerke()
		case kbd.Enter:
			if T > 0 {
				x0, y0 = scr.MousePosGr()
				//        scr.Fill1 (x0, y0)
			}
		case kbd.PrintScr:
			img.Print(uint(X), uint(Y), X1, Y1-16)
		case kbd.Tab:
			if T == 0 {
				if Figur+1 < Nfigure {
					Figur++
				} else {
					Figur = figure(0)
				}
			} else {
				if Figur > 0 {
					Figur--
				} else {
					Figur = figure(Nfigure - 1)
				}
			}
			scr.Colours(col.White, Papier)
			scr.Write1(symbol[Figur], scr.NY()-1, 0)
		case kbd.Here:
			x0, y0 = scr.MousePosGr()
			scr.CircleFull(x0, y0, 3/2)
		case kbd.Pull:
			x, y = scr.MousePosGr()
			scr.Line(x0, y0, x, y)
			x0, y0 = x, y
		case kbd.Hither:
			x, y = scr.MousePosGr()
			scr.Line(x0, y0, x, y)
		case kbd.There:
			x0, y0 = scr.MousePosGr()
			x, y = x0, y0
		case kbd.Push:
			paint(Figur, inv, x0, y0, x, y)
			x, y = scr.MousePosGr()
			paint(Figur, inv, x0, y0, x, y)
		case kbd.Thither:
			paint(Figur, inv, x0, y0, x, y)
			//      scr.Colour (paintColour)
			x, y = scr.MousePosGr()
			paint(Figur, border, x0, y0, x, y)
			x0, y0 = x, y
		case kbd.This:
			x0, y0 = scr.MousePosGr()
			x, y = x0, y0
		case kbd.Move:
			scr.LineInv(x0, y0, x, y)
			x, y = scr.MousePosGr()
			scr.LineInv(x0, y0, x, y)
		case kbd.Thus:
			scr.LineInv(x0, y0, x, y)
			x, y = scr.MousePosGr()
			scr.Line(x0, y0, x, y)
			x0, y0 = x, y
		}
	}
	scr.Save(0, 0, 20, 1)
	for {
		bx.Edit(&Name, 0, 0)
		// TODO make sure, that "Name" is x{x|y} where x is letter, y is digit
		if !str.Empty(Name) {
			str.RemSpaces(&Name)
			break
		}
	}
	scr.Restore(0, 0, 20, 1)
	img.Put(Name, uint(X), uint(Y), X1, Y1)
	ker.Terminate()
}
Example #9
0
func Edit() {
	//
	Write()
	errh.Hint("Graph editieren: Hilfe per F1, fertig: Abbruchtaste (Esc)")
	scr.MouseCursor(true)
loop:
	for {
		K, i := kbd.Command()
		//    errh.DelHint()
		switch K {
		case kbd.Esc:
			break loop
		case kbd.Help:
			errh.WriteHelp(help)
		case kbd.Here: // neue Ecke oder Namen vorhandener Ecke ändern:
			if Graph.ExPred(node.UnderMouse) {
				if i > 0 {
					Ecke = Graph.Get().(*node.Imp) // aktuell: Ecke
					Ecke.Edit()
					Graph.Put(Ecke)
				}
			} else {
				Ecke.Clr()
				Ecke.Locate()
				Ecke.Write(true, true)
				Ecke.Edit()
				Graph.Ins(Ecke)
			}
		case kbd.Del: // Ecke entfernen
			if Graph.ExPred(node.UnderMouse) {
				wr(false, false)
				Graph.Del()
			}
		case kbd.There: // Ecke verschieben
			switch i {
			case 0:
				if Graph.ExPred(node.UnderMouse) {
					wr(false, false)
					wr(false, true)
				loop1:
					for {
						geschoben := false
						kk, _ := kbd.Command()
						switch kk {
						case kbd.Push:
							geschoben = true
							wr(false, true)
							Ecke = Graph.Get().(*node.Imp)
							Ecke.Locate()
							Graph.Put(Ecke)
							wr(false, true)
						case kbd.Thither:
							wr(false, true)
							if geschoben {
								Graph.Put(Ecke)
							}
							wr(true, false)
							break loop1
						}
					}
				}
			default: // Ecke entfernen
				if Graph.ExPred(node.UnderMouse) {
					wr(false, false)
					Graph.Del()
				}
			}
		case kbd.This: // Ecken verbinden / Kante entfernen:
			x0, y0 := scr.MousePosGr()
			x, y := x0, y0
			if Graph.ExPred(node.UnderMouse) {
				Ecke = Graph.Get().(*node.Imp) // Ecke aktuell
				Graph.Position(true)           // Ecke auch postaktuell
			loop2:
				for {
					kk, _ := kbd.Command()
					switch kk {
					case kbd.Move:
						scr.LineInv(x0, y0, x, y)
						x, y = scr.MousePosGr()
						scr.LineInv(x0, y0, x, y)
					case kbd.Thus:
						scr.LineInv(x0, y0, x, y)
						if Graph.ExPred(node.UnderMouse) {
							Ecke1 = Graph.Get().(*node.Imp) // Ecke1 aktuell
							g := Graph.Directed()
							if g {
								Kante.Write(Ecke, Ecke1, g, false, false)
							}
							Kante.Edit(Ecke, Ecke1, g)
							Graph.Edge1(Kante)
							if Kante.Val() == 0 {
								Kante.Write(Ecke, Ecke1, g, false, false)
								Graph.Del1()
							}
						}
						break loop2
					}
				}
			}
		case kbd.PrintScr:
			//      img.Write (".tmp.Graph", 0, 0, scr.NX(), scr.NY())
			//      img.Print()
		}
	}
	errh.DelHint()
}
Example #10
0
func (f *Imp) Edit() {
	//
	if f.Empty() {
		scr.Colour(f.colour)
		f.x, f.y = make([]int, 1), make([]int, 1)
		f.x[0], f.y[0] = scr.MousePosGr()
		switch f.sort {
		case Pointset, Segments, Polygon, Curve:
			f.editN()
		case InfLine, Rectangle, Circle, Ellipse:
			f.edit1()
		case Text:
			f.editText()
		case Image:
			//      ALLOCATE (Imageptr, Groesse())
			//      img.Get (tx [...], Imageptr)
			f.editImage()
		}
		if f.x == nil {
			f.Clr()
		}
	} else {
		n := uint(len(f.x))
		errh.Error("Figur hat Länge", n)
		switch f.sort {
		case Text:
			f.editText()
		case Image:
			f.editImage()
		default:
			f.Erase()
			f.Invert()
			if true { // f.sort == Curve {
				for i := uint(0); i < n; i++ {
					f.mark(i)
				}
			}
			i := f.uM()
			f.x[i], f.y[i] = scr.MousePosGr()
		loop:
			for {
				scr.MouseCursor(true)
				c, _ := kbd.Command()
				switch c {
				case kbd.Esc:
					break loop
				case kbd.Enter, kbd.Tab, kbd.LookFor:
					f.colour = sel.Colour()
				case kbd.Here:
					break loop
				case kbd.There:
					i = f.uM()
				case kbd.Push, kbd.Thither:
					if i < n {
						f.Invert()
						f.mark(i)
						f.x[i], f.y[i] = scr.MousePosGr()
						f.mark(i)
						f.Invert()
						if c == kbd.Thither {
							i = n
						} // ? ? ?
					}
				case kbd.This:
					switch f.sort {
					case Pointset, Segments, Polygon, Curve:
						if f.x == nil {
							f.Clr()
						} else {
							for i := uint(0); i < n; i++ {
								f.mark(i)
							}
							f.Erase()
							n-- // ? ? ?
							f.Invert()
							for i := uint(0); i < n; i++ {
								f.mark(i)
							}
						}
					}
				}
				errh.Hint(c.String())
			}
			f.Invert()
			if true { // sort != Text {
				for i := uint(0); i < n; i++ {
					f.mark(i)
				}
			}
			f.Write()
		}
	}
}
Example #11
0
func (f *Imp) edit1() {
	//
	x0 := make([]int, 2)
	x0[0] = f.x[0]
	f.x = x0
	y0 := make([]int, 2)
	y0[0] = f.y[0]
	f.y = y0
	switch f.sort {
	case InfLine:
		if f.x[0] == 0 {
			f.x[1] = 1
		} else {
			f.x[1] = f.x[0] - 1
		}
		f.y[1] = f.y[0]
	case Rectangle:
		f.x[1] = f.x[0]
		f.y[1] = f.y[0]
	case Circle, Ellipse:
		f.x[1] = 0
		f.y[1] = 0
	default:
		return
	}
	//    scr.PointInv (f.x[0], f.y[0])
	f.invert1()
loop:
	for {
		K, T := kbd.Command()
		switch K {
		case kbd.Pull, kbd.Hither:
			f.invert1()
			f.x[1], f.y[1] = scr.MousePosGr()
			switch f.sort {
			case InfLine:
				if f.x[1] == f.x[0] && f.y[1] == f.y[0] {
					if f.x[0] == 0 {
						f.x[1] = 1
					} else {
						f.x[1] = f.x[0] - 1
					}
				}
			case Rectangle:

			case Circle, Ellipse:
				if f.x[1] > f.x[0] {
					f.x[1] -= f.x[0]
				} else {
					f.x[1] = f.x[0] - f.x[1]
				}
				if f.y[1] > f.y[0] {
					f.y[1] -= f.y[0]
				} else {
					f.y[1] = f.y[0] - f.y[1]
				}
				if f.sort == Circle {
					if f.x[1] > f.y[1] {
						f.y[1] = f.x[1]
					} else {
						f.x[1] = f.y[1]
					}
				}
			default:
				// stop (Modul, 1)
			}
			f.invert1()
			if K == kbd.Hither {
				f.filled = T > 0
				break loop
			}
		}
	}
	switch f.sort {
	case InfLine:
		scr.InfLine(f.x[0], f.y[0], f.x[1], f.y[1])
	case Rectangle:
		if f.filled {
			scr.RectangleFull(f.x[0], f.y[0], f.x[1], f.y[1])
		} else {
			scr.Rectangle(f.x[0], f.y[0], f.x[1], f.y[1])
		}
	case Circle, Ellipse:
		if f.filled {
			scr.EllipseFull(f.x[0], f.y[0], uint(f.x[1]), uint(f.y[1]))
		} else {
			scr.Ellipse(f.x[0], f.y[0], uint(f.x[1]), uint(f.y[1]))
		}
	}
}
Example #12
0
func (f *Imp) editN() {
	//
	switch f.sort {
	case Pointset, Segments, Polygon, Curve:
	default:
		return
	}
	x0 := make([]int, 2)
	x0[0] = f.x[0]
	f.x = x0
	y0 := make([]int, 2)
	y0[0] = f.y[0]
	f.y = y0
	f.x[1], f.y[1] = scr.MousePosGr()
	f.invertN()
	var (
		K kbd.Comm
		T uint
	)
loop:
	for {
		K, T = kbd.Command()
		scr.MouseCursor(true)
		n := uint(len(f.x))
		switch K {
		case kbd.Esc:
			break loop
		case kbd.Go,
			kbd.Here, kbd.Pull, kbd.Hither,
			kbd.There, kbd.Push, kbd.Thither,
			kbd.This: // kbd.ToThis:
			f.invertN()
			//      if f.sort == Curve {
			//        if n == scr.MaxBezierdegree { break loop }
			//      }
			if f.sort == Pointset {
				if K != kbd.Go {
					n++
				}
			} else {
				if K == kbd.Here { // TODO Curve: missing
					n++
				}
			}
			if K == kbd.This {
				n := len(f.x)
				if n == 0 {
					break loop
				} else { // TODO
					n--
					if n == 0 {
						break loop
						//          } else {
						//            x0 = make ([]int, n); copy (x0, f.x[:n]); f.x = x0
						//            y0 = make ([]int, n); copy (y0, f.y[:n]); f.y = y0
					}
				}
			}
			if n > uint(len(f.x)) {
				x0 = make([]int, n)
				copy(x0, f.x)
				f.x = x0
				y0 = make([]int, n)
				copy(y0, f.y)
				f.y = y0
			}
			f.x[n-1], f.y[n-1] = scr.MousePosGr()
			f.invertN()
			if f.sort == Pointset {
				if K == kbd.Hither {
					break loop
				}
			} else {
				if K == kbd.Thither {
					break loop
				}
			}
		}
	}
	if f.x == nil {
		f.Clr()
		return
	}
	scr.Colour(f.colour)
	switch f.sort {
	case Pointset:
		scr.Pointset(f.x, f.y)
	case Segments:
		scr.Segments(f.x, f.y)
	case Polygon:
		scr.Polygon(f.x, f.y)
		f.filled = T > 0 && f.convex()
		if f.filled {
			//      scr.PolygonFull (f.x, f.y) // not yet implemented
		}
	case Curve:
		scr.Curve(f.x, f.y)
		f.filled = T > 0
		if f.filled {
			n := len(f.x) - 1
			scr.CircleFull(f.x[n], f.y[n], 4)
		}
	}
}
Example #13
0
func (f *Imp) UnderMouse(t uint) bool {
	//
	a, b := scr.MousePosGr()
	return f.On(a, b, t)
}
Example #14
0
func edit() {
	//
	var d uint
	c := kbd.LastCommand(&d)
	if d > 2 {
		d = 2
	}
	switch c {
	case kbd.Back:
		if width < maxWidth {
			w := width * mm[d]
			if w > maxWidth {
				w = maxWidth
			}
			dw := (w - width) / 2
			x0, y0 = x0-dw, y0-dw/scr.Proportion()
			width = w
		} else { // überschritten
			x0, y0 = xMin, yMin
			width = maxWidth
		}
		height = width / scr.Proportion()
		mX, mY = nX/width, nY/height
	case kbd.Enter:
		if width > maxWidth/maxMag {
			w := width / mm[d]
			if w < maxWidth/maxMag {
				w = maxWidth / maxMag
			}
			dw := (w - width) / 2
			x0, y0 = x0-dw, y0-dw/scr.Proportion()
			width = w
			height = width / scr.Proportion()
			mX, mY = nX/width, nY/height
		}
	case kbd.Left:
		if x0 >= xMin {
			x0 = x0 - width/nn[d]
		}
	case kbd.Right:
		if x0+width <= xMin+maxWidth {
			x0 = x0 + width/nn[d]
		}
		// TODO: Rollrad von Maus einbauen - die sendet Up/Down
	case kbd.Up:
		if y0+height < yMin+maxHeight {
			y0 = y0 + width/nn[d]
		}
	case kbd.Down:
		if y0 >= yMin {
			y0 = y0 - width/nn[d]
		}
	case kbd.This:
		x, y := scr.MousePosGr()
		y = int(scr.NY()) - y
		x0 = x0 + float64(x)/mX - width/2
		y0 = y0 + float64(y)/mY - height/2
	case kbd.There:
		x, y := scr.MousePosGr()
		xt, yt = float64(x), float64(int(scr.NY())-y)
	case kbd.Push, kbd.Thither:
		x, y := scr.MousePosGr()
		x0 = x0 - (float64(x)-xt)/mX
		y0 = y0 - (float64(int(scr.NY())-y)-yt)/mY
		xt, yt = float64(x), float64(int(scr.NY())-y)
	}
	if x0 < xMin {
		x0 = xMin
	}
	if x0+width > xMin+maxWidth {
		x0 = xMin + maxWidth - width
	}
	if y0 < yMin {
		y0 = yMin
	}
	if y0+height >= yMin+maxHeight {
		y0 = yMin + maxHeight - height
	}
}
Example #15
0
func main() {
	//
	h := [...]string{
		// 0         1         2         3         4         5         6         7
		// 012345678901234567890123456789012345678901234567890123456789012345678901234567
		"   Art (Farbe) für neue Figur auswählen: (Umschalt- +) Leer- oder Rolltaste   ",
		//  "                 Schriftgröße auswählen: Alt- + Leer- oder Rolltaste          ",
		"                    neue Figur erzeugen: linke Maustaste,                     ",
		"                                         Streckenzüge, Polygone und Kurven    ",
		"                                         mit rechter Maustaste abschließen,   ",
		"                                         Texteingabe mit Eingabetaste beenden ",
		"                           Figur ändern: Alt- + linke Maustaste, die 'Punkte' ",
		"                                         mit rechter Maustaste verschieben,   ",
		"                                         mit linker Maustaste abschließen     ",
		"                           Figur färben: Umschalt-, Alt- + linke Maustaste    ",
		"             (alle) Figur(en) markieren: (Umschalt- +) F5-Taste oder          ",
		"                                         (Alt- +) mittlere Maustaste          ",
		"          (alle) Figur(en) entmarkieren: (Umschalt- +) F6-Taste oder          ",
		"                                         Umschalt- + (Alt- +) mittl. Maustaste",
		"           markierte Figur(en) kopieren: Umschalt- + linke Maustaste          ",
		"      (markierte) Figur(en) verschieben: (Umschalt- +) rechte Maustaste       ",
		"          (markierte) Figur(en) löschen: (Umschalt- +) Entfernungtaste oder   ",
		"                                         (Umschalt-,) Alt- + rechte Maustaste ",
		"     letzte gelöschte Figur zurückholen: Rücktaste (<-)                       ",
		"          letzte erzeugte Figur löschen: Umschalt- + Rücktaste (<-)           ",
		"letzte gelöschte mark. Fig. zurückholen: Alt- + Rücktaste (<-)                ",
		"Hintergrundfarbe umschalten (auswählen): (Umschalt- +) F4-Taste               ",
		" Figuren aus eBoard holen und markieren: F7-Taste                             ",
		"    markierte Figuren in eBoard ablegen: F8-Taste                             ",
		"                      eBoard ausdrucken: Drucktaste                           ",
		"                           ePen beenden: Abbruchtaste (Esc)                   ",
		"                                                                              ",
		"                  Steuerungstaste (Strg) wirkt wie Umschalttaste              "}
	help := make([]string, len(h))
	for i := 0; i < len(h); i++ {
		str.Set(&help[i], h[i])
	}
	scr.Switch(scr.SXGA)
	actColour = col.ScreenF
	paperColour = col.ScreenB
	//  fo = scr.Normal
	figure = fig2.New()
	newFigure := fig2.New()
	newFigure.SetColour(actColour)
	figures, copiedFigures, image = seq.New(newFigure), seq.New(newFigure), seq.New(newFigure)
	cuttedFigures, depot = seq.New(newFigure), seq.New(newFigure)
	stack = stk.New(newFigure)
	name, filename := names()
	if filename == "" {
		return
	}
	origname := filename
	load(figures, filename)
	//  extract (paperColour)
	write()
	var x0, y0 int // kbd.Push
	var movable bool
	var Schub int
loop:
	for {
		scr.MouseCursor(true)
		//    control(); write()
		c, cmd, d := kbd.Read()
		if cmd == kbd.None {
			switch c {
			case ' ':
				cmd = kbd.Roll
			}
		}
		xm, ym := scr.MousePosGr()
		switch d {
		case 0:
			Schub = 8
		case 1:
			Schub = int(scr.NY() / 40)
		default:
			Schub = int(scr.NX() / 8)
		}
		switch cmd {
		case kbd.Esc:
			break loop
		case kbd.Enter:
			// actualize ?
		case kbd.Back:
			switch d {
			case 0:
				ins(top())
			case 1:
				delLast()
			default:
				getMarked()
			}
		case kbd.Left:
			kick(spc.Right, Schub)
		case kbd.Right:
			Schub = -Schub
			kick(spc.Right, Schub)
		case kbd.Up:
			kick(spc.Top, Schub)
		case kbd.Down:
			Schub = -Schub
			kick(spc.Top, Schub)
		case kbd.Del:
			switch d {
			case 0:
				if deleted(xm, ym) {
					push()
				}
			default:
				delMarked()
			}
		case kbd.Tab:
			// free for use
		case kbd.Help:
			scr.SwitchFontsize(font.Normal)
			errh.WriteHelp(help)
		case kbd.LookFor:
			// wird für die Auswahl des eBoards verwendet - NEIN, sondern:
			load(figures, filename)
			write()
		case kbd.Act:
			//      inject (paperColour)
			store(figures, filename)
		case kbd.Cfg:
			paperColour = sel.Colour()
			bgColour(paperColour)
		case kbd.Mark:
			switch d {
			case 0:
				mark(xm, ym, true)
			case 1:
				markAll(true)
			default:
				showMarked()
			}
		case kbd.Demark:
			switch d {
			case 0:
				mark(xm, ym, false)
			case 1:
				markAll(false)
			default:
				showMarked()
			}
		case kbd.Deposit:
			writeMarked()
		case kbd.Paste:
			readMarked()
		case kbd.PrintScr:
			print(name)
		case kbd.Roll:
			switch d {
			case 0:
				newFigure.Select()
			case 1:
				actColour = sel.Colour()
				newFigure.SetColour(actColour)
			case 2:
				scr.SwitchFontsize(font.Normal)
				//        fo = sel.Size (actColour)
				//        newFigure.SetFont (fo)
			}
		case kbd.Here:
			switch d {
			case 0:
				generate(newFigure)
			case 1:
				copyMarked()
			case 2:
				change(xm, ym)
			case 3:
				setColours(xm, ym, actColour)
			}
		case kbd.There:
			movable = underMouse(uint(xm), uint(ym)) && d <= 1
			x0, y0 = xm, ym // kbd.Push
			switch d {
			case 0:
				if movable {
					cut(xm, ym)
				}
			case 1:
				if movable {
					cutMarked()
				}
			case 2:
				if deleted(xm, ym) {
					push()
				}
			default:
				delMarked()
				write()
			}
		case kbd.Push:
			if movable {
				switch d {
				case 0:
					move(xm-x0, ym-y0)
				case 1:
					moveMarked(xm-x0, ym-y0)
				}
				x0, y0 = scr.MousePosGr()
			}
		case kbd.Thither:
			if movable {
				switch d {
				case 0:
					join()
				case 1:
					joinMarked()
				}
			}
		case kbd.This:
			switch d {
			case 0:
				mark(xm, ym, true)
			case 1:
				mark(xm, ym, false)
			case 2:
				markAll(true)
			case 3:
				markAll(false)
			}
			invMarked()
		case kbd.Thus:
			invMarked()
		}
	}
	markAll(false)
	_, filename = names()
	if filename == "" {
		filename = origname
	}
	//  inject (paperColour)
	store(figures, filename) // -> Terminieren
	ker.Terminate()
}
Example #16
0
func select_(write WritingCol, n, h, w uint, i *uint, l, c uint, f, b col.Colour) {
	//
	if n == 0 {
		ker.Stop(pack, 1)
	}
	if n == 1 {
		*i = 0
		return
	}
	if h == 0 {
		ker.Stop(pack, 2)
	}
	if h > n {
		h = n
	}
	if w == 0 {
		w = scr.NColumns()
	}
	if w > scr.NColumns() {
		w = scr.NColumns()
	}
	if c+w > scr.NColumns() {
		c = scr.NColumns() - w
	}
	// so, dass letzte Zeile frei bleibt
	if l+h >= scr.NLines() {
		h = scr.NLines() - l - 1
	}
	if *i >= n {
		*i = n - 1
	}
	MouseOn := scr.MouseCursorOn()
	var x, y int
	if MouseOn {
		scr.MouseCursor(false)
		x, y = scr.MousePosGr()
	}
	scr.WarpMouse(l+*i, c)
	scr.Save(l, c, w, h)
	i0, n0 := uint(0), uint(0)
	if *i == 0 {
		n0 = 1
	} // else { n0 = 0 }
	neu := true
loop:
	for {
		if *i < i0 {
			i0 = *i
			neu = true
		} else if *i > i0+h-1 {
			i0 = *i - (h - 1)
			neu = true
		} else {
			neu = *i != n0
		}
		if neu {
			neu = false
			var cF, cB col.Colour
			for j := uint(0); j < h; j++ {
				if i0+j == *i {
					cF, cB = f, b
				} else {
					cF, cB = b, f
				}
				write(i0+j, l+j, c, cF, cB)
			}
		}
		n0 = *i
		C, d := kbd.Command()
		switch C {
		case kbd.Esc, kbd.Thither:
			*i = n
			break loop
		case kbd.Enter, kbd.Hither:
			break loop
		case kbd.Left, kbd.Up:
			if d == 0 {
				if *i > 0 {
					*i--
				}
			} else {
				if *i >= 10 {
					*i -= 10
				}
			}
		case kbd.Right, kbd.Down:
			if d == 0 {
				if *i+1 < n {
					*i++
				}
			} else {
				if *i+10 < n {
					*i += 10
				}
			}
		case kbd.Pos1:
			*i = 0
		case kbd.End:
			*i = n - 1
		case kbd.Go:
			_, yM := scr.MousePosGr()
			if uint(yM) <= l*scr.NY1()+scr.NY1()/2 {
				if *i > 0 {
					*i--
				}
			} else if uint(yM) >= (l+h)*scr.NY1() {
				if *i < n-1 {
					*i++
				}
			} else {
				*i = i0 + uint(yM)/scr.NY1() - l
			}
			/*
			   case kbd.Help:
			     errh.Hint (errh.zumAuswaehlen)
			     kbd.Wait (true)
			     errh.DelHint()
			*/
		}
	}
	scr.Restore(l, c, w, h)
	if MouseOn {
		scr.MouseCursor(true)
		scr.WarpMouseGr(x, y)
	}
}