Beispiel #1
0
func (B *Imp) Edit(s *string, l, c uint) {
	//
	if l >= scr.NLines() {
		return
	}
	if c >= scr.NColumns() {
		return
	}
	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)
	}
	B.graphical = false
	if B.numerical || B.TRnumerical {
		B.editNumber(false, s, scr.NX1()*c, scr.NY1()*l)
	} else {
		B.editText(false, s, scr.NX1()*c, scr.NY1()*l)
	}
	B.width = b
}
Beispiel #2
0
func (x *Imp) selected(l, c uint) bool {
	//
	n := uint(len(x.nextLevel))
	if n == 0 || !x.isMenu {
		return false
	}
	if n == 1 {
		return true
	}
	bx.Colours(menuheadF, menuheadB)
	bx.Wd(scr.NColumns())
	bx.Write(x.text, l, c)
	errh.Hint(errh.ToSelect)
	i := x.lastPos
	sel.Select(func(p, l, c uint, f, b col.Colour) {
		bx.Colours(f, b)
		bx.Write(x.nextLevel[p].text, l, c)
	}, n, scr.NLines()-2, scr.NColumns(), &i, 2, 0, menuF, menuB)
	if i < n {
		x.lastPos = i
		x.next = x.nextLevel[i]
	}
	errh.DelHint()
	return i < n
}
Beispiel #3
0
func (x *Imp) Exec() {
	//
	l, c := uint(0), uint(0)
	depth++
	if x.isMenu {
		for {
			if x.selected(l, c) {
				x.next.Exec()
			} else {
				break
			}
		}
	} else {
		if x.withTitle {
			bx.Wd(scr.NColumns())
			bx.Colours(menuheadF, menuheadB)
			bx.Write(x.text, l, c)
		} else {
			scr.Clr(l, c, scr.NColumns(), 1)
		}
		x.execute()
		scr.Cls()
	}
	depth--
	if depth == 0 {
		ker.Terminate()
	}
}
Beispiel #4
0
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)
	}
}
Beispiel #5
0
func New(s string) *Imp {
	//
	x := new(Imp)
	str.Set(&x.text, s)
	x.text += " "
	str.Norm(&x.text, scr.NColumns())
	x.isMenu = true
	x.execute = Null
	return x
}
Beispiel #6
0
func Show() {
	//
	if line >= scr.NLines() {
		SetAttributes(Zero, scr.NColumns()-textlength[clock.fmt], col.HintF, col.HintB)
	}
	for {
		clock.Actualize()
		clockbx.Write(clock.String(), line, column)
		Sleep(1) // not precise, but good enough for practical purposes
		// more precise would be: sleep until AlarmClock rings
	}
}
Beispiel #7
0
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
}
Beispiel #8
0
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()
}
Beispiel #9
0
func (x *Imp) Write(l, c uint) {
	//
	s := x.String()
	c0 := c
	for n := 0; n < len(s); n++ {
		scr.Write1(s[n], l, c)
		if c+1 < scr.NColumns() {
			c++
		} else if l+2 < scr.NLines() {
			l++
			c = c0
		} else {
			break
		}
	}
}
Beispiel #10
0
func main() { // just to get all stuff compiled
	//
	var _ chanm.ChannelModel = chanm.New(nil)
	t := integ.String(0)
	_ = real.String(0.0)
	var _ lint.LongInteger = lint.New(0)
	var _ brat.Rational = brat.New()
	var _ Object = date.New()
	var _ buf.Buffer = bpqu.New(0, 1)
	var _ pset.PersistentSet = pset.New(persaddr.New())
	var _ acc.Account = acc.New()
	var _ schol.Scholar = schol.New()
	eye.Touch()
	fuday.Touch()
	gra1.Touch()
	fig.Touch()
	var _ asem.AddSemaphore = asem.New(2)
	var _ barr.Barrier = barr.New(2)
	var _ rw.ReaderWriter = rw.New()
	var _ lr.LeftRight = lr.New()
	var _ lock2.Locker2 = lock2.NewPeterson()
	var _ lockp.LockerP = phil.NewLockNaiv()
	var _ barb.Barber = barb.NewSem()
	var _ smok.Smokers = smok.NewNaiv()
	var _ lock.Locker = dlock.New(nil)
	puls.Touch()
	var _ conn.Connection = conn.New()
	rob.Touch()
	var _ Indexer = audio.New()
	scr.Switch(scr.MaxMode()) // >= scr.PAL
	xx, yy := scr.NColumns(), scr.NLines()
	cf, cl, cb := v.Colours()
	circ(cb, xx/2, yy)
	circ(cl, xx-yy, yy)
	circ(cf, yy, yy)
	t = ""
	errh.MurusLicense("murus", v.String(), "1986-2013  Christian Maurer   http://murus.org", cf, cl, cb, &t)
	col.ScreenB = cb
	done := make(chan bool)
	go drive(cf, cl, cb, done)
	<-done
	ker.Terminate()
}
Beispiel #11
0
func (x *Imp) Edit(l, c uint) {
	//
	s := x.String()
	w := uint(len(s))
	N := scr.NColumns()
	if c >= N-w {
		x.Write(l, c)
		errh.Error("zu wenig Platz auf dem Bildschirm", 0) // TODO
		return
	}
	bx.Wd(N - 1 - c)
	bx.Edit(&s, l, c)
	for {
		if x.Defined(s) {
			break
		} else {
			errh.Error("keine Zahl", 0)
		}
	}
	x.Write(l, c)
}
Beispiel #12
0
func New() *Imp {
	//
	return &Imp{width: scr.NColumns(), cF: col.ScreenF, cB: col.ScreenB, command: kbd.None}
}
Beispiel #13
0
func select_(write WritingCol, n, h, w uint, i *uint, l, c uint, f, b col.Colour) {
	//
	if n == 0 {
		ker.Stop(pack, 1)
	}
	if n == 1 {
		*i = 0
		return
	}
	if h == 0 {
		ker.Stop(pack, 2)
	}
	if h > n {
		h = n
	}
	if w == 0 {
		w = scr.NColumns()
	}
	if w > scr.NColumns() {
		w = scr.NColumns()
	}
	if c+w > scr.NColumns() {
		c = scr.NColumns() - w
	}
	// so, dass letzte Zeile frei bleibt
	if l+h >= scr.NLines() {
		h = scr.NLines() - l - 1
	}
	if *i >= n {
		*i = n - 1
	}
	MouseOn := scr.MouseCursorOn()
	var x, y int
	if MouseOn {
		scr.MouseCursor(false)
		x, y = scr.MousePosGr()
	}
	scr.WarpMouse(l+*i, c)
	scr.Save(l, c, w, h)
	i0, n0 := uint(0), uint(0)
	if *i == 0 {
		n0 = 1
	} // else { n0 = 0 }
	neu := true
loop:
	for {
		if *i < i0 {
			i0 = *i
			neu = true
		} else if *i > i0+h-1 {
			i0 = *i - (h - 1)
			neu = true
		} else {
			neu = *i != n0
		}
		if neu {
			neu = false
			var cF, cB col.Colour
			for j := uint(0); j < h; j++ {
				if i0+j == *i {
					cF, cB = f, b
				} else {
					cF, cB = b, f
				}
				write(i0+j, l+j, c, cF, cB)
			}
		}
		n0 = *i
		C, d := kbd.Command()
		switch C {
		case kbd.Esc, kbd.Thither:
			*i = n
			break loop
		case kbd.Enter, kbd.Hither:
			break loop
		case kbd.Left, kbd.Up:
			if d == 0 {
				if *i > 0 {
					*i--
				}
			} else {
				if *i >= 10 {
					*i -= 10
				}
			}
		case kbd.Right, kbd.Down:
			if d == 0 {
				if *i+1 < n {
					*i++
				}
			} else {
				if *i+10 < n {
					*i += 10
				}
			}
		case kbd.Pos1:
			*i = 0
		case kbd.End:
			*i = n - 1
		case kbd.Go:
			_, yM := scr.MousePosGr()
			if uint(yM) <= l*scr.NY1()+scr.NY1()/2 {
				if *i > 0 {
					*i--
				}
			} else if uint(yM) >= (l+h)*scr.NY1() {
				if *i < n-1 {
					*i++
				}
			} else {
				*i = i0 + uint(yM)/scr.NY1() - l
			}
			/*
			   case kbd.Help:
			     errh.Hint (errh.zumAuswaehlen)
			     kbd.Wait (true)
			     errh.DelHint()
			*/
		}
	}
	scr.Restore(l, c, w, h)
	if MouseOn {
		scr.MouseCursor(true)
		scr.WarpMouseGr(x, y)
	}
}