Ejemplo n.º 1
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()
}
Ejemplo n.º 2
0
func draw(right bool, c col.Colour, X, Y int) {
	//
	scr.Lock()
	for y := 0; y < H; y++ {
		for x := 0; x < W; x++ {
			if car[y][x] == '*' {
				scr.Colour(c)
			} else {
				scr.Colour(col.ScreenB)
			}
			if right {
				scr.Point(X+x, Y+y)
			} else {
				scr.Point(X+W-1-x, Y+y)
			}
		}
	}
	scr.Unlock()
}
Ejemplo n.º 3
0
func (B *Imp) Write(s string, l, c uint) {
	//
	if l >= scr.NLines() {
		return
	}
	if c >= scr.NColumns() {
		return
	}
	//  Wd (&s, s)
	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)
	}
	//  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.Write(s, l, c)
	if B.transparent {
		scr.SwitchTransparence(false)
	}
	scr.Unlock()
	B.width = b
}
Ejemplo 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()
}
Ejemplo n.º 5
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
}
Ejemplo n.º 6
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) }
}
Ejemplo n.º 7
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) }
}