示例#1
0
文件: imp.go 项目: CaptainSoOmA/Uni
func (x *Imp) String() string {
	//
	n, f := x.surname.String(), x.firstName.String()
	str.RemSpaces(&n)
	str.RemSpaces(&f)
	nf, fn, b := n+", "+f, f+" "+n, x.bd.String()
	switch x.fmt {
	case VeryShort, Short:
		return nf
	case ShortB:
		return nf + " (" + b + ")"
	case ShortT:
		if !x.ti.Empty() {
			nf = x.ti.String() + " " + nf
		}
		return nf
	case ShortTB:
		if !x.ti.Empty() {
			fn = x.ti.String() + " " + fn
		}
		return nf + " (" + b + ")"
		/* mit Maske:
		   case Long:    // Name, Vorname, m/w     1 Zeile,  64 Spalten
		     return ""
		   case LongB:   // lang, GebDat           1 Zeile,  80 Spalten
		     return ""
		   case LongT:   // lang, Anrede           2 Zeilen, 64 Spalten
		     return ""
		   case LongTB:  // lang, GebDat, Anrede   2 Zeilen, 80 Spalten
		     return ""
		*/
	}
	return nf
}
示例#2
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
}
示例#3
0
文件: imp.go 项目: CaptainSoOmA/Uni
func string_(x float64) string {
	//
	s := strconv.FormatFloat(x, 'f', 2, 64)
	str.Move(&s, true)
	str.RemSpaces(&s)
	return s
}
示例#4
0
文件: imp.go 项目: CaptainSoOmA/Uni
func (x *Imp) Defined(t string) bool {
	//
	str.RemSpaces(&t)
	if str.Empty(t) {
		x.Clr()
		return true
	}
	for c := country(keineAngabe); c < noNations; c++ {
		x.cnt = c
		x.att = Folge[c]
		switch x.fmt {
		case Tld:
			if t == x.att.tld {
				return true
			}
		case Long:
			var p uint
			if str.IsPart(t, x.att.name, &p) && p == 0 {
				return true
			}
		default:
			return false
		}
	}
	return false
}
示例#5
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)
	}
}
示例#6
0
文件: imp.go 项目: CaptainSoOmA/Uni
func (x *Imp) Name(s string) {
	//
	x.name = s
	str.RemSpaces(&x.name)
	x.file.Name(x.name + "." + suffix)
	x.dayset.Clr()
	x.file.Trav(func(a Any) { x.dayset.Ins(a.(*day.Imp)) })
}
示例#7
0
文件: imp.go 项目: CaptainSoOmA/Uni
func defined(s string) (float64, bool) {
	//
	str.Move(&s, true)
	str.RemSpaces(&s)
	r, e := strconv.ParseFloat(s, 64)
	if e != strconv.ErrSyntax {
		return r, true
	}
	return math.NaN(), false
}
示例#8
0
文件: imp.go 项目: CaptainSoOmA/Uni
func (x *Imp) String() string {
	//
	if x.denom == 0 {
		return "Zähler/Nenner"
	}
	s := nat.StringFmt(x.num, 9, false)
	str.Move(&s, true)
	str.RemSpaces(&s)
	if !x.geq0 {
		s = "-" + s
	}
	if x.denom == 1 {
		return s
	}
	s += "/"
	t := nat.StringFmt(x.denom, 9, false)
	str.Move(&t, true)
	str.RemSpaces(&t)
	return s + t
}
示例#9
0
文件: imp.go 项目: CaptainSoOmA/Uni
func EditActual(Z, S uint) {
	//
	actual.Write(Z, S)
	bx.Edit(&actual.text, Z, S)
	str.Move(&actual.text, true)
	str.RemSpaces(&actual.text)
	str.Norm(&actual.text, length)
	actual.Write(Z, S)
	file.Seek(0)
	file.Put(actual.text)
}
示例#10
0
文件: imp.go 项目: CaptainSoOmA/Uni
func (x *Imp) Print(s string, l, c uint) {
	//
	if l >= prt.NLines() || c >= prt.NColumns() {
		return
	}
	str.RemSpaces(&s)
	if len(s) == 0 {
		return
	}
	prt.Print(s, l, c, x.font)
}
示例#11
0
文件: imp.go 项目: CaptainSoOmA/Uni
func (x *Imp) String() string {
	//
	if x.r == x.invalid {
		return str.Clr(x.wd)
	}
	s := real.String(x.r)
	str.Move(&s, true)
	str.RemSpaces(&s)
	str.Norm(&s, x.wd)
	str.Move(&s, false)
	return s
}
示例#12
0
文件: imp.go 项目: CaptainSoOmA/Uni
func (x *Imp) Name(s string) {
	//
	x.name = s
	str.Move(&x.name, true)
	str.RemSpaces(&x.name)
	n := pseq.Length(x.name)
	if n > 0 {
		buf := make([]byte, n)
		f := pseq.New(buf)
		f.Name(x.name)
		buf = f.Get().([]byte)
		f.Terminate()
		x.Decode(buf)
	}
}
示例#13
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)
}
示例#14
0
文件: imp.go 项目: CaptainSoOmA/Uni
func (x *Imp) Rename(s string) {
	//
	x.name = s
	str.Move(&x.name, true)
	str.RemSpaces(&x.name)
	// rest of implementation TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO
	n := pseq.Length(x.name)
	if n > 0 {
		buf := make([]byte, n)
		f := pseq.New(buf)
		f.Rename(x.name)
		//    buf = f.Get ().([]byte)
		f.Terminate()
		//    x.Decode (buf)
	}
}
示例#15
0
文件: imp.go 项目: CaptainSoOmA/Uni
func get(n string, x, y uint) {
	//
	const tst = true
	if str.Empty(n) {
		return
	}
	str.RemSpaces(&n)
	filename := n + suffix
	l := pseq.Length(filename)
	if l == 0 {
		return
	}
	buf := make([]byte, l)
	file := pseq.New(buf)
	file.Name(filename)
	buf = file.Get().([]byte)
	file.Terminate()
	scr.P6Decode(x, y, buf)
}
示例#16
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)
}
示例#17
0
文件: imp.go 项目: CaptainSoOmA/Uni
func size_(n string) (uint, uint) {
	//
	w, h := uint(0), uint(0)
	if str.Empty(n) {
		return w, h
	}
	str.RemSpaces(&n)
	filename := n + suffix
	l := pseq.Length(filename)
	if l == 0 {
		return w, h
	}
	buf := make([]byte, l)
	file := pseq.New(buf)
	file.Name(filename)
	buf = file.Get().([]byte)
	file.Terminate()
	w, h = scr.P6Size(buf)
	return w, h
}
示例#18
0
文件: imp.go 项目: CaptainSoOmA/Uni
func New0(a Any, h string, p uint16, o bool) *Imp {
	//
	if str.Empty(h) || p >= 1<<16-Port0 {
		return nil
	}
	if a == nil {
		a = false
	}
	x := new(Imp)
	if tst {
		println("nchan.New0 started for host", h, "/ port", p)
	}
	x.object, x.width = Clone(a), Codelen(a)
	str.RemSpaces(&h)
	x.farHost = host.New()
	if !x.farHost.Defined(h) {
		errh.Error("Hostname "+h+" is not resolvable", 0)
		Stop(pack, 1)
	}
	x.isServer = host.Local(h)
	x.server = h
	x.port = Port0 + p
	x.oneOne = o
	if x.oneOne {
		if x.isServer {
			x.isServer = first(x.port)
		} else {
			x.isServer = x.farHost.Sonstewas()
		}
	}
	x.buf = make([]byte, x.width)
	//  x.info = true
	if tst {
		println("nchan.New0 for host", h, "is done")
	}
	return x
}
示例#19
0
文件: imp.go 项目: CaptainSoOmA/Uni
func (x *Imp) String() string {
	//
	if x.year == emptyYear {
		return str.Clr(length[x.fmt])
	}
	const mitNullen = true
	s := ""
	switch x.fmt {
	case Dd, Dd_mm_, Dd_mm_yy, Dd_mm_yyyy, Dd_M, Dd_M_yyyy:
		if x.day == 0 {
			Panic("day.String: x.day == 0")
		}
		s = nat.StringFmt(x.day, 2, mitNullen)
		if x.fmt == Dd {
			return s
		}
		s += "."
		switch x.fmt {
		case Dd_M, Dd_M_yyyy:
			s += " " + nameMonth[x.month]
			str.RemSpaces(&s)
			if x.fmt == Dd_M {
				return s
			}
			s += " "
		default:
			s += nat.StringFmt(x.month, 2, mitNullen) + "."
		}
		switch x.fmt {
		case Dd_mm_:

		case Dd_mm_yy:
			s += nat.StringFmt(x.year, 2, true)
		default: // Dd_mm_yyyy, Dd_M_yyyy:
			s += nat.StringFmt(x.year, 4, false)
		}
	case Yymmdd:
		s = nat.StringFmt(x.year%100, 2, true) +
			nat.StringFmt(x.month, 2, true) +
			nat.StringFmt(x.day, 2, true)
	case Yyyymmdd:
		s = nat.StringFmt(x.year, 4, true) +
			nat.StringFmt(x.month, 2, true) +
			nat.StringFmt(x.day, 2, true)
	case Yy:
		s = nat.StringFmt(x.year, 2, true)
	case Yyyy:
		s = nat.StringFmt(x.year, 4, false)
	case Wd:
		s = WdShorttext[x.Weekday(Daily)]
	case WD:
		s = WdText[x.Weekday(Daily)]
	case Mmm, M:
		s = nameMonth[x.month]
		if x.fmt == Mmm {
			s = str.Part(s, 0, 3)
		}
	case Myyyy:
		s = nameMonth[x.month] + " " +
			nat.StringFmt(x.year, 4, false)
	case Wn, WN, WNyyyy:
		s = nat.StringFmt(x.Weeknumber(), 2, false)
		if x.fmt > Wn {
			s += ".Woche"
		}
		if x.fmt == WNyyyy {
			s += " " + nat.StringFmt(x.year, 4, false)
		}
	case Qu:
		switch (x.month - 1) / 3 {
		case 0:
			s = "  I"
		case 1:
			s = " II"
		case 2:
			s = "III"
		case 3:
			s = " IV"
		}
		s += "/" + nat.StringFmt(x.year, 2, true)
	}
	return s
}
示例#20
0
文件: main.go 项目: CaptainSoOmA/Uni
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()
}
示例#21
0
文件: imp.go 项目: CaptainSoOmA/Uni
func (x *Imp) String() string {
	//
	s := x.s[x.f][x.b]
	str.RemSpaces(&s)
	return s
}