コード例 #1
0
func (r *LogsDisplay) DrawLogBuffer() {
	utility.WipeArea(r.MarginPos+1, 3, r.width, r.height-2, r.page.Foreground, r.page.Background)

	paneStart := 3
	paneEnd := r.height - 2 // height in rows of the screen

	if len(r.lineBuffer) < (paneEnd - paneStart) { // adjust for length of the buffer
		paneStart = paneEnd - len(r.lineBuffer)
	}

	offset := len(r.lineBuffer) - (paneEnd - paneStart)

	if r.pagingMode {
		offset = r.pagingOffset
	}

	// look at
	for i := paneEnd; i > paneStart; i-- {
		line := r.lineBuffer[(i-paneStart)+offset-1]

		cursor := r.MarginPos + 1

		if line.Source != "" {
			source := fmt.Sprintf("[%s] ", line.Source)
			utility.WriteString(source, cursor, i-1, utility.ColorBrightGreen, r.page.Background)
			cursor += len(source)
		}

		if line.Indent {
			utility.WriteString(">> ", cursor, i-1, utility.ColorBrightGreen, r.page.Background)
			cursor += 3
		}

		utility.WriteString(line.Line, cursor, i-1, r.page.Foreground, r.page.Background)
	}

	if r.pagingMode {
		numberOfPages := math.Ceil(float64(len(r.lineBuffer)) / float64(r.height-5))
		currentPage := math.Ceil(float64(r.pagingOffset)/float64(r.height-5) + 1)

		// offSetIndicator := fmt.Sprintf(" %d / %d ", r.pagingOffset, len(r.lineBuffer))
		offSetIndicator := fmt.Sprintf(" %d / %d ", int(currentPage), int(numberOfPages))
		x := r.width - len(offSetIndicator)
		utility.WriteString(offSetIndicator, x, paneStart, r.page.Foreground, termbox.ColorRed)
	}
}
コード例 #2
0
func (r *NullDisplay) Setup(page *pages.Page) {
	r.page = page

	line := 5
	for y := 0; y < 4; y++ {
		for x := 0; x < 8; x++ {
			for z := 0; z < 8; z++ {
				c1 := termbox.Attribute(256 - y*64 - x*8 - z)
				c2 := termbox.Attribute(1 + y*64 + z*8 + x)
				c3 := termbox.Attribute(256 - y*64 - z*8 - x)
				c4 := termbox.Attribute(1 + y*64 + x*4 + z*4)
				utility.WriteString(fmt.Sprintf("%d,%d,%d", y, x, z), 0, line, c1, r.page.Background)
				utility.WriteString(fmt.Sprintf("%d,%d,%d", y, z, x), 10, line, c2, r.page.Background)
				utility.WriteString(fmt.Sprintf("%d,%d,%d", y, z, x), 20, line, c3, r.page.Background)
				utility.WriteString(fmt.Sprintf("%d,%d,%d", y, x, z), 30, line, c4, r.page.Background)
				line++
			}
		}
	}

	termbox.Flush()
}
コード例 #3
0
func (r *LogsDisplay) Setup(page *pages.Page) {
	r.page = page
	r.width, r.height = termbox.Size()

	utility.WriteString("Filters: ", 2, 3, page.Foreground, page.Background)

	termbox.SetCell(r.MarginPos, 2, rune(pages.LinesVerticalJoinDown), page.Foreground, page.Background)
	termbox.SetCell(r.MarginPos, r.height-2, rune(pages.LinesVerticalJoinUp), page.Foreground, page.Background)

	for i := 3; i < r.height-2; i++ {
		termbox.SetCell(r.MarginPos, i, rune(pages.LinesVLineStd), page.Foreground, page.Background)
	}

	r.DrawOriginList()
	r.DrawLogBuffer()
	termbox.Flush()
}