func gew() bool { // var dummy *bahnhof.Imp for { // ok:= false c, _ := kbd.Command() scr.MouseCursor(true) switch c { case kbd.Esc: return false case kbd.Enter, kbd.Back, kbd.Left, kbd.Right, kbd.Up, kbd.Down: dummy.SkalaEditieren() write(false) case kbd.Help: errh.WriteHelp(help) case kbd.Hither: if netz.ExPred(func(a Any) bool { return a.(*bahnhof.Imp).UnterMaus() }) { return true } case kbd.There, kbd.Push, kbd.Thither: dummy.SkalaEditieren() write(false) /* case kbd.This: ok = netz.ExPred (func (a Any) bool { return a.(*bahnhof.Imp).UnterMaus() }) case kbd.Push: x, y:= scr.MousePosGr () if ok { bhf:= netz.Get ().(*bahnhof.Imp) bhf.Rescale (uint(x), uint(y)) netz.Put (bhf) write (false) } */ case kbd.PrintScr: errh.DelHint() img.Print1() } } return false }
func (w *Imp) Edit(l, c uint) { // l, c: fake // s := w.spec[w.line][w.column] sa := s y, x := scr.MousePos() ya, xa := y, x loop: for { s.Write(y0+w.line, 2*w.column) ya, xa = y, x sa = s c, _ := kbd.Command() y, x = scr.MousePos() if y0 <= y && y < ny+y0 && x < 2*nx { w.line, w.column = y-y0, x/2 s = w.spec[w.line][w.column] } if ya >= y0 { sa.Mark(false) sa.Write(ya, 2*(xa/2)) } switch c { case kbd.Esc: break loop case kbd.Enter: w.modify() w.Write(0, 0) case kbd.Help: errh.WriteHelp(help[:]) case kbd.Here: s.Inc() case kbd.There: s.Dec() } s.Mark(true) w.writeNumbers() } w.terminate() }
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() }
func (R *Imp) Manipulieren(K kbd.Comm, T uint) { // s := schrittweise schrittweise = false amEditieren = true switch K { case kbd.Esc: return case kbd.Enter: if T == 0 { if R.Geschoben1() { } } else { R.schiessen() } case kbd.Left: if Sokoban { switch R.richtung { case Nord: R.LinksDrehen() case West: case Sued: R.RechtsDrehen() case Ost: R.umkehren() } if R.NachbarLeer() { if R.Gelaufen1() { } } else { if R.Geschoben1() { } } } else { switch R.richtung { case Nord: R.LinksDrehen() case West: if T == 0 { if R.Gelaufen1() { } } else { for R.Gelaufen1() { } } case Sued: R.RechtsDrehen() case Ost: R.umkehren() } } case kbd.Right: if Sokoban { switch R.richtung { case Nord: R.RechtsDrehen() case West: R.umkehren() case Sued: R.LinksDrehen() case Ost: } if R.NachbarLeer() { if R.Gelaufen1() { } } else { if R.Geschoben1() { } } } else { switch R.richtung { case Nord: R.RechtsDrehen() case West: R.umkehren() case Sued: R.LinksDrehen() case Ost: if T == 0 { if R.Gelaufen1() { } } else { for R.Gelaufen1() { } } } } case kbd.Up: if Sokoban { switch R.richtung { case Nord: case West: R.RechtsDrehen() case Sued: R.umkehren() case Ost: R.LinksDrehen() } if R.NachbarLeer() { if R.Gelaufen1() { } } else { if R.Geschoben1() { } } } else { if T == 2 { R.Entmarkieren() } else { switch R.richtung { case Nord: if T == 0 { if R.Gelaufen1() { } } else { for R.Gelaufen1() { } } case West: R.RechtsDrehen() case Sued: R.umkehren() case Ost: R.LinksDrehen() } } } case kbd.Down: if Sokoban { switch R.richtung { case Nord: R.umkehren() case West: R.LinksDrehen() case Sued: case Ost: R.RechtsDrehen() } if R.NachbarLeer() { if R.Gelaufen1() { } } else { if R.Geschoben1() { } } } else { if T == 2 { R.Markieren() } else { switch R.richtung { case Nord: R.umkehren() case West: R.LinksDrehen() case Sued: if T == 0 { if R.Gelaufen1() { } } else { for R.Gelaufen1() { } } case Ost: R.RechtsDrehen() } } } case kbd.Pos1: if !Sokoban { if R.Gemauert1() { } } case kbd.End: if !Sokoban { if R.Entmauert1() { } } case kbd.Tab: if !Sokoban { switch T { case 0: if Roboterwelt.markiert(R.Y, R.X) { R.Entmarkieren() } else { R.Markieren() } /* R.Markieren () 1: // unter X funktioniert Umschalt + Tab nicht R.Entmarkieren () } else { R.allesEntmarkieren () */ } } case kbd.Ins: if !Sokoban { if R.tasche > 0 { R.Legen1() } } case kbd.Del: if !Sokoban { if T == 0 { R.Leeren1() } else { Roboterwelt.klotzen(R.Y, R.X, 0) } } case kbd.Back: for len(R.aktionen) > 0 { switch R.letzteAktion() { case Links: R.linksDrehenZurueck() case Rechts: R.rechtsDrehenZurueck() case Weiter: R.laufen1zurueck() case Zurueck: R.zuruecklaufen1zurueck() case KlotzWeg: R.leeren1zurueck() case KlotzHin: R.legen1zurueck() case KlotzWeiter: R.schieben1zurueck() case MarkeHin: R.markierenZurueck() case MarkeWeg: R.entmarkierenZurueck() case MauerHin: R.mauern1zurueck() case MauerWeg: R.entmauern1zurueck() } if T == 0 { break } } case kbd.Help: if Sokoban { errh.WriteHelp(Sokobanhilfe[:]) } else { errh.WriteHelp(Hilfe[:]) } case kbd.LookFor: // Roboter wechseln case kbd.Act: // neuen Roboter initialisieren case kbd.Cfg: // terminieren (R) case kbd.Mark: if !Sokoban { R.Markieren() } case kbd.Demark: if !Sokoban { if T == 0 { R.Entmarkieren() } else { R.allesEntmarkieren() } } case kbd.Paste: case kbd.Deposit: case kbd.Black: case kbd.Red: case kbd.Green: case kbd.Blue: case kbd.PrintScr: img.Print(0, 0, scr.NX(), scr.NY()-scr.NY1()) case kbd.Roll: if T == 0 { // Roboter wechseln } else { // terminieren (R) } case kbd.Pause: // Roboter killen case kbd.Go: /* case kbd.Here: if scr.UnderMouse (2 * R.Y + 1, 4 * R.X, 4, 2) { // ist angeklickt } */ case kbd.Pull: // wenn Roboter getroffen, vorläufig hierhin case kbd.Hither: // wenn Roboter getroffen, endgültig hierhin case kbd.There: case kbd.Push: case kbd.Thither: case kbd.This: case kbd.Move: case kbd.Thus: case kbd.Navigate: } amEditieren = false schrittweise = s }
func main() { // h := [...]string{ // 0 1 2 3 4 5 6 7 // 012345678901234567890123456789012345678901234567890123456789012345678901234567 " Art (Farbe) für neue Figur auswählen: (Umschalt- +) Leer- oder Rolltaste ", // " Schriftgröße auswählen: Alt- + Leer- oder Rolltaste ", " neue Figur erzeugen: linke Maustaste, ", " Streckenzüge, Polygone und Kurven ", " mit rechter Maustaste abschließen, ", " Texteingabe mit Eingabetaste beenden ", " Figur ändern: Alt- + linke Maustaste, die 'Punkte' ", " mit rechter Maustaste verschieben, ", " mit linker Maustaste abschließen ", " Figur färben: Umschalt-, Alt- + linke Maustaste ", " (alle) Figur(en) markieren: (Umschalt- +) F5-Taste oder ", " (Alt- +) mittlere Maustaste ", " (alle) Figur(en) entmarkieren: (Umschalt- +) F6-Taste oder ", " Umschalt- + (Alt- +) mittl. Maustaste", " markierte Figur(en) kopieren: Umschalt- + linke Maustaste ", " (markierte) Figur(en) verschieben: (Umschalt- +) rechte Maustaste ", " (markierte) Figur(en) löschen: (Umschalt- +) Entfernungtaste oder ", " (Umschalt-,) Alt- + rechte Maustaste ", " letzte gelöschte Figur zurückholen: Rücktaste (<-) ", " letzte erzeugte Figur löschen: Umschalt- + Rücktaste (<-) ", "letzte gelöschte mark. Fig. zurückholen: Alt- + Rücktaste (<-) ", "Hintergrundfarbe umschalten (auswählen): (Umschalt- +) F4-Taste ", " Figuren aus eBoard holen und markieren: F7-Taste ", " markierte Figuren in eBoard ablegen: F8-Taste ", " eBoard ausdrucken: Drucktaste ", " ePen beenden: Abbruchtaste (Esc) ", " ", " Steuerungstaste (Strg) wirkt wie Umschalttaste "} help := make([]string, len(h)) for i := 0; i < len(h); i++ { str.Set(&help[i], h[i]) } scr.Switch(scr.SXGA) actColour = col.ScreenF paperColour = col.ScreenB // fo = scr.Normal figure = fig2.New() newFigure := fig2.New() newFigure.SetColour(actColour) figures, copiedFigures, image = seq.New(newFigure), seq.New(newFigure), seq.New(newFigure) cuttedFigures, depot = seq.New(newFigure), seq.New(newFigure) stack = stk.New(newFigure) name, filename := names() if filename == "" { return } origname := filename load(figures, filename) // extract (paperColour) write() var x0, y0 int // kbd.Push var movable bool var Schub int loop: for { scr.MouseCursor(true) // control(); write() c, cmd, d := kbd.Read() if cmd == kbd.None { switch c { case ' ': cmd = kbd.Roll } } xm, ym := scr.MousePosGr() switch d { case 0: Schub = 8 case 1: Schub = int(scr.NY() / 40) default: Schub = int(scr.NX() / 8) } switch cmd { case kbd.Esc: break loop case kbd.Enter: // actualize ? case kbd.Back: switch d { case 0: ins(top()) case 1: delLast() default: getMarked() } case kbd.Left: kick(spc.Right, Schub) case kbd.Right: Schub = -Schub kick(spc.Right, Schub) case kbd.Up: kick(spc.Top, Schub) case kbd.Down: Schub = -Schub kick(spc.Top, Schub) case kbd.Del: switch d { case 0: if deleted(xm, ym) { push() } default: delMarked() } case kbd.Tab: // free for use case kbd.Help: scr.SwitchFontsize(font.Normal) errh.WriteHelp(help) case kbd.LookFor: // wird für die Auswahl des eBoards verwendet - NEIN, sondern: load(figures, filename) write() case kbd.Act: // inject (paperColour) store(figures, filename) case kbd.Cfg: paperColour = sel.Colour() bgColour(paperColour) case kbd.Mark: switch d { case 0: mark(xm, ym, true) case 1: markAll(true) default: showMarked() } case kbd.Demark: switch d { case 0: mark(xm, ym, false) case 1: markAll(false) default: showMarked() } case kbd.Deposit: writeMarked() case kbd.Paste: readMarked() case kbd.PrintScr: print(name) case kbd.Roll: switch d { case 0: newFigure.Select() case 1: actColour = sel.Colour() newFigure.SetColour(actColour) case 2: scr.SwitchFontsize(font.Normal) // fo = sel.Size (actColour) // newFigure.SetFont (fo) } case kbd.Here: switch d { case 0: generate(newFigure) case 1: copyMarked() case 2: change(xm, ym) case 3: setColours(xm, ym, actColour) } case kbd.There: movable = underMouse(uint(xm), uint(ym)) && d <= 1 x0, y0 = xm, ym // kbd.Push switch d { case 0: if movable { cut(xm, ym) } case 1: if movable { cutMarked() } case 2: if deleted(xm, ym) { push() } default: delMarked() write() } case kbd.Push: if movable { switch d { case 0: move(xm-x0, ym-y0) case 1: moveMarked(xm-x0, ym-y0) } x0, y0 = scr.MousePosGr() } case kbd.Thither: if movable { switch d { case 0: join() case 1: joinMarked() } } case kbd.This: switch d { case 0: mark(xm, ym, true) case 1: mark(xm, ym, false) case 2: markAll(true) case 3: markAll(false) } invMarked() case kbd.Thus: invMarked() } } markAll(false) _, filename = names() if filename == "" { filename = origname } // inject (paperColour) store(figures, filename) // -> Terminieren ker.Terminate() }
func editiert() bool { // scr.Cls() l0, c0 = 0, 0 dc = 0 switch period { case day.Decadic: actualDay.SetFormat(day.Yyyy) actualDay.SetColours(day.YearnumberF, day.YearnumberB) case day.Yearly: case day.HalfYearly, day.Quarterly: ker.Stop("termin.main", 1) case day.Monthly: l0, c0 = 3, 5 dc = 12 // 11 dayattr + 1 actualDay.SetAttribute(setWeekdayColours) actualDay.SetFormat(day.Wd) actualDay.WriteWeek(true, 3, l0, 2) actualDay.WriteWeek(true, 3, l0, 2+6*dc+3) case day.Weekly: l0, c0 = 2, 2 dc = 11 // 7 x 11 == 77 < 80 actualDay.SetAttribute(setWeekdayColours) actualDay.SetFormat(day.Wd) actualDay.WriteWeek(false, dc, l0, c0) case day.Daily: cal.Edit(actualDay, l0, c0) } switch period { case day.Weekly, day.Monthly, day.Quarterly, day.Yearly: dayattr.WriteActual(l1, c1) } var startDate = day.New() var Original = day.New() loop: for { switch period { case day.Yearly: actualDay.SetFormat(day.Dd) case day.Quarterly, day.HalfYearly: errh.Error("nicht erreichbarer Punkt", 3) case day.Weekly, day.Monthly: actualDay.SetFormat(day.Dd_mm_) } if !actualDay.Equiv(startDate, period) { // clearAll (startDate) // alte Zusatzinformationen löschen startDate.Copy(actualDay) switch period { case day.Yearly: dayattr.WriteActual(l1, c1) actualDay.SetFormat(day.Dd) case day.Monthly, day.Weekly: if period == day.Monthly { actualDay.SetColours(day.MonthF, day.MonthB) } else { actualDay.SetColours(day.WeekdayNameF, day.WeekdayNameB) } actualDay.SetFormat(day.Yyyy) actualDay.SetColours(day.YearnumberF, day.YearnumberB) actualDay.Write(0, 0) actualDay.Write(0, 80-4) if period == day.Monthly { actualDay.SetFormat(day.M) } else { actualDay.SetFormat(day.WN) } actualDay.SetColours(day.MonthF, day.MonthB) actualDay.Write(0, 30) actualDay.SetFormat(day.Dd_mm_) } actualDay.SetAttribute(dayattr.Attrib) write() writeAll(actualDay) } l, c := pos(actualDay) dayattr.Attrib(actualDay) Original.Copy(actualDay) switch period { case day.Daily: case day.Weekly: actualDay.Edit(l0+l, c0+c+3) case day.Monthly, day.Quarterly, day.HalfYearly, day.Yearly: actualDay.Edit(l0+l, c0+c) case day.Decadic: actualDay.Edit(0, 0) } if actualDay.Empty() { actualDay.Copy(Original) } var d uint C := kbd.LastCommand(&d) // actualDay.Write (l0 + l, c0 + c) switch C { case kbd.Enter: for { if period == day.Daily { return false } else { period-- if period == day.HalfYearly { period-- } if period == day.Quarterly { period-- } } if d == 0 { return false } else { d-- } } case kbd.Esc, kbd.Back: for { if period == day.Decadic { break loop } else { period++ if period == day.Quarterly { period++ } if period == day.HalfYearly { period++ } } if d == 0 { return false } else { d-- } } case kbd.Tab: dayattr.Change(d == 0) write() dayattr.WriteActual(l1, c1) C = kbd.Enter // see above case kbd.Help: errh.WriteHelp(help) case kbd.LookFor: dayattr.Normalize() dayattr.WriteActual(l1, c1) cal.EditWord(l1, c1+1+8) dayattr.Clr() cal.LookFor(func(a Any) { dayattr.Actualize(a.(*day.Imp), true) }) write() if period == day.Weekly { writeAll(actualDay) } C = kbd.Enter // so "actualDay" is not influenced case kbd.Mark, kbd.Demark: dayattr.Actualize(actualDay, C == kbd.Mark) dayattr.Attrib(actualDay) actualDay.Write(l0+l, c0+c) C = kbd.Down case kbd.PrintScr: // TODO Zusatzinformationen switch period { case day.Yearly: actualDay.PrintYear(0, 0) prt.GoPrint() /* case day.Monthly: actualDay.PrintMonth (true, 1, 3, dc, l0, c0) prt.Printout() case day.Daily: cal.Print (0, 0) prt.Printout() */ } /* case kbd.Here: // , kbd.There, kbd.This: switch period { case day.Yearly: // day.mitMausImJahrAendern (actualDay) case day.Monthly: l0 = 3, c0 = 5; dc = 12 // day.mitMausImMonatAendern (actualDay, true, 1, 3, dc, l0, c0) case day.Weekly: l0 = 2, c0 = 2; dc = 11 // day.mitMausInWocheAendern (actualDay, false, dc, l0, c0) } */ default: if period == day.Decadic { if d == 0 { d = 3 } else { d = 5 } } } switch C { case kbd.Here, kbd.There, kbd.This: if period == day.Yearly { switch C { case kbd.Here: period = day.Monthly case kbd.There: period = day.Weekly case kbd.This: period = day.Daily } C = kbd.Enter return false } default: actualDay.Change(C, d) } } return true }