potocpav / xi_glium

Glium-based front-end to the xi editor
MIT License
84 stars 13 forks source link

added a basic (and buggy) on-click support #6

Closed themasch closed 8 years ago

themasch commented 8 years ago

i'm having a little trouble adding mouse support since I don't know how to correctly map an on-screen x coordinate to the matching column. I think I'm missing an offset/padding and might use a wrong factor. Any suggestions?

themasch commented 8 years ago

This is somewhat related to #4.

potocpav commented 8 years ago

I am currently re-doing the text positioning. Once it's done, it should be fairly easy (and different than it is now) to compute the click's line number. We can get the column using the glium_text::get_char_pos_x(n) function. This function returns the offset of a given character. It's parameter is a position of the character, in bytes.

Best to wait for the changes with this.

EDIT: The get_char_pos_x is that way because that is what the back-end does for the cursor position. It is used in src/renderer.rs:40.

potocpav commented 8 years ago

Updated a comment on get_char_pos_x, so it (hopefully) describes the result accurately (cf32132).

themasch commented 8 years ago

okay, I think we should close this PR and I'll open a new one with the new implementation.

potocpav commented 8 years ago

I finished a simple mouse-click implementation. Used some code from this PR.