Skip to content

cursor position, leading/trailing and affinity #323

Open
@cmyr

Description

@cmyr

I ran into an issue in piet-coregraphics where hit_test_position wasn't respecting trailing newlines, and this has led me down a bit of a rabbit hole. In particular, I'm curious that there doesn't seem to be any concept of leading/trailing or upstream/downstream here? Is this an oversight, or am I missing something?

As an illustration, imagine the text "AAA BBB" with a soft break, so lines are "AAA " and "BBB". If I hit-test position 4, both "AAA |" and "|BBB" are valid. Is there some trick I'm missing? This doesn't seem to be as much of an issue on piet-d2d, although I haven't been able to play around there quite as much.

I'm pretty sure I could implement this in piet as some kind of cursor_pos_for_point method, because then I could ensure I take the line of the point into account when choosing my position instead of resolving to a string index and resolving from that back to a point, which is lossy?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requestedtext

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions