Example #1
0
func (B *Imp) EditGr(s *string, x, y uint) {
	//
	if y >= scr.NY() {
		return
	}
	if x >= scr.NX()-scr.NX1() {
		return
	}
	n, b := uint(len(*s)), B.width
	if x+B.width*scr.NX1() > scr.NX() {
		B.width = (scr.NX() - uint(x)) / scr.NX1()
	}
	if B.width == 0 {
		B.width = n
	}
	if B.width < n {
		Norm(s, B.width)
	}
	//  if B.width > n { B.width = n }
	B.graphical = true
	if B.numerical || B.TRnumerical {
		B.editNumber(true, s, x, y)
	} else {
		B.editText(true, s, x, y)
	}
	B.width = b
}
Example #2
0
func (B *Imp) Edit(s *string, l, c uint) {
	//
	if l >= scr.NLines() {
		return
	}
	if c >= scr.NColumns() {
		return
	}
	n, b := uint(len(*s)), B.width
	if c+b > scr.NColumns() {
		B.width = scr.NColumns() - c
	}
	if B.width == 0 {
		B.width = n
	}
	//  if B.width > n { B.width = n }
	if B.width < n {
		Norm(s, B.width)
	}
	B.graphical = false
	if B.numerical || B.TRnumerical {
		B.editNumber(false, s, scr.NX1()*c, scr.NY1()*l)
	} else {
		B.editText(false, s, scr.NX1()*c, scr.NY1()*l)
	}
	B.width = b
}
Example #3
0
func (x *Imp) Radius() uint {
	//
	if x.length > 2 {
		return R0
	}
	return ((x.length + 1) * scr.NX1()) / 2
}
Example #4
0
func (f *Imp) editText() {
	//
	if f.sort != Text {
		return
	}
	scr.MouseCursor(false)
	bx.Wd(lenText)
	bx.ColourF(f.colour)
	x1 := f.x[0] + int(lenText*scr.NX1()) - 1
	if x1 >= xx {
		x1 = xx - 1
	}
	y1 := f.y[0] + int(scr.NY1()) - 1
	if y1 >= yy {
		y1 = yy - 1
	}
	scr.SaveGr(uint(f.x[0]), uint(f.y[0]), uint(x1), uint(y1))
	bx.SetTransparent(false)
	f.tx = str.Clr(lenText) // wörkeraunt
	bx.EditGr(&f.tx, uint(f.x[0]), uint(f.y[0]))
	bx.SetTransparent(true)
	scr.RestoreGr(uint(f.x[0]), uint(f.y[0]), uint(x1), uint(y1))
	var T uint
	if kbd.LastCommand(&T) == kbd.Enter {
		bx.SetTransparent(true)
		//    scr.RestoreGr (f.x[0], f.y[0], x1, y1)
		bx.WriteGr(f.tx, f.x[0], f.y[0])
		k := str.ProperLen(f.tx)
		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.x[0] + int(scr.NX1()*k) - 1
		f.y[1] = f.y[0] + int(scr.NY1()) - 1
		scr.WarpMouseGr(f.x[0], f.y[1])
	} else {
		//    f.tx = str.Clr (lenText)
		//    bx.WriteGr (f.tx, f.x[0], f.y[0])
		//    f.tx = ""
		//    f.x, f.y = nil, nil
	}
	scr.MouseCursor(true)
}
Example #5
0
func (B *Imp) Clr(L, C uint) {
	//
	if B.width == 0 {
		return
	}
	scr.Lock()
	scr.Colours(col.ScreenF, col.ScreenB)
	scr.WriteGr(Clr(B.width), int(scr.NX1()*C), int(scr.NY1()*L))
	scr.Unlock()
}
Example #6
0
func (x *Imp) write() {
	//
	r := x.Radius()
	/*
	   if r <= R0 {
	     scr.CircleFull (int(x.x), int(x.y), R0)
	   } else {
	     for n:= uint(0); n <= 1; n++ {
	       scr.Circle (int(x.x), int(x.y), r + n)
	     }
	   }
	*/
	if x.length > 0 {
		n := str.ProperLen(x.name)
		xx := x.x - (n*scr.NX1())/2 + 1
		yy := x.y - scr.NY1()/2 + 1
		switch x.lab {
		case zentral:

		case rechts:
			xx = x.x + scr.NX1() + 1
		case oben:
			yy -= 5 * scr.NY1() / 6
		case links:
			xx = x.x - n*scr.NX1() - scr.NX1() + 1
		case unten:
			yy += 5 * scr.NY1() / 6
		}
		bx.SetTransparent(transparent)
		bx.Wd(x.length)
		bx.WriteGr(x.name, int(xx), int(yy))
	}
	if r <= R0 {
		scr.CircleFull(int(x.x), int(x.y), R0)
	} else {
		for n := uint(0); n <= 1; n++ {
			scr.Circle(int(x.x), int(x.y), r+n)
		}
	}
}
Example #7
0
func (x *Imp) Edit() {
	//
	if x.length > 0 {
		B := (x.length * scr.NX1()) / 2
		H := scr.NY1() / 2
		bx.Wd(x.length)
		bx.ColourF(Farbe[0])
		bx.EditGr(&x.name, x.x-B+1, x.y-H+1)
		N := str.Clr(x.length)
		bx.WriteGr(N, int(x.x-B+1), int(x.y-H+1))
	}
	x.write()
}
Example #8
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()
}
Example #9
0
func (B *Imp) WriteGr(s string, x, y int) {
	//
	if uint(y) >= scr.NY() {
		return
	}
	if uint(x) >= scr.NX()-scr.NX1() {
		return
	}
	n, b := uint(len(s)), B.width
	if B.width == 0 {
		B.width = n
	}
	if uint(x)+B.width*scr.NX1() > scr.NX() {
		B.width = (scr.NX() - uint(x)) / scr.NX1()
	}
	if B.width > n {
		B.width = n
	}
	if B.width < n {
		Norm(&s, B.width)
	}
	if B.numerical || B.TRnumerical {
		Move(&s, false)
	}
	scr.Lock()
	scr.Colours(B.cF, B.cB)
	if B.transparent {
		scr.SwitchTransparence(true)
	}
	scr.WriteGr(s, x, y)
	if B.transparent {
		scr.SwitchTransparence(false)
	}
	scr.Unlock()
	B.width = b
}
Example #10
0
func (x *Imp) pos(n, n1 *node.Imp, d bool) (uint, uint, uint, uint, bool) {
	//
	x.x, x.y = n.Pos()
	x.x1, x.y1 = n1.Pos()
	if x.x == x.x1 && x.y == x.y1 {
		return 0, 0, 0, 0, false
	}
	dx := math.Abs(float64(x.x) - float64(x.x1))
	dy := math.Abs(float64(x.y) - float64(x.y1))
	if dx*dx+dy*dy < 0.001 {
		return 0, 0, 0, 0, false
	}
	d0 := 1.0 / math.Sqrt(dx*dx+dy*dy)
	dx, dy = d0*dx, d0*dy
	r := n.Radius()
	h := uint(dx*float64(r+r0+1)+0.5) + 1
	if x.x < x.x1 {
		x.x += h
		x.x1 -= h
	} else {
		x.x -= h
		x.x1 += h
	}
	h = uint(dy*float64(r+r0+1)+0.5) + 1
	if x.y < x.y1 {
		x.y += h
		x.y1 -= h
	} else {
		x.y -= h
		x.y1 += h
	}
	x0 := (x.x+x.x1)/2 - (zk*scr.NX1())/2 + 1
	y0 := (x.y+x.y1)/2 - scr.NY1()/2 + 1
	var x1, y1 uint
	//  x1, y1 = (x.x + 7 * x.x1) / 8, (x.y + 7 * x.y1) / 8
	if d {
		x1, y1 = x.x1, x.y1
	} else {
		x1, y1 = x.x, x.y
	}
	return x0, y0, x1, y1, true
}
Example #11
0
func dr(x0, x1, y int, c col.Colour, f bool) {
	//
	const dx = 2
	nx1, ny, y1 := int(scr.NX1()), int(scr.NY()), 0
	for x := x0; x < x1; x += dx {
		if !f {
			scr.SaveGr(uint(x), uint(y), uint(x)+car.W, uint(y)+car.H)
		}
		car.Draw(true, c, x, y)
		ker.Msleep(10)
		car.Draw(true, col.ScreenB, x, y)
		if f && x > x0+26*nx1 && x%8 == 0 && y+car.H < ny {
			y1++
			y += y1
		}
		if !f {
			scr.RestoreGr(uint(x), uint(y), uint(x)+car.W, uint(y)+car.H)
		}
	}
}
Example #12
0
func New(h bool) *Imp {
	//
	B := new(Imp)
	l := scr.NLines()
	c := scr.NX()
	B.max = 100
	B.horizontal = h
	B.value = 0
	if h {
		B.width = c
		B.height = scr.NY1()
		B.Locate(0, (l-1)*B.height, B.width, B.height)
	} else {
		B.width = scr.NX1()
		B.height = scr.NY()
		B.Locate(c-B.width, 0, B.width, B.height)
	}
	B.cF, B.cB = col.HintF, col.HintB
	B.Locate(B.x0, B.y0, B.width, B.height)
	return B
}
Example #13
0
func init() {
	//
	scr.Switch(scr.TXT)
	cF, cB = col.LightMagenta, col.Black
	// scr.Colours (cF, cB)
	lengthF, timeF = col.Red, col.LightBlue
	trackTimeF, ctrlF = col.Colour3(191, 191, 255), col.Colour3(63, 111, 255)
	for c := cdker.Controller(0); c < cdker.NCtrl; c++ {
		ctrlText[c] = cdker.Ctrltext[c]
		str.Center(&ctrlText[c], wr)
		lv[c] = l0 + 3*uint(c)
	}
	timeText = [2]string{"tracktime", "total time"}
	str.Center(&timeText[0], wr)
	str.Center(&timeText[1], wr)
	lt = [2]uint{l1 + 2, l1 + 2 + 3}
	bx = box.New()
	bx.Wd(wr)
	bx.Colours(col.HintF, col.HintB)
	bx.Colours(trackTimeF, cB)
	bx.Write(" track", l1, cr+wr-6-2)
	cw, lh := scr.NX1(), scr.NY1()
	bx.Colours(cF, cB)
	bx.Wd(wr)
	for c := cdker.Controller(0); c < cdker.NCtrl; c++ {
		ctrlBar[c] = pbar.New(true)
		ctrlBar[c].Def(cdker.MaxVol)
		ctrlBar[c].SetColours(ctrlF, cB)
		ctrlBar[c].Locate(cr*cw, lv[c]*lh, wr*cw, lh)
		bx.Write(ctrlText[c], lv[c]+1, cr)
	}
	for i := 0; i < 2; i++ {
		timeBar[i] = pbar.New(true)
		timeBar[i].SetColours(ctrlF, cB)
		timeBar[i].Locate(cr*cw, lt[i]*lh, wr*cw, lh)
		bx.Write(timeText[i], lt[i]+1, cr)
	}
	scr.MouseCursor(true)
	scr.WarpMouse(lv[cdker.All]+1, cr+wr/4)
}
Example #14
0
func (f *Imp) Decode(B []byte) {
	//
	a := uint(0)
	f.sort = Sort(B[a])
	a++
	col.Decode(&f.colour, B[a:a+3])
	a += 3
	n := uint(0)
	n = Decode(uint(0), B[a:a+clz]).(uint)
	a += clz
	if f.sort < Text {
		f.x, f.y = make([]int, n), make([]int, n)
		for i := uint(0); i < n; i++ {
			f.x[i] = Decode(f.x[i], B[a:a+clz]).(int)
			a += clz
			f.y[i] = Decode(f.y[i], B[a:a+clz]).(int)
			a += clz
		}
	} else { // sort == Text, Image
		f.x, f.y = make([]int, 2), make([]int, 2)
		f.x[0] = Decode(f.x[0], B[a:a+clz]).(int)
		a += clz
		f.y[0] = Decode(f.y[0], B[a:a+clz]).(int)
		a += clz
		if f.sort == Image {
			f.x[1] = Decode(f.x[1], B[a:a+clz]).(int)
			a += clz
			f.y[1] = Decode(f.y[1], B[a:a+clz]).(int)
			a += clz
		}
		f.tx = string(B[a : a+n])
		a += n
		if f.sort == Text {
			f.x[1] = f.x[0] + int(scr.NX1()*n) - 1
			f.y[1] = f.y[0] + int(scr.NY1()) - 1
		}
	}
	f.filled = B[a]%2 == 1
	f.marked = (B[a]/2)%2 == 1
}
Example #15
0
func drive(cc, cl, cb col.Colour, d chan bool) {
	//
	nx, nx1, ny1 := int(scr.NX()), int(scr.NX1()), int(scr.NY1())
	dw := 96 * nx1
	x0 := (nx - dw) / 2
	x1 := x0 + dw - car.W
	y0 := ((int(scr.NLines())-31)/2 + 3) * ny1
	dr(x0, x1, y0, cc, false)
	dr(x0, x1, y0+2*ny1, cl, false)
	dr(x0, x1, y0+3*ny1, cl, false)
	joke(x0, x1, y0, nx1, ny1, 2, 4, 48, cl, "nsp", true)
	dr(x0, x1, y0+19*ny1, cl, false)
	dr(x0, x0+68*nx1, y0+20*ny1, cl, false)
	csb := col.ScreenB
	col.ScreenB = col.Black
	dr(x0+69*nx1, nx, y0+20*ny1, col.FlashRed, true)
	col.ScreenB = csb
	joke(x0, x1, y0, nx1, ny1, 67, 21, 14, cl, "fire", false)
	joke(x0, x1, y0, nx1, ny1, 48, 22, 15, cl, "mca", false)
	moon(x0 + 90*nx1)
	dr(x0, x1, y0+26*ny1, cc, false)
	d <- true
}
Example #16
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 #17
0
func (x *Imp) Write(aktuell bool) {
	//
	xx, yy := scale.Scale(x.breite, x.länge)
	lw := scr.ActLinewidth()
	scr.SetLinewidth(scr.Thin)
	if aktuell {
		scr.Colours(linie.Farbe[x.linie], col.ScreenB)
	} else { // umstieg
		scr.Colours(col.Black, col.ScreenB)
	}
	const r = 2
	if xx >= r && yy >= r {
		scr.Circle(xx, yy, r)
		//    scr.Colour (col.ScreenB)
		scr.CircleFull(xx, yy, r-1)
	}
	scr.SetLinewidth(lw)
	n := int(str.ProperLen(x.name))
	if n <= 2 {
		return
	}
	n1 := int(str.ProperLen(x.name1))
	if n1 > n {
		n = n1
	}
	xn, yn := 0, 0
	w, h := int(scr.NX1()), int(scr.NY1())
	switch x.beschriftung {
	case 'r':
		xn = xx + w + 1
		if n1 == 0 {
			yn = yy - h/2
		} else {
			yn = yy - h
		}
	case 'o':
		xn = xx - (n*w)/2 + 1
		if n1 == 0 {
			yn = yy - h - 1
		} else {
			yn = yy - 2*h - 1
		}
	case 'l':
		xn = xx - n*w - w + 1
		if n1 == 0 {
			yn = yy - h/2
		} else {
			yn = yy - h
		}
	case 'u':
		xn = xx - (n*w)/2 + 1
		yn = yy + h/2 - 2
	default:
		xn = xx - (n*w)/2 + 1
		if n1 == 0 {
			yn = yy - h/2
		} else {
			yn = yy - h
		}
	}
	xxx := x.name
	for i := uint(0); i < uint(len(xxx)); i++ {
		if xxx[i] == '_' {
			str.Replace(&xxx, i, ' ')
		}
	}
	xxx1 := x.name1
	for i := uint(0); i < uint(len(xxx1)); i++ {
		if xxx1[i] == '_' {
			str.Replace(&xxx1, i, ' ')
		}
	}
	if aktuell {
		scr.Colours(linie.Farbe[x.linie], col.ScreenB)
	} else { // umstieg
		scr.Colours(col.Black, col.ScreenB)
		scr.Colours(col.Black, col.Pink)
	}
	scr.WriteGr(xxx, xn, yn)
	scr.WriteGr(xxx1, xn, yn+h+0)
}
Example #18
0
func ausgeben1(a arten, r Richtung, y uint, x uint, f, b col.Colour) {
	//
	y0 := (zellengroesse / int(scr.NY1())) * int(y+1)
	x0 := (zellengroesse / int(scr.NX1())) * int(x)
	x0 *= int(scr.NX1())
	y0 = int(scr.NY1()) * (y0) // * (y0 - 1)
	if a == nichts {           // schneller:
		scr.Colour(farbeH)
		scr.RectangleFull(x0+1, y0+1, x0+zellengroesse-2, y0+zellengroesse-1)
		scr.Colour(randfarbe)
		scr.Rectangle(x0, y0, x0+zellengroesse-1, y0+zellengroesse-1)
	} else {
		// Datenstrukturen zur Beschleunigung der Ausgabe unter X um das 171-fache
		// durch Reduktion der Aufrufe von X-Routinen von 2 * 32 * 32 = 2048 auf 2 * 6 = 12:
		const (
			n  = 6 // Farbzahl
			zz = zellengroesse * zellengroesse
		)
		var (
			nr    int
			zelle [zellengroesse][zellengroesse]int
		)
		for dy := 0; dy < zellengroesse; dy++ {
			for dx := 0; dx < zellengroesse; dx++ {
				nr = 0 // farbeH
				switch bild[a][dy][dx] {
				case 'o':
					nr = 1 // F
				case 'x':
					nr = 2 // randfarbe
				case '+':
					nr = 3 // farbeV
				case 'k':
					if Roboterwelt.kloetze(y, x) > 0 {
						nr = 4 // B
					}
				case 'm':
					if Roboterwelt.markiert(y, x) {
						nr = 4 // B
					}
				case ' ':
					if a == mauer {
						nr = 5 // mauerfarbe
					} else {
						nr = 0 // farbeH
					}
				default:
					return // stop
				}
				if a != einRoboter {
					r = Nord
				}
				switch r {
				case Nord:
					zelle[dx][dy] = nr
				case West:
					zelle[dy][dx] = nr
				case Sued:
					zelle[dx][zellengroesse-1-dy] = nr
				case Ost:
					zelle[zellengroesse-1-dy][dx] = nr
				}
			}
		}
		var (
			anzahl [n]int
			xx, yy [n][zz]int
		)
		for dy := 0; dy < zellengroesse; dy++ {
			for dx := 0; dx < zellengroesse; dx++ {
				nr = zelle[dx][dy]
				xx[nr][anzahl[nr]] = x0 + dx
				yy[nr][anzahl[nr]] = y0 + dy
				anzahl[nr]++
			}
		}
		c := [n]col.Colour{farbeH, f, randfarbe, farbeV, b, mauerfarbe}
		for i := 0; i < n; i++ {
			scr.Colour(c[i])
			scr.Pointset(xx[i][:], yy[i][:])
		}
	}
}
Example #19
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) }
}
Example #20
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) }
}