コード例 #1
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
}
コード例 #2
0
ファイル: imp.go プロジェクト: CaptainSoOmA/Uni
func soundfile() *os.File {
	//
	dev := env.Par(1)
	if dev == "" {
		dev = "cdrom"
	}
	var e error
	cdfile, e = os.OpenFile("/dev/"+dev, syscall.O_RDONLY|syscall.O_NONBLOCK, 0440)
	if e != nil {
		return nil
	}
	cdd = int(cdfile.Fd())
	C.closeTray(C.int(cdd))
	counter := 0
	for { // anfangs dauert's manchmal 'ne Weile ...
		counter++
		if counter > 30 {
			return nil
		}
		_, status = cstatus(cdd)
		if status == invalid {
			ker.Msleep(250 * 1000)
		} else {
			break
		}
	}
	nTracks = uint8(C.nTracks(C.int(cdd)))
	n1 := nTracks + 1
	startFrame = make([]uint, n1)
	StartTime = make([]*clk.Imp, nTracks)
	Length = make([]*clk.Imp, nTracks)
	for t := uint8(0); t <= nTracks; t++ {
		startFrame[t] = uint(C.startFrame(C.int(cdd), C.uchar(t)))
		if t < nTracks {
			StartTime[t] = clk.New()
			Length[t] = clk.New()
			m, s := ms(startFrame[t] - offset)
			StartTime[t].Set(m/60, m%60, s)
		}
		if t > 0 {
			m, s := ms(startFrame[t] - startFrame[t-1] - offset)
			Length[t-1].Set(m/60, m%60, s)
		}
	}
	m, s := ms(startFrame[nTracks] - 2*offset)
	TotalTime.Set(m/60, m%60, s)
	var l, r C.uchar
	C.volRead(C.int(cdd), &l, &r)
	volume_left, volume_right = uint8(l), uint8(r)
	//  C.lockDoor (C.int(cdd))
	Ctrl(All, MaxVol/3)
	return cdfile
}
コード例 #3
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()
}
コード例 #4
0
ファイル: imp.go プロジェクト: CaptainSoOmA/Uni
func Init(w, h uint, cF, cB col.Colour) (uint, uint, uint) {
	//
	initialized = false
	//
	maxX, maxY, bitdepth = Screen()
	bdp := uint(bitdepth)
	switch bdp {
	case 15, 16, 24, 32:
		col.SetColourDepth(bdp)
	default:
		panic("strange colourdepth") /* Terminate (); */ os.Exit(1)
	}
	colourdepth := (bdp + 1) / 8
	col.ScreenF, col.ScreenB = cF, cB
	xx, yy = C.uint(w), C.uint(h)
	window = C.XCreateSimpleWindow(display, C.Window(window0), 0, 0, xx, yy, C.uint(0), C.ulong(0), cc(col.ScreenB))
	//  var E C.XEvent
	//  C.XNextEvent (display, &E) // XCreate... did not produce an XEvent
	C.initialize(display, screen, window)
	t := C.CString(env.Par(0))
	defer C.free(unsafe.Pointer(t))
	C.XStoreName(display, window, t)
	C.XMapRaised(display, window)
	const inputmask = (C.KeyPressMask + // C.KeyReleaseMask +
		C.ButtonPressMask + C.ButtonReleaseMask + C.PointerMotionMask +
		C.ExposureMask + C.StructureNotifyMask)
	C.XSelectInput(display, window, inputmask)
	cursor := C.XCreateFontCursor(display, C.XC_gumby)
	C.XDefineCursor(display, window, cursor)
	graphicsContext = C.XDefaultGC(display, screen)
	//  C.XFlushGC (display graphicsContext)
	C.XSetGraphicsExposures(display, graphicsContext, C.False)
	SetFontsize(16)
	initialized = true
	Colours(cF, cB)
	C.XSetForeground(display, graphicsContext, cc(col.ScreenB))

	C.XFillRectangle(display, C.Drawable(window), graphicsContext, 0, 0, xx, yy)
	pixmap = C.XCreatePixmap(display, C.Drawable(window), xx, yy, bitdepth)
	pixmap1 = C.XCreatePixmap(display, C.Drawable(window), maxX, maxY, bitdepth)
	C.XFillRectangle(display, C.Drawable(pixmap), graphicsContext, 0, 0, xx, yy)
	C.XFillRectangle(display, C.Drawable(pixmap1), graphicsContext, 0, 0, xx, yy)
	C.XSetForeground(display, graphicsContext, cc(col.ScreenF))

	MouseDef(0, 0, int(xx-1), int(yy-1))
	var E C.XEvent
	C.XNextEvent(display, &E)
	var et C.int = C.typ(&E) // et == *E.type
	switch et {
	case C.Expose, C.ConfigureNotify: // zur Erstausgabe
		for C.XCheckTypedEvent(display, et, &E) == C.True {
		}
		//    pp2ff ()
	case KeyPress, KeyRelease, ButtonPress, ButtonRelease, MotionNotify:
		C.XPutBackEvent(display, &E)
	case C.ReparentNotify: // at Switch (?)
		// ignore
	default: // for test purposes
		//    println ("at initializing x:" + txt [et])
	}
	p := C.CString("WM_PROTOCOLS")
	defer C.free(unsafe.Pointer(p))
	wm_protocols := C.XInternAtom(display, p, C.False)
	C.XSetWMProtocols(display, window, &wm_protocols, 1)
	s := C.CString("_NET_WM_STATE")
	defer C.free(unsafe.Pointer(s))
	netwm_state = C.XInternAtom(display, s, C.False)
	f := C.CString("_NET_WM_STATE_FULLSCREEN")
	defer C.free(unsafe.Pointer(f))
	fullscreen = C.XInternAtom(display, f, C.False)
	m := C.CString("navi")
	defer C.free(unsafe.Pointer(m))
	naviAtom = C.XInternAtom(display, m, C.False)
	Eventpipe = make(chan Event)
	go sendEvents()
	//  C.XFlush (display)
	//  println ("init ok")
	return uint(maxX), uint(maxY), colourdepth
}
コード例 #5
0
ファイル: imp.go プロジェクト: CaptainSoOmA/Uni
func DefCall() {
	//
	Name(env.Par(1))
}