Example #1
0
func (l *CodeEditorLine) PaintEditorSelections(c gxui.Canvas, info CodeEditorLinePaintInfo) {
	controller := l.textbox.controller

	ls, le := uint64(controller.LineStart(l.lineIndex)), uint64(controller.LineEnd(l.lineIndex))

	selections := controller.Selections()
	if l.textbox.selectionDragging {
		interval.Replace(&selections, l.textbox.selectionDrag)
	}
	interval.Visit(&selections, gxui.CreateTextSelection(int(ls), int(le), false), func(s, e uint64, _ int) {
		if s < e {
			var startOffset math.Point
			if s > ls {
				startOffset = l.endOfChar(info.GlyphOffsets[s-ls-1])
			}
			var endOffset math.Point
			if e > ls {
				endOffset = l.endOfChar(info.GlyphOffsets[e-ls-1])
			}

			width := endOffset.X - startOffset.X
			m := l.outer.MeasureRunes(int(s), int(e))
			m.W = width
			top := math.Point{X: l.caretWidth + startOffset.X, Y: 0}
			bottom := top.Add(m.Point())
			l.outer.PaintSelection(c, top, bottom)
		}
	})
}
Example #2
0
func (t *DefaultTextBoxLine) PaintSelections(c gxui.Canvas) {
	controller := t.textbox.controller

	ls, le := controller.LineStart(t.lineIndex), controller.LineEnd(t.lineIndex)

	selections := controller.Selections()
	if t.textbox.selectionDragging {
		interval.Replace(&selections, t.textbox.selectionDrag)
	}
	interval.Visit(&selections, gxui.CreateTextSelection(ls, le, false), func(s, e uint64, _ int) {
		if s < e {
			x := t.outer.MeasureRunes(ls, int(s)).W
			m := t.outer.MeasureRunes(int(s), int(e))
			top := math.Point{X: t.caretWidth + x, Y: 0}
			bottom := top.Add(m.Point())
			t.outer.PaintSelection(c, top, bottom)
		}
	})
}
Example #3
0
func (l *CodeSyntaxLayer) AddSpan(span interval.IntData) {
	interval.Replace(&l.spans, span)
}
Example #4
0
func (l *CodeSyntaxLayer) AddData(start, count int, data interface{}) {
	span := interval.CreateIntData(start, start+count, data)
	interval.Replace(&l.spans, span)
}