func (X *Imp) Write(l, c uint) { // r := rep[X.nr] switch format { case Short: switch system { case Life: f, b := r.cf[X.mark], r.cb[X.mark] if X.nr == nothing { f, b = b, f } x, y := int(8*c)+8, int(16*l)+8 scr.Colour(f) scr.Circle(x, y, 6) scr.Circle(x, y, 5) scr.Colour(b) scr.CircleFull(x, y, 2) case Eco: for y := 0; y < Height; y++ { for x := 0; x < Width; x++ { f, b := r.cf[X.mark], r.cb[X.mark] // ! if r.img[y][x] == ' ' { f, b = b, f } scr.Colours(f, b) scr.Point(Width*int(c)/2+x, Height*int(l)+y) } } } case Long: scr.Colour(r.cf[plantNothing]) scr.Write(r.word, l, c) } }
func (x *Imp) Write(l, c uint) { // scr.Colours(col.White, col.Blue) scr.WriteNat(x.num, l, c) c += 4 for i := uint(0); i < max; i++ { scr.Colours(col.Yellow, col.Red) scr.WriteNat(x.pos[i], l, c) c += 4 scr.Colours(col.White, col.Blue) scr.Write(x.content[i].(*text.Imp).String(), l, c) c += 10 } scr.Colours(col.Yellow, col.Red) scr.WriteNat(x.pos[max], l, c) }
func suchen() { // /* const maxU = 8 var ( startlinie, ziellinie [maxU]Linie startnummer, zielnummer [maxU]uint n, imin, kmin uint ) t1, t2:= netz.Get2 () bhf1, bhf2:= t1.(*bahnhof.Imp), t2.(*bahnhof.Imp) startlinie [0], startnummer [0] = bhf1.Linie (), bhf1.Nummer () ziellinie [0], zielnummer [0] = bhf2.Linie (), bhf2.Nummer () ss, zz:= 1, 1 netz.Trav (func (a Any) { bhf:= a.(*bahnhof.Imp) if bhf.Equiv (bhf1) { startlinie [ss], startnummer [ss] = bhf.Linie (), bhf.Nummer () ss ++ } else if bhf.Equiv (bhf2) { ziellinie [zz], zielnummer [zz] = bhf.Linie (), bhf.Nummer () zz ++ } }) nmin:= uint(ker.MaxNat) for i:= 0; i < ss; i++ { for k:= 0; k < zz; k++ { l, n:= startlinie [i], startnummer [i] l1, n1:= ziellinie [k], zielnummer [k] if ! netz.ExPred2 (func (a Any) bool { b:= a.(*bahnhof.Imp); return b.Linie() == l && b.Nummer() == n }, func (a Any) bool { b:= a.(*bahnhof.Imp); return b.Linie() == l1 && b.Nummer() == n1 }) { ker.Stop (pack, 4) } netz.Actualize () n = netz.LenAct () if n < nmin { nmin = n imin, kmin = uint(i), uint(k) } } } l, n:= startlinie [imin], startnummer [imin] l1, n1:= ziellinie [kmin], zielnummer [kmin] if ! netz.ExPred2 (func (a Any) bool { b:= a.(*bahnhof.Imp); return b.Linie() == l && b.Nummer() == n }, func (a Any) bool { b:= a.(*bahnhof.Imp); return b.Linie() == l1 && b.Nummer() == n1 }) { ker.Stop (pack, 5) } */ netz.Actualize() write(true) scr.Colours(col.HintF, col.HintB) scr.SwitchTransparence(false) na := netz.LenAct() scr.Write("kürzeste Verbindung "+nat.String(na)+" Minuten", 0, 0) scr.SwitchTransparence(true) }
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() }
func (R *Imp) melden() { // if Roboterwelt.kloetze(R.Y, R.X) > 0 { nat.SetColours(farbe[R.nr], farbeH) nat.Write(uint(Roboterwelt.kloetze(R.Y, R.X)), 0, 32+2) } else { scr.Colours(farbeH, farbeH) scr.Write(" ", 0, 32) } }
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() }
func (x *Imp) Write(l, c uint) { // if x.num == 0 { return } scr.Colours(x.cF, x.cB) l += x.l0 for i := uint(0); i < x.num; i++ { scr.Write(x.mask[i], l+x.l[i], c+x.c[i]) } }
func ProtokollSchalten(ein bool) { // sollProtokolliertWerden = ein scr.Colours(col.ErrorF, col.ErrorB) if sollProtokolliertWerden { // rob.aktionsfolge = rob.aktionsfolge [0:0] scr.Write("Protokoll eingeschaltet", 0, scr.NColumns()-23) } else { scr.Write(" ", 0, scr.NColumns()-23) } }
func (x *Imp) Write() { // const n0 = 1 for n := uint(0); n < x.file.Num(); n++ { scr.Colours(col.Yellow, col.Green) scr.WriteNat(n, n0+n, 0) // x.tmp = x.read (n) // x.tmp.Write (n0 + n, 8) x.read(n).Write(n0+n, 4) } for d := uint(1); d < maxDepth; d++ { scr.WriteNat(x.idx[d], n0+d, 70) } }
func (W *Welt) Ausgeben() { // l := str.Clr(scr.NColumns()) scr.Colours(farbeV, farbeH) scr.Write(l, 0, 0) // kollidiert mit geplanter Ausgabe des Weltnamens scr.Write(l, 1, 0) scr.Write(l, scr.NLines()-2, 0) // scr.Write (l, scr.NLines() - 3, 0) for y := null; y < nY; y++ { for x := null; x < nX; x++ { platzAusgeben(y, x) } } W.schatten.ausgeben() }
func (R *Imp) programmErzeugen() { // programmdatei = pseq.New(byte(0)) heute := day.New() heute.SetFormat(day.Dd) heute.Actualize() programmdatei.Name(env.User() + "-" + heute.String() + ".go") // TODO aktuelle Zeit ? programmdatei.Clr() scr.Cls() scr.Colours(col.Yellow, col.DarkBlue) prog("package main" + LF + LF + "import . \"murus/robo\"" + LF) prog("func main () {" + LF + "//") Robo.Trav(func(a obj.Any) { prog(" " + rob.Aktionstext[a.(rob.Aktion)] + "()") }) prog(" Fertig()" + LF + "}") programmdatei.Terminate() }
func (x *Imp) Edit(l, c uint) { // b := x.symbol scr.Colours(x.cF, x.cB) scr.Write1(b, l, c) loop: for { scr.Warp(l, c, scr.Understroke) b = kbd.Byte() switch { case ' ' <= b, b < 128, z.IsLatin1(b): break loop } } scr.Write1(b, l, c) x.symbol = b }
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 }
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() }
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 }
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) } }
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) } }
func (x *Imp) Write(l, c uint) { // scr.Colours(x.cF, x.cB) scr.Write1(x.symbol, l, c) }
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() }
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) }