8000 added functionality for delete_word_left, delete_word_right and move_left/right_by_word for text_input by aang521 · Pull Request #1 · focus-editor/focus · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

added functionality for delete_word_left, delete_word_right and move_left/right_by_word for text_input #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8000
Merged
merged 4 commits into from
Apr 28, 2023

Conversation

aang521
Copy link
Contributor
@aang521 aang521 commented Apr 27, 2023

No description provided.

Copy link
Owner
@focus-editor focus-editor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thanks for sending in your PR! You chose a good piece of work to do.

Unfortunately there are some issues - you could either fix them yourself or if you want I could fix them - just let me know.

Text input was designed originally in a way that cursor.pos and cursor.sel represent character offsets (not byte offsets like in the main editor). Your changes now treat them as byte offsets, which is good, but the drawing code isn't aware of this yet.

You can try this utf-8 string to trigger a crash: "водка_vodka борис_ельцин".

Thanks!

@aang521
Copy link
Contributor Author
aang521 commented Apr 27, 2023

Hi, that explains a lot 😅
I will take a look at it tomorrow. Would you prefer it it text input is also treated as byte offsets, or rather have me change my changes to treat it as character offsets?

@focus-editor
Copy link
Owner

I think byte offsets is the way to go. I haven't touched that code in a long time, but I think there may be a couple of auxiliary functions for dealing with char offsets in the drawing code - feel free to remove them if they are no longer used elsewhere.

Thanks for your work! 💪

8000 @aang521 aang521 requested a review from focus-editor April 28, 2023 11:06
@aang521
Copy link
Contributor Author
aang521 commented Apr 28, 2023

I think I fixed all the issues with multi byte characters.

Copy link
Collaborator
@obiwanus obiwanus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks much better now! That temporary limit of 5000 has been bothering me and now we can get rid of it.

I think the only thing left to do it the text_input_type_char function, which still uses char offsets and causes crashes when you type non-ascii chars.

Would you be able to make that change? And delete the decode_utf8_string_to_temp_chars and get_char_offset while you're at it?

}

select_word :: (using input: *Text_Input) {
// Decode the characters on the line for scanning
chars := decode_utf8_string_to_temp_chars(to_string(text), max_char = 5000); // arbitrary number
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So glad to see it gone - this function can finally retire.

… removing characters when the text contains multi byte characters
@aang521
Copy link
Contributor Author
aang521 commented Apr 28, 2023

Fixed the issue with typing non-ascii characters.
Also found and fixed some issues with deleting multibyte characters.

@focus-editor focus-editor merged commit 2319028 into focus-editor:main Apr 28, 2023
@focus-editor
Copy link
Owner

Well done, thank you very much! 💪

I noticed that the alt-delete shortcuts don't yet work, perhaps we should also add them later

filippocrocchini pushed a commit to filippocrocchini/focus that referenced this pull request Oct 30, 2023
Now checks command-line args for directories to add to workspace_dirs array
filippocrocchini pushed a commit to filippocrocchini/focus that referenced this pull request Oct 30, 2023
Properly merge keymaps
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0