Exemple #1
0
func (l *CodeEditorLine) offsets(font gxui.Font) []math.Point {
	rect := l.Size().Rect().OffsetX(l.caretWidth)
	runes := l.ce.Controller().LineRunes(l.lineIndex)
	offsets := font.Layout(&gxui.TextBlock{
		Runes:     runes,
		AlignRect: rect,
		H:         gxui.AlignLeft,
		V:         gxui.AlignMiddle,
	})
	l.applyTabWidth(runes, offsets, font)
	for i, offset := range offsets {
		offsets[i] = offset.AddX(-l.offset)
	}
	return offsets
}
Exemple #2
0
// tabDelta returns the difference between the current font's measurement
// of a tab character and the actual tab size based on spaces times the
// code editor's tab width.
func (l *CodeEditorLine) tabDelta(font gxui.Font) int {
	tabWidth := font.Measure(&gxui.TextBlock{Runes: []rune{'\t'}}).W
	spaceWidth := font.Measure(&gxui.TextBlock{Runes: []rune{' '}}).W
	return spaceWidth*l.ce.TabWidth() - tabWidth
}