Пример #1
0
func wait() { // TODO -> kbd, other name
	//
loop:
	for {
		_, c, _ := kbd.Read()
		switch c {
		case kbd.Enter, kbd.Esc, kbd.Back, kbd.Here, kbd.There:
			break loop
		}
	}
}
Пример #2
0
func confirmed() bool {
	//
	pre()
	s := "Sind Sie sicher?  j(a / n(ein"
	w := NColumns()
	str.Center(&s, w)
	l := NLines() - 1
	Save(l, 0, w, 1)
	errorbox.Wd(w)
	errorbox.Write(s, l, 0)
	b, _, _ := kbd.Read()
	a := b&' ' == 'J'
	Restore(l, 0, w, 1)
	post()
	return a
}
Пример #3
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()
}
Пример #4
0
func (B *Imp) editNumber(imGraphikmodus bool, Text *string, x, y uint) {
	//
	var (
		char        byte
		cursorshape scr.Shape
		temp        uint
		firstTime   bool
	)
	B.graphical = imGraphikmodus
	//  if B.usesMouse { scr.SwitchMouseCursor (true) }
	Norm(Text, B.width)
	B.overwritable = !Empty(*Text)
	Move(Text, false)
	B.index = 0
	B.write(*Text, x, y)
	B.index = B.width
	if B.TRnumerical {
		firstTime = true
		edited = false
		// Zahl beim ersten Lesen eines Zeichens zurücksetzen, s.u.
	} else {
		edited = true
	}
	for {
		getStatus(Text)
		if B.overwritable {
			cursorshape = scr.Block
		} else {
			cursorshape = scr.Understroke
		}
		if B.graphical {
			scr.WarpGr(x+scr.NX1()*B.index, y, cursorshape)
		} else {
			scr.Warp(y/scr.NY1(), x/scr.NX1()+B.index, cursorshape) // Off
		}
		for {
			char, B.command, B.depth = kbd.Read()
			switch char {
			case 0: // Command
				break
			case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
				if B.TRnumerical {
					if firstTime {
						*Text = Clr(B.width)
						status = start
						firstTime = false
						edited = true
					}
				}
				if status == start {
					status = bp
					break
				} else if status == ee {
					if Contains(*Text, 'E', &temp) {
						if temp >= B.width-3 { // not more than 2 digits after 'E'
							break
						}
					}
				} else {
					break
				}
			case '-':
				if B.TRnumerical {
					kbd.DepositCommand(kbd.None)
					kbd.DepositByte(char)
					return
				} else {
					if Empty(*Text) || (*Text)[B.width-1] == 'E' {
						break
					}
				}
			case '.', ',':
				if status == bp {
					status = ap
					break
				}
			case 'E':
				if B.numerical || B.TRnumerical {
					if status == ap && // noch Platz für zwei Zeichen
						(*Text)[0] == space && (*Text)[1] == space {
						status = ee
						if B.numerical {
							break
						} else {
							Rem(Text, B.width-2, 2)
							*Text = *Text + "E+"
							char = 0
							break
						}
					}
				}
			case 'v':
				char = 0
				if B.TRnumerical { // || B.numerical {
					if status == bp || status == ap {
						temp = 0
						for (*Text)[temp] == space {
							temp++
						}
						if (*Text)[temp] == '-' {
							Replace(Text, temp, '+')
							break
						} else if (*Text)[temp] == '+' {
							Replace(Text, temp, '-')
							break
						} else if temp > 0 {
							Replace(Text, temp-1, '-')
							break
						}
					} else if status == ee {
						if Contains(*Text, 'E', &temp) {
							if (*Text)[temp+1] == '-' {
								Replace(Text, temp+1, '+')
								break
							} else if (*Text)[temp+1] == '+' {
								Replace(Text, temp+1, '-')
								break
							}
						}
					}
				}
			default:
				if B.TRnumerical {
					// >>> Besser wäre dies nur für den Fall, dass 'Zeichen' ein Funktionszeichen aus dem Zahlen-Modul ist:
					kbd.DepositCommand(kbd.None)
					kbd.DepositByte(char)
					return
				}
			}
		}
		if B.graphical {
			scr.WarpGr(x+scr.NX1()*B.index, y, scr.Off)
		} else {
			scr.Warp(y/scr.NY1(), x/scr.NX1()+B.index, scr.Off)
		}
		if B.command == kbd.None {
			if B.index == B.width {
				if B.overwritable {
					B.overwritable = false
				}
				if char == 0 { // change of sign or exponent
					temp = B.index
					B.index = 0
					B.write(*Text, x, y)
					B.index = temp
				} else if B.possibleNumerical(Text, x, y) {
					temp = B.index
					B.index = 0
					B.write(*Text, x, y)
					B.index = temp
					Replace(Text, B.index-1, char)
					scr.Lock()
					scr.Colours(B.cF, B.cB)
					if B.graphical {
						scr.Write1Gr(char, int(x+scr.NX1()*(B.index-1)), int(y))
					} else {
						scr.Write1(char, y/scr.NY1(), x/scr.NX1()+B.index-1)
					}
					scr.Unlock()
				} else {
				}
			} else {
				// see editText
			}
		} else {
			if B.doneNumerical(Text, x, y) {
				break
			}
		}
	}
	// if B.usesMouse { scr.SwitchMouseCursor (false) }
}
Пример #5
0
func (B *Imp) editText(imGraphikmodus bool, Text *string, x, y uint) {
	//
	var char byte
	var cursorshape scr.Shape
	B.graphical = imGraphikmodus
	// if B.usesMouse { scr.SwitchMouseCursor (true) }
	Norm(Text, B.width)
	B.overwritable = !Empty(*Text)
	B.index = 0
	B.write(*Text, x, y)
	B.overwritable = !Empty(*Text)
	B.write(*Text, x, y)
	if B.start > 0 && B.start < B.width {
		B.index = B.start
		B.start = 0
	} else {
		B.index = 0
	}
	for {
		if B.overwritable {
			cursorshape = scr.Block
		} else {
			cursorshape = scr.Understroke
		}
		if B.graphical {
			scr.WarpGr(x+scr.NX1()*B.index, y, cursorshape)
		} else {
			scr.Warp(y/scr.NY1(), x/scr.NX1()+B.index, cursorshape)
		}
		for {
			char, B.command, B.depth = kbd.Read()
			if B.command < kbd.Go {
				break
			}
		}
		edited = char != byte(0)
		if B.graphical {
			scr.WarpGr(x+scr.NX1()*B.index, y, scr.Off)
		} else {
			scr.Warp(y/scr.NY1(), x/scr.NX1()+B.index, scr.Off)
		}
		if B.command == kbd.None {
			if B.index == B.width {
				// see editNumber
			} else {
				if B.possible(Text, x, y) {
					Replace(Text, B.index, char)
					scr.Lock()
					scr.Colours(B.cF, B.cB)
					if B.graphical {
						scr.Write1Gr(char, int(x+scr.NX1()*B.index), int(y))
					} else {
						scr.Write1(char, y/scr.NY1(), x/scr.NX1()+B.index)
					}
					scr.Unlock()
					B.index++
				}
			}
		} else {
			if B.done(Text, x, y) {
				break
			}
		}
	}
	// if B.usesMouse { scr.SwitchMouseCursor (false) }
}
Пример #6
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()
}