示例#1
0
文件: imp.go 项目: CaptainSoOmA/Uni
func NodesSelected() bool {
	//
	scr.MouseCursor(true)
	g := false
	for {
		errh.Hint("Start auswählen")
		if ausgewaehlt(Ecke) { // Ecke aktuell
			Graph.Position(true) // Ecke postaktuell
			Write()
			errh.Hint("Ziel auswählen")
			if ausgewaehlt(Ecke1) { // Ecke1 aktuell
				errh.DelHint()
				if Graph.Positioned() {
					errh.Error("Fehler: Start und Ziel sind gleich !", 0)
				} else {
					g = true
					break
				}
			}
		} else {
			break
		}
	}
	Write()
	errh.DelHint()
	scr.MouseCursor(false)
	return g
}
示例#2
0
文件: imp.go 项目: CaptainSoOmA/Uni
func gewählt() bool {
	//
loop:
	for {
		errh.Hint("Start auswählen     (Klick mit linker Maustaste)")
		if gew() { // Start aktuell
			netz.Get().(*bahnhof.Imp).Write(true)
			netz.Position(true) // Start postaktuell
			write(false)
		} else {
			break
		}
		errh.Hint("Ziel auswählen     (Klick mit linker Maustaste)")
		for {
			if gew() { // Ziel aktuell
				if !netz.Positioned() {
					netz.Get().(*bahnhof.Imp).Write(true)
					errh.DelHint()
					return true
				}
			} else {
				break loop
			}
		}
	}
	write(false)
	defer ker.Terminate()
	return false
}
示例#3
0
文件: imp.go 项目: CaptainSoOmA/Uni
func put(n string, x, y, w, h uint) {
	//
	if str.Empty(n) {
		return
	}
	str.RemSpaces(&n)
	filename := n + suffix
	if scr.UnderX() {
		errh.Hint("bitte etwas Geduld ...")
	}
	buf := scr.P6Encode(x, y, w, h)
	if scr.UnderX() {
		errh.DelHint()
	}
	file := pseq.New(buf)
	file.Name(filename)
	file.Clr()
	file.Put(buf)
	file.Terminate()
	if !toPrint {
		exec.Command("pnmtopng", filename+suffix, ">", n, ".png").Run()
		ker.Msleep(100)
		exec.Command("rm", filename)
	}
}
示例#4
0
文件: imp.go 项目: CaptainSoOmA/Uni
func (x *Imp) selected(l, c uint) bool {
	//
	n := uint(len(x.nextLevel))
	if n == 0 || !x.isMenu {
		return false
	}
	if n == 1 {
		return true
	}
	bx.Colours(menuheadF, menuheadB)
	bx.Wd(scr.NColumns())
	bx.Write(x.text, l, c)
	errh.Hint(errh.ToSelect)
	i := x.lastPos
	sel.Select(func(p, l, c uint, f, b col.Colour) {
		bx.Colours(f, b)
		bx.Write(x.nextLevel[p].text, l, c)
	}, n, scr.NLines()-2, scr.NColumns(), &i, 2, 0, menuF, menuB)
	if i < n {
		x.lastPos = i
		x.next = x.nextLevel[i]
	}
	errh.DelHint()
	return i < n
}
示例#5
0
文件: imp.go 项目: CaptainSoOmA/Uni
func (x *Imp) selected(l, c uint) bool {
	//
	if x.num == 0 {
		return false
	}
	if x.num == 1 {
		return true
	}
	x.Write(l, c)
	i := uint(0)
	h := x.num / 2
	if h < 5 {
		h = 5
	}
	if h > x.num {
		h = x.num
	}
	errh.Hint(errh.ToSelect)
	//  f, b:= x.cF, x.cB
	//  f, b = col.Pink, col.Darkmagenta
	sel.Select(func(p, l, c uint, f, b col.Colour) {
		bx.Colours(f, b)
		bx.Write(x.s[x.f][p], l, c)
	}, x.num, h, x.wd[x.f], &i, l, c, x.cB, x.cF)
	errh.DelHint()
	if i < x.num {
		x.b = byte(i)
	}
	return i < x.num
}
示例#6
0
文件: main.go 项目: CaptainSoOmA/Uni
func main() {
	//
	scr.Switch(scr.TXT)
	var today, birthday *Imp
	today = New()
	today.Actualize()
	birthday = New()
	birthday.SetColours(col.LightWhite, col.Blue)
	scr.Colour(col.Yellow)
	scr.Write("Ihr Geburtsdatum:", 12, 0)
	birthday.Edit(12, 18)
	if birthday.Empty() {
		birthday.Actualize()
	} else {
		scr.Write(" war ein ", 12, 26)
		birthday.SetFormat(WD)
		birthday.Write(12, 35)
		errh.Error2("Sie sind heute", birthday.Distance(today), "Tage alt.", 0)
	}
	scr.Colours(col.ScreenF, col.ScreenB)
	scr.Cls()
	errh.Hint(" vor-/rückwärts: Pfeiltasten               fertig: Esc ")
	var (
		c kbd.Comm
		t uint
	)
	neu := true
loop:
	for {
		if neu {
			birthday.WriteYear(0, 0)
			neu = false
		}
		switch c, t = kbd.Command(); c {
		case kbd.Esc:
			break loop
		case kbd.Down:
			if t == 0 {
				birthday.Inc(Yearly)
			} else {
				birthday.Inc(Decadic)
			}
			neu = true
		case kbd.Up:
			if t == 0 {
				birthday.Dec(Yearly)
			} else {
				birthday.Dec(Decadic)
			}
			neu = true
		case kbd.PrintScr:
			birthday.PrintYear(0, 0)
			prt.GoPrint()
		}
	}
	ker.Terminate()
}
示例#7
0
文件: imp.go 项目: CaptainSoOmA/Uni
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
}
示例#8
0
文件: imp.go 项目: CaptainSoOmA/Uni
func NodeSelected() bool {
	//
	scr.MouseCursor(true)
	errh.Hint("Ecke auswählen")
	g := false
	if ausgewaehlt(Ecke) { // Ecke aktuell
		Graph.Position(true) // Ecke postaktuell
		g = true
		Write()
	}
	errh.DelHint()
	scr.MouseCursor(false)
	return g
}
示例#9
0
文件: main.go 项目: CaptainSoOmA/Uni
func defined() (string, bool) {
	//
	bx := box.New()
	bx.Wd(6)
	bx.Colours(col.LightCyan, col.Black)
	bx.Write("Welt:", 1, 0)
	const n = 12
	bx.Wd(n)
	name := str.Clr(n)
	name = ""
	errh.Hint("Namen der Welt eingeben                Programmende: leere Eingabe")
	bx.Edit(&name, 1, 6)
	str.RemSpaces(&name)
	errh.DelHint()
	return name, !str.Empty(name)
}
示例#10
0
文件: imp.go 项目: CaptainSoOmA/Uni
// CLR 23.3, CLRS 22.3
func (x *Imp) depthfirstSearch() {
	//
	x.preDepth()
	if x.demo[Depth] {
		errh.Hint("weiter mit Eingabetaste")
	}
	n := x.nodeAnchor.nextN
	for n != x.nodeAnchor {
		if n.time0 == 0 {
			x.search(n, n, True)
		}
		n = n.nextN
	}
	if x.demo[Depth] {
		errh.DelHint()
	}
}
示例#11
0
文件: imp.go 项目: CaptainSoOmA/Uni
func schreiten() {
	//
	if !schrittweise {
		return
	}
	errh.Hint(errh.ToContinueOrNot)
loop:
	for {
		c, _ := kbd.Command()
		switch c {
		case kbd.Enter:
			break loop
		case kbd.Esc:
			ker.Terminate()
		}
	}
}
示例#12
0
文件: imp.go 项目: CaptainSoOmA/Uni
func (f *Imp) editImage() {
	//
	if f.sort != Image {
		return
	}
	scr.MouseCursor(false)
	errh.Hint("Name des Bildes eingeben")
	bx.Wd(32) // reine Willkür
	Hf := col.ScreenB
	bx.Colours(f.colour, Hf)
	f.tx = str.Clr(BB)
	bx.EditGr(&f.tx, uint(f.x[0]), uint(f.y[0]))
	str.RemSpaces(&f.tx)
	W, H := img.Size(f.tx)
	w, h := int(W), int(H)
	if w <= xx && h <= yy {
		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] + w - 1
		f.y[1] = f.y[0] + h - 1
		if f.x[1] >= xx {
			f.x[0] = xx - w
			f.x[1] = xx - 1
		}
		if f.y[1] >= yy {
			f.y[0] = yy - h
			f.y[1] = yy - 1
		}
		errh.DelHint()
		//  besser:
		//    img.Get ...
		//    NEW (Imagespeicher)
		//    img.Get ( ... dort rein ...)
		//    img.Get (tx, x[0], y[0])
	} else {
		errh.DelHint()
	}
	scr.MouseCursor(true)
}
示例#13
0
文件: imp.go 项目: CaptainSoOmA/Uni
func (R *Imp) Editieren() {
	//
	//  errh.WriteHelp1 ()
	R.Aktualisieren()
	errh.Hint("Hilfe mit F1")
	//  R.aktionen = R.aktionen [0:0]
	var (
		K kbd.Comm
		T uint
	)
	for {
		K, T = kbd.Command()
		R.Manipulieren(K, T)
		if K == kbd.Esc {
			break
		}
	}
	errh.DelHint()
}
示例#14
0
文件: imp.go 项目: CaptainSoOmA/Uni
func Edit(d *day.Imp, Z, S uint) {
	//
	globalPage.Set(d)
	globalPage.SetFormat(day.Daily)
	exists := content.Ex(globalPage)
	if exists { // haben wir an diesem Tag Termine
		errh.Hint(errh.ToSelect)
	loop:
		for {
			globalPage = content.Get().(*page.Imp)
			globalPage.Write(Z, S)
			K, _ := kbd.Command()
			switch K {
			case kbd.Enter:
				break loop
			case kbd.Esc:
				errh.DelHint()
				return
			case kbd.Down, kbd.Up:
				content.Step(K == kbd.Down)
			case kbd.Pos1, kbd.End:
				content.Jump(K == kbd.End)
			}
		}
		errh.DelHint()
		globalDay = globalPage.Day().(*day.Imp)
	}
	globalPage.Edit(Z, S)
	if globalPage.Empty() {
		if exists {
			content.Del()
		}
	} else if exists {
		content.Put(globalPage)
	} else {
		content.Ins(globalPage)
	}
}
示例#15
0
文件: imp.go 项目: CaptainSoOmA/Uni
func Edit() {
	//
	Write()
	errh.Hint("Graph editieren: Hilfe per F1, fertig: Abbruchtaste (Esc)")
	scr.MouseCursor(true)
loop:
	for {
		K, i := kbd.Command()
		//    errh.DelHint()
		switch K {
		case kbd.Esc:
			break loop
		case kbd.Help:
			errh.WriteHelp(help)
		case kbd.Here: // neue Ecke oder Namen vorhandener Ecke ändern:
			if Graph.ExPred(node.UnderMouse) {
				if i > 0 {
					Ecke = Graph.Get().(*node.Imp) // aktuell: Ecke
					Ecke.Edit()
					Graph.Put(Ecke)
				}
			} else {
				Ecke.Clr()
				Ecke.Locate()
				Ecke.Write(true, true)
				Ecke.Edit()
				Graph.Ins(Ecke)
			}
		case kbd.Del: // Ecke entfernen
			if Graph.ExPred(node.UnderMouse) {
				wr(false, false)
				Graph.Del()
			}
		case kbd.There: // Ecke verschieben
			switch i {
			case 0:
				if Graph.ExPred(node.UnderMouse) {
					wr(false, false)
					wr(false, true)
				loop1:
					for {
						geschoben := false
						kk, _ := kbd.Command()
						switch kk {
						case kbd.Push:
							geschoben = true
							wr(false, true)
							Ecke = Graph.Get().(*node.Imp)
							Ecke.Locate()
							Graph.Put(Ecke)
							wr(false, true)
						case kbd.Thither:
							wr(false, true)
							if geschoben {
								Graph.Put(Ecke)
							}
							wr(true, false)
							break loop1
						}
					}
				}
			default: // Ecke entfernen
				if Graph.ExPred(node.UnderMouse) {
					wr(false, false)
					Graph.Del()
				}
			}
		case kbd.This: // Ecken verbinden / Kante entfernen:
			x0, y0 := scr.MousePosGr()
			x, y := x0, y0
			if Graph.ExPred(node.UnderMouse) {
				Ecke = Graph.Get().(*node.Imp) // Ecke aktuell
				Graph.Position(true)           // Ecke auch postaktuell
			loop2:
				for {
					kk, _ := kbd.Command()
					switch kk {
					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)
						if Graph.ExPred(node.UnderMouse) {
							Ecke1 = Graph.Get().(*node.Imp) // Ecke1 aktuell
							g := Graph.Directed()
							if g {
								Kante.Write(Ecke, Ecke1, g, false, false)
							}
							Kante.Edit(Ecke, Ecke1, g)
							Graph.Edge1(Kante)
							if Kante.Val() == 0 {
								Kante.Write(Ecke, Ecke1, g, false, false)
								Graph.Del1()
							}
						}
						break loop2
					}
				}
			}
		case kbd.PrintScr:
			//      img.Write (".tmp.Graph", 0, 0, scr.NX(), scr.NY())
			//      img.Print()
		}
	}
	errh.DelHint()
}
示例#16
0
文件: imp.go 项目: CaptainSoOmA/Uni
func (f *Imp) Edit() {
	//
	if f.Empty() {
		scr.Colour(f.colour)
		f.x, f.y = make([]int, 1), make([]int, 1)
		f.x[0], f.y[0] = scr.MousePosGr()
		switch f.sort {
		case Pointset, Segments, Polygon, Curve:
			f.editN()
		case InfLine, Rectangle, Circle, Ellipse:
			f.edit1()
		case Text:
			f.editText()
		case Image:
			//      ALLOCATE (Imageptr, Groesse())
			//      img.Get (tx [...], Imageptr)
			f.editImage()
		}
		if f.x == nil {
			f.Clr()
		}
	} else {
		n := uint(len(f.x))
		errh.Error("Figur hat Länge", n)
		switch f.sort {
		case Text:
			f.editText()
		case Image:
			f.editImage()
		default:
			f.Erase()
			f.Invert()
			if true { // f.sort == Curve {
				for i := uint(0); i < n; i++ {
					f.mark(i)
				}
			}
			i := f.uM()
			f.x[i], f.y[i] = scr.MousePosGr()
		loop:
			for {
				scr.MouseCursor(true)
				c, _ := kbd.Command()
				switch c {
				case kbd.Esc:
					break loop
				case kbd.Enter, kbd.Tab, kbd.LookFor:
					f.colour = sel.Colour()
				case kbd.Here:
					break loop
				case kbd.There:
					i = f.uM()
				case kbd.Push, kbd.Thither:
					if i < n {
						f.Invert()
						f.mark(i)
						f.x[i], f.y[i] = scr.MousePosGr()
						f.mark(i)
						f.Invert()
						if c == kbd.Thither {
							i = n
						} // ? ? ?
					}
				case kbd.This:
					switch f.sort {
					case Pointset, Segments, Polygon, Curve:
						if f.x == nil {
							f.Clr()
						} else {
							for i := uint(0); i < n; i++ {
								f.mark(i)
							}
							f.Erase()
							n-- // ? ? ?
							f.Invert()
							for i := uint(0); i < n; i++ {
								f.mark(i)
							}
						}
					}
				}
				errh.Hint(c.String())
			}
			f.Invert()
			if true { // sort != Text {
				for i := uint(0); i < n; i++ {
					f.mark(i)
				}
			}
			f.Write()
		}
	}
}