Exemple #1
0
func (x *Imp) String() string {
	//
	if x.Empty() {
		return str.Clr(length)
	}
	return nat.StringFmt(x.cent/hundred, nDigits, false) + "," +
		nat.StringFmt(x.cent%hundred, 2, true)
}
Exemple #2
0
func (x *Imp) String() string {
	//
	if x.Empty() {
		return str.Clr(textlength[x.fmt])
	}
	s := ""
	if x.fmt <= Hh_mm_ss { // Hh_mm
		s = nat.StringFmt(x.hour, 2, true) + "."
	}
	s += nat.StringFmt(x.minute, 2, true)
	if x.fmt >= Hh_mm_ss {
		s += ":" + nat.StringFmt(x.second, 2, true)
	}
	return s
}
Exemple #3
0
func (x *Imp) string_ () string {
//
  y:= x.Year () % 100
  tmp.Set (1, 4, y)
  s:= nat.StringFmt (y, 2, true)
  if x.Imp.Less (tmp) {
    tmp.Dec (day.Yearly)
    return "WS " + nat.StringFmt (tmp.Year() % 100, 2, true) + "/" + s
  }
  tmp.Set (1, 10, y)
  if x.Imp.Less (tmp) {
    return "SS " + s
  }
  tmp.Inc (day.Yearly)
  return "WS" + s + "/" + nat.StringFmt (tmp.Year() % 100, 2, true)
}
Exemple #4
0
func write() {
	//
	n, a := cdker.NTracks(), cdker.ActTrack()
	//  cdker.Mutex.Lock()
	bx.Wd(12) // TODO
	bx.Colours(col.HintF, col.HintB)
	bx.Write(cdker.String(), l1, cr)
	var f col.Colour
	for t := uint8(0); t < n; t++ {
		if t == a {
			f = trackTimeF
		} else {
			f = cF
		}
		wr1(uint(t)+1, l0+uint(t), 0, f, cB)
	}
	for c := cdker.Controller(0); c < cdker.NCtrl; c++ {
		ctrlBar[c].Fill(uint(cdker.Volume(c)))
		ctrlBar[c].Write()
	}
	timeBar[0].Def(cdker.Length[a].NSeconds())
	timeBar[0].Fill(cdker.TrackTime.NSeconds())
	timeBar[0].Write()
	timeBar[1].Fill(cdker.Time.NSeconds())
	timeBar[1].Write()
	bx.Wd(2)
	bx.Colours(trackTimeF, cB)
	bx.Write(nat.StringFmt(uint(a)+1, 2, false), l1, cr+wr-2)
	wrt(cdker.TrackTime, clk.Mm_ss, trackTimeF, cB, lt[0]+1, cr)
	wrt(cdker.Length[a], clk.Mm_ss, lengthF, cB, lt[0]+1, cr+wr-5)
	wrt(cdker.Time, clk.Mm_ss, trackTimeF, cB, lt[1]+1, cr)
	//  cdker.Mutex.Unlock()
}
Exemple #5
0
func (x *Imp) String() string {
	//
	n := uint(x.n)
	if n == x.invalid {
		return str.Clr(x.wd)
	}
	return nat.StringFmt(n, x.wd, x.zero)
}
Exemple #6
0
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
}
Exemple #7
0
func stringFmt(z int, l uint) string {
	//
	a := " "
	if z < 0 {
		a = "-"
		z = -z
	}
	w := Wd(z)
	if l < w {
		l = w
	}
	return a + nat.StringFmt(uint(z), l-1, false)
}
Exemple #8
0
func (x *Imp) aus(n, n1 *node.Imp, directed bool) {
	//
	x0, y0, x1, y1, ok := x.pos(n, n1, directed)
	if !ok {
		return
	}
	scr.InfLine(int(x.x), int(x.y), int(x.x1), int(x.y1))
	if directed {
		scr.CircleFull(int(x1), int(y1), r0)
	}
	if zk > 0 && WithValues {
		T := nat.StringFmt(x.val, zk, false)
		bx.WriteGr(T, int(x0), int(y0))
	}
}
Exemple #9
0
func (x *Imp) Edit(N, N1 node.Node, directed bool) {
	//
	n, n1 := N.(*node.Imp), N1.(*node.Imp)
	x.Write(n, n1, directed, true, false)
	x0, y0, _, _, _ := x.pos(n, n1, directed)
	if zk == 0 || !WithValues {
		/* accept only Del
		   _, c, _:= kbd.Read () // ?
		   if c == kbd.Del { x.val = 0 }
		*/
	} else {
		T := nat.StringFmt(x.val, zk, false)
		bx.ColourF(Farbe[0])
		for {
			bx.EditGr(&T, x0, y0)
			if nat.Defined(&x.val, T) {
				break
			}
		}
	}
}
Exemple #10
0
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
}
Exemple #11
0
func name(n uint16) string {
	//
	const d = 5 // n < 2^16 contains at most 5 digits
	return prefix + nat.StringFmt(uint(n), d, true)
}
Exemple #12
0
func (x *Imp) Go() {
	//
	if x.gone {
		return
	}
	x.gone = true
	portstring := nat.StringFmt(uint(x.port), nat.Wd(uint(x.port)), true)
	if x.isServer {
		if x.info {
			println("nchan.Go started on server", x.server)
		}
		x.addr, _ = net.ResolveTCPAddr(tcp, ":"+portstring)
		//    if x.err != nil { Stop (pack, 2) }
		x.list, _ = net.ListenTCP(tcp, x.addr)
		//    if x.err != nil { Stop (pack, 3) }
		if x.oneOne {
			var e error
			x.conn, e = x.list.Accept() // x.conn.RemoteAddr().(*net.TCPAddr).IP == ipFar
			if e != nil || x.conn == nil {
				Stop(pack, 4)
			}
		} else {
			if x.info {
				println("server", x.server, "is up")
			}
			x.in, x.out = make(chan Any), make(chan Any)
			go func() {
				for {
					conn, err := x.list.Accept()
					if err == nil {
						x.nClients++
						go x.serve(conn)
					} else {
						// if tst { println ("not accepted because " + err.String()) }
					}
				}
			}()
		}
	} else { // client
		if tst {
			println("nchan.Go started for", x.server, "as client")
		}
		x.farHost.SetFormat(host.Hostname)
		dialaddr := x.farHost.String() + ":" + portstring
		for {
			//      println ("waiting for server", x.server)
			x.conn, x.err = net.Dial(tcp, dialaddr)
			if x.err == nil {
				break
			}
			time.Sleep(2e9)
		}
		if x.conn == nil {
			Stop(pack, 5)
		}
		if tst {
			println("nchan.Go.Dial", x.server, "war erfolgreich")
		}
		//    if x.info { errh.DelHint () }
	}
}