Esempio n. 1
0
func names(mask, suffix string, n uint, l, c uint, f, b col.Colour) (string, string) {
	//
	t, t1 := uint(len(mask)), uint(0)
	if t > 0 {
		t1 = 1 + t
	}
	scr.Save(l, c, t1+n, 1)
	if t > 0 {
		mbx.Wd(t)
		mbx.ColoursScreen()
		mbx.Write(mask, l, c)
	}
	bx.Wd(n)
	bx.Colours(f, b)
	ptSuffix = "." + suffix
	errh.Hint("falls Dateien vorhanden, auswählen F2-, dann Pfeil-/Eingabetaste, ggf. Esc")
	name := env.Par(1)
	if name == "" {
		name = str.Clr(n) // Wörkeraunt um Fehler in box/imp.go
	}
	var p uint
	if str.Contains(name, '.', &p) {
		name = str.Part(name, 0, p)
	}
	bx.Edit(&name, l, c+t1)
	str.RemSpaces(&name)
	if str.Contains(name, '.', &p) {
		name = str.Part(name, 0, p)
	}
	filename := name + ptSuffix
	a := files.NumPred(hasSuffix)
	if a > 0 {
		var d uint
		switch kbd.LastCommand(&d) {
		case kbd.Esc:
			return "", "" // str.Clr (n), ""
		case kbd.Enter:
			// entered
		case kbd.LookFor:
			i := uint(0)
			select_(aus, a, a, n, &i, l, c+t1, b, f)
			if i == a {
				return "", "" // str.Clr (n), ""
			} else {
				str.Set(&filename, files.NamePred(hasSuffix, i))
			}
		}
	}
	errh.DelHint()
	str.RemSpaces(&filename)
	if str.Contains(filename, '.', &p) {
		name = str.Part(filename, 0, p)
	}
	scr.Restore(l, c, t1+n, 1)
	return name, filename
}
Esempio n. 2
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()
}
Esempio n. 3
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)
	}
}