예제 #1
0
func (cs *ColoredScrollingString) Print(x, y int, width int, scrolling, is_highlighted bool, tick_id uint) {
	if tick_id == cs.last_print_tick_id+1 && scrolling {
		cs.tick_scrolling(width)
	} else if tick_id != cs.last_print_tick_id || !scrolling {
		cs.reset()
	}
	cs.last_print_tick_id = tick_id

	bg := get_bg_color(is_highlighted)

	var_scroll := cs.scroll_at
	var i int = 0
	for ; i < len(cs.strings) && var_scroll > len(cs.strings[i]); i++ {
		var_scroll -= len(cs.strings[i])
	}
	var x_at = x
	if i < len(cs.strings) {
		first_string := cs.strings[i][var_scroll:]
		util.WriteString(x_at, y, width, cs.colors[i], bg, first_string)
		x_at += len(first_string)
		width -= len(first_string)
		i++
	}
	for ; i < len(cs.strings) && width > 0; i++ {
		util.WriteString(x_at, y, width, cs.colors[i], bg, cs.strings[i])
		x_at += len(cs.strings[i])
		width -= len(cs.strings[i])
	}
}
예제 #2
0
func (pl *PrintableListing) PrintListing() {
	var dir_header_fg termbox.Attribute
	if pl.filter_nomatch {
		dir_header_fg = termbox.ColorRed
	} else {
		dir_header_fg = termbox.ColorWhite
	}

	pl.col_at = pl.calc_start_column()
	util.WriteString(0, 0, pl.width, dir_header_fg, termbox.ColorBlue, pl.header)
	pl.rows = pl.height - 1
	pl.cols = (pl.items.Len() / pl.height) + 1
	max_cols := (pl.width / pl.column_width) + 1
	available_boxes := max_cols * pl.rows
	start_at := pl.col_at * pl.rows

	var i int = 0
	for e := pl.items.Front(); i-start_at < available_boxes; {
		if i < start_at {
			i++
			if e == nil {
				panic(errors.New(fmt.Sprintf("col_at: %d", pl.col_at)))
			}
			e = e.Next()
			continue // Fast forward
		}

		effective_index := i - start_at

		if e != nil {
			pl.print_entry(
				effective_index%pl.rows, effective_index/pl.rows,
				e, e == pl.highlighted_element)

			e = e.Next()
		} else {
			col := effective_index / pl.rows
			row := effective_index % pl.rows
			str_width := util.Min(pl.column_width, pl.width-(col*pl.column_width))
			util.WriteString(
				col*pl.column_width, row+1, str_width,
				termbox.ColorBlack, termbox.ColorBlack, "")
		}
		i++
	}
}
예제 #3
0
func (cl *CommandLine) Draw(draw_cursor bool) {
	cmd_length := cl.get_visible_length()
	cmd := string(cl.Cmd[:cmd_length])
	util.WriteString(cl.X, cl.Y, cl.Length, cl.FG, cl.BG, cl.Prefix)
	util.WriteString_FillWithChar(cl.X+len(cl.Prefix), cl.Y, cl.Length, cl.FG, cl.BG, cmd, cl.FillRune)
	if draw_cursor {
		termbox.SetCursor(cl.X+len(cl.Prefix)+util.Min(cl.cursor_at, cmd_length), cl.Y)
	}
}
예제 #4
0
파일: textbox.go 프로젝트: chrigrah/nextplz
func (tb *TextBox) draw_question() {
	startx := tb.X + 2
	starty := tb.Y + 2
	stopx := tb.X + tb.Width - 2
	line_width := stopx - startx
	question_array := []rune(tb.question)

	for i := starty; len(question_array) > 0; i++ {
		str_len := util.Min(line_width, len(question_array))
		str := string(question_array[:str_len])
		util.WriteString(startx, i, line_width, termbox.ColorWhite, termbox.ColorBlue, str)
		question_array = question_array[str_len:]
	}
}
예제 #5
0
func (sl *StatusLine) Draw() {
	util.WriteString(sl.X, sl.Y, sl.Length, sl.FG, sl.BG, sl.Status)
}