actually use the text library for text editing (fully working I think but code isn't cleanest)
This commit is contained in:
@@ -2,8 +2,8 @@ use std::ops::Range;
|
||||
|
||||
use crate::{
|
||||
layout::{
|
||||
Active, Cursor, TextAttrs, TextBuffer, TextData, TextOffset, TextureHandle, Textures,
|
||||
UiRegion, Vec2, WidgetId, Widgets,
|
||||
Active, TextAttrs, TextBuffer, TextData, TextOffset, TextureHandle, Textures, UiRegion,
|
||||
Vec2, VisualCursor, WidgetId, Widgets,
|
||||
},
|
||||
render::{Primitive, PrimitiveHandle, Primitives},
|
||||
util::{HashSet, Id},
|
||||
@@ -277,13 +277,10 @@ impl<'a, 'c> Painter<'a, 'c> {
|
||||
pub fn render_text(
|
||||
&mut self,
|
||||
buffer: &mut TextBuffer,
|
||||
content: &str,
|
||||
attrs: &TextAttrs,
|
||||
cursor: &Cursor,
|
||||
cursor: &VisualCursor,
|
||||
) -> (TextureHandle, TextOffset) {
|
||||
self.ctx
|
||||
.text
|
||||
.draw(buffer, content, attrs, cursor, self.ctx.textures)
|
||||
self.ctx.text.draw(buffer, attrs, cursor, self.ctx.textures)
|
||||
}
|
||||
|
||||
pub fn region(&self) -> UiRegion {
|
||||
@@ -307,6 +304,10 @@ impl<'a, 'c> Painter<'a, 'c> {
|
||||
checked: &mut self.sized_children,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn text_data(&mut self) -> &mut TextData {
|
||||
self.ctx.text
|
||||
}
|
||||
}
|
||||
|
||||
pub struct SizeCtx<'a> {
|
||||
@@ -325,12 +326,10 @@ impl SizeCtx<'_> {
|
||||
pub fn draw_text(
|
||||
&mut self,
|
||||
buffer: &mut TextBuffer,
|
||||
content: &str,
|
||||
attrs: &TextAttrs,
|
||||
cursor: &Cursor,
|
||||
cursor: &VisualCursor,
|
||||
) -> (TextureHandle, TextOffset) {
|
||||
self.text
|
||||
.draw(buffer, content, attrs, cursor, self.textures)
|
||||
self.text.draw(buffer, attrs, cursor, self.textures)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user