Exemplo n.º 1
0
func (x *Imp) Edit(l, c uint) {
	//
	b := x.symbol
	scr.Colours(x.cF, x.cB)
	scr.Write1(b, l, c)
loop:
	for {
		scr.Warp(l, c, scr.Understroke)
		b = kbd.Byte()
		switch {
		case ' ' <= b, b < 128, z.IsLatin1(b):
			break loop
		}
	}
	scr.Write1(b, l, c)
	x.symbol = b
}
Exemplo n.º 2
0
func (x *Imp) Write(l, c uint) {
	//
	s := x.String()
	c0 := c
	for n := 0; n < len(s); n++ {
		scr.Write1(s[n], l, c)
		if c+1 < scr.NColumns() {
			c++
		} else if l+2 < scr.NLines() {
			l++
			c = c0
		} else {
			break
		}
	}
}
Exemplo n.º 3
0
func rot(n int) {
	var b byte
	for i := 0; !ok; i++ {
		switch i % 4 {
		case 0:
			b = '|'
		case 1:
			b = '/'
		case 2:
			b = '-'
		case 3:
			b = '\\'
		}
		scr.Write1(b, y0+1, 71)
		ker.Msleep(50)
	}
}
Exemplo n.º 4
0
func (B *Imp) write(Text string, x, y uint) {
	//
	scr.Lock()
	scr.Colours(B.cF, B.cB)
	if B.transparent {
		scr.SwitchTransparence(true)
	}
	y1 := B.width
	if y1 > uint(len(Text)) {
		y1 = uint(len(Text))
	}
	for x1 := B.index; x1 < y1; x1++ {
		if B.graphical {
			scr.Write1Gr(Text[x1], int(x+scr.NX1()*x1), int(y))
		} else {
			scr.Write1(Text[x1], y/scr.NY1(), x/scr.NX1()+x1)
		}
	}
	if B.transparent {
		scr.SwitchTransparence(false)
	}
	scr.Unlock()
}
Exemplo n.º 5
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()
}
Exemplo n.º 6
0
func (x *Imp) writeMask(l, c uint) {
	//
	scr.Write1(separator, l, c+10) // TODO depends on Format
}
Exemplo n.º 7
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) }
}
Exemplo n.º 8
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) }
}
Exemplo n.º 9
0
func (x *Imp) Write(l, c uint) {
	//
	scr.Colours(x.cF, x.cB)
	scr.Write1(x.symbol, l, c)
}