func (x *Imp) SetFormat(f, t string) { // x.rep[falseVal] = f x.length = str.ProperLen(x.rep[falseVal]) if x.length == 0 { x.rep = [nValues]string{" ", "n", "j"} return } x.rep[trueVal] = t n := str.ProperLen(x.rep[falseVal]) if n > x.length { x.length = n } x.rep[undecidable] = str.Clr(x.length) }
func (f *Imp) Write() { // if f.Empty() { return } scr.Colour(f.colour) switch f.sort { case Pointset: scr.Pointset(f.x, f.y) case Segments: scr.Segments(f.x, f.y) case Polygon: scr.Polygon(f.x, f.y) if f.filled { // scr.PolygonFull (f.x, f.y) // not yet implemented } case Curve: scr.Curve(f.x, f.y) if f.filled { n := len(f.x) - 1 scr.CircleFull(f.x[n], f.y[n], 4) // ? } case InfLine: scr.InfLine(f.x[0], f.y[0], f.x[1], f.y[1]) case Rectangle: if f.filled { scr.RectangleFull(f.x[0], f.y[0], f.x[1], f.y[1]) } else { scr.Rectangle(f.x[0], f.y[0], f.x[1], f.y[1]) } case Circle: if f.filled { scr.CircleFull(f.x[0], f.y[0], uint(f.x[1])) } else { scr.Circle(f.x[0], f.y[0], uint(f.x[1])) } case Ellipse: if f.filled { scr.EllipseFull(f.x[0], f.y[0], uint(f.x[1]), uint(f.y[1])) } else { scr.Ellipse(f.x[0], f.y[0], uint(f.x[1]), uint(f.y[1])) } case Text: bx.Wd(str.ProperLen(f.tx)) bx.ColourF(f.colour) bx.WriteGr(f.tx, f.x[0], f.y[0]) case Image: // if bewegt { // scr.RectangleFullInv (...) // } else { // copy from Imageptr in Framebuffer // } img.Get(f.tx, uint(f.x[0]), uint(f.y[0])) } }
func isMonth(Monat *uint, Wort string) bool { // var T string n := str.ProperLen(Wort) if n > 0 { for m := uint(1); m <= maxmonth; m++ { T = str.Part(nameMonth[m], 0, n) if Wort == T { // str.QuasiEq (Wort, T) { *Monat = uint(m) return true } } } return false }
func (f *Imp) editText() { // if f.sort != Text { return } scr.MouseCursor(false) bx.Wd(lenText) bx.ColourF(f.colour) x1 := f.x[0] + int(lenText*scr.NX1()) - 1 if x1 >= xx { x1 = xx - 1 } y1 := f.y[0] + int(scr.NY1()) - 1 if y1 >= yy { y1 = yy - 1 } scr.SaveGr(uint(f.x[0]), uint(f.y[0]), uint(x1), uint(y1)) bx.SetTransparent(false) f.tx = str.Clr(lenText) // wörkeraunt bx.EditGr(&f.tx, uint(f.x[0]), uint(f.y[0])) bx.SetTransparent(true) scr.RestoreGr(uint(f.x[0]), uint(f.y[0]), uint(x1), uint(y1)) var T uint if kbd.LastCommand(&T) == kbd.Enter { bx.SetTransparent(true) // scr.RestoreGr (f.x[0], f.y[0], x1, y1) bx.WriteGr(f.tx, f.x[0], f.y[0]) k := str.ProperLen(f.tx) 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] + int(scr.NX1()*k) - 1 f.y[1] = f.y[0] + int(scr.NY1()) - 1 scr.WarpMouseGr(f.x[0], f.y[1]) } else { // f.tx = str.Clr (lenText) // bx.WriteGr (f.tx, f.x[0], f.y[0]) // f.tx = "" // f.x, f.y = nil, nil } scr.MouseCursor(true) }
func (x *Imp) write() { // r := x.Radius() /* if r <= R0 { scr.CircleFull (int(x.x), int(x.y), R0) } else { for n:= uint(0); n <= 1; n++ { scr.Circle (int(x.x), int(x.y), r + n) } } */ if x.length > 0 { n := str.ProperLen(x.name) xx := x.x - (n*scr.NX1())/2 + 1 yy := x.y - scr.NY1()/2 + 1 switch x.lab { case zentral: case rechts: xx = x.x + scr.NX1() + 1 case oben: yy -= 5 * scr.NY1() / 6 case links: xx = x.x - n*scr.NX1() - scr.NX1() + 1 case unten: yy += 5 * scr.NY1() / 6 } bx.SetTransparent(transparent) bx.Wd(x.length) bx.WriteGr(x.name, int(xx), int(yy)) } if r <= R0 { scr.CircleFull(int(x.x), int(x.y), R0) } else { for n := uint(0); n <= 1; n++ { scr.Circle(int(x.x), int(x.y), r+n) } } }
func (x *Imp) Defined(s string) bool { // if str.Empty(s) { x.Clr() return true } i := uint(0) str.Move(&s, true) l := str.ProperLen(s) if str.Contains(s, ' ', &i) && s[0] == '0' { n := uint(0) if nat.Defined(&n, s[1:i]) { // i <= l x.prefix = uint16(n) if l == i { return false } s = s[i:l] } else { return false } } else { x.prefix = 0 } str.Move(&s, true) str.RemAllSpaces(&s) if s == "" { x.number = uint(x.prefix) x.prefix = 0 return true } if nat.Defined(&x.number, s) { return true } else { x.prefix = 0 x.number = 0 } return false }
func defined(n *uint, s string) bool { // if s == "" { return false } str.Move(&s, true) l := str.ProperLen(s) *n = uint(0) var b byte for i := 0; i < int(l); i++ { if isDigit(s[i]) { b = s[i] - '0' if *n <= (MaxNat-uint(b))/10 { *n = 10**n + uint(b) } else { return false } } else { return false } } return true }
func (x *Imp) Defined(s string) bool { // x.Clr() if str.Empty(s) { return true } str.Move(&s, true) x.geq0 = s[0] != '-' switch s[0] { case '+', '-': str.Rem(&s, 0, 1) } n := str.ProperLen(s) var p uint if str.Contains(s, '/', &p) { s1 := str.Part(s, p+1, n-p-1) if nat.Defined(&x.denom, s1) { if x.denom >= max { return false } } else { return false } } else { p = n x.denom = 1 } s1 := str.Part(s, 0, p) if nat.Defined(&x.num, s1) { if x.num >= max { return false } } else { return false } return true }
func (x *Imp) Defined(s string) bool { // if str.Empty(s) { x.Clr() return true } var d Imp d.day, d.month, d.year = x.day, x.month, x.year var T string var l, p uint n, ss, P, L := nat.DigitSequences(s) switch x.fmt { case Dd, // e.g. " 8" Dd_mm_, // e.g. " 8.10." Dd_mm_yy, // e.g. " 8.10.07" Dd_mm_yyyy: // e.g. " 8.10.2007" *): switch n { case 1: l = 2 case 2, 3: l = L[0] default: return false } // see below case Dd_M, // e.g. "8. Oktober" Dd_M_yyyy: // e.g. "8. Oktober 2007" if x.fmt == Dd_M { if n != 1 { return false } } else { if n != 2 { return false } } if !str.Contains(s, '.', &p) { return false } if x.fmt == Dd_M_yyyy { // l = str.ProperLen (s) // T = str.Part (s, p, l - p) T = ss[1] if !nat.Defined(&d.year, T) { return false } } T = ss[0] str.Move(&T, true) if !nat.Defined(&d.day, T) { return false } T = str.Part(s, p+1, P[1]-p-1) str.Move(&T, true) if !isMonth(&d.month, T) { return false } return x.defined(d.day, d.month, d.year) case Yymmdd: // e.g. "090418" if !nat.Defined(&d.year, str.Part(s, 0, 2)) { return false } if !nat.Defined(&d.month, str.Part(s, 2, 2)) { return false } if !nat.Defined(&d.day, str.Part(s, 4, 2)) { return false } return x.defined(d.day, d.month, d.year) case Yyyymmdd: // e.g. "20090418" if !nat.Defined(&d.year, str.Part(s, 0, 4)) { return false } if !nat.Defined(&d.month, str.Part(s, 4, 2)) { return false } if !nat.Defined(&d.day, str.Part(s, 6, 2)) { return false } return x.defined(d.day, d.month, d.year) case Yy, // e.g. "08" Yyyy: // e.g. "2007" if n != 1 { return false } if nat.Defined(&d.year, ss[0]) { return x.defined(d.day, d.month, d.year) } else { return false } case Wd, // e.g. "Mo" WD: // e.g. "Monday" return false // Fall noch nicht erledigt case Mmm, // e.g. "Mon" M: // e.g. "Oktober" if !isMonth(&d.month, s) { return false } return x.defined(d.day, d.month, d.year) case Myyyy: // e.g. "Oktober 2007" if n != 1 { return false } if !nat.Defined(&d.year, ss[0]) { return false } if !str.Contains(s, ' ', &p) { return false } if !isMonth(&d.month, str.Part(s, 0, p)) { return false } return x.defined(d.day, d.month, d.year) case Wn, // e.g. "1" (.Woche) WN: // e.g. "1.Woche" if n != 1 { return false } if nat.Defined(&n, T) { if 0 < n && n <= 3 { d.day, d.month, d.year = 1, 1, x.year c := internalCode(d) w := weekday(d) if w > Thursday { c += 7 } // see Weeknumber if c < uint16(w) { return false } c -= uint16(w) // so c is a Monday d.Decode(Encode(uint(c) + 7*n)) if d.year == x.year { x.day = d.day x.month = d.month return true } } return false } case WNyyyy: // e.g. "1.Woche 2007" return false // not yet implemented case Qu: // e.g. " I/06" if n != 1 { return false } if !str.Contains(s, '/', &p) { return false } if !nat.Defined(&d.year, ss[0]) { return false } T = str.Part(s, 0, p) str.Move(&T, true) n = str.ProperLen(T) if T[0] != 'I' { return false } switch n { case 1: d.month = 1 case 2: switch T[1] { case 'I': d.month = 4 case 'V': d.month = 10 default: return false } case 3: if T[1] == 'I' && T[2] == 'I' { d.month = 7 } default: return false } return x.defined(d.day, d.month, d.year) } if !nat.Defined(&d.day, str.Part(s, P[0], l)) { return false } if n == 1 { if L[0] > 8 { return false } // maximal "Dd_mm_yyyy" if L[0] > 2 { if !nat.Defined(&d.month, str.Part(s, P[0]+2, 2)) { return false } } if L[0] > 4 { if !nat.Defined(&d.year, str.Part(s, P[0]+4, L[0]-4)) { return false } } } else { // n == 2, 3 if !nat.Defined(&d.month, ss[1]) { return false } if n == 2 && x.Empty() { d.year = today.(*Imp).year } if n == 3 { if !nat.Defined(&d.year, ss[2]) { return false } } } return x.defined(d.day, d.month, d.year) }
func hasSuffix(a Any) bool { // var p uint return str.IsPart(ptSuffix, a.(string), &p) && p == str.ProperLen(a.(string))-uint(len(ptSuffix)) }
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) }
func (x *Imp) ProperLen() uint { // return str.ProperLen(x.content) // return str.ProperLen (x.String ()) }