Skip to content
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

Include punctuation when double-clicking words to select them #4360

Draft
wants to merge 41 commits into
base: master
Choose a base branch
from

Conversation

rustbasic
Copy link
Contributor

@rustbasic rustbasic commented Apr 14, 2024

Determines whether a character is a component of a word.

This is In general, it feels good to use.

This works well even when using UTF8 characters rather than English-speaking characters.

Before : This is a double clicked on a word.

20240414-1

After : This is a double clicked on a word.

20240414-3

@rustbasic rustbasic requested a review from emilk April 21, 2024 11:05
@rustbasic rustbasic changed the title Determines whether a character is a component of a string. Determines whether a character is a component of a word. Apr 22, 2024
@emilk emilk changed the title Determines whether a character is a component of a word. Include punctuation when double-clicking words to select them May 10, 2024
@emilk
Copy link
Owner

emilk commented May 10, 2024

This is not how mac works though - double-clicking a word does NOT include - or .

Screenshot 2024-05-11 at 00 39 52 Screenshot 2024-05-11 at 00 39 48

@rustbasic
Copy link
Contributor Author

This is not how mac works though - double-clicking a word does NOT include - or .

I can only test Windows.
This function is_word_char() works fine.
The problem on mac does not seem to be an issue with is_word_char().

(
It looks like changes to 'is_word_char()' were not applied at compile time.
Wouldn't the changed to 'is_word_char()' have been applied at compile time?
)

@rustbasic rustbasic requested a review from emilk May 11, 2024 01:48
@emilk
Copy link
Owner

emilk commented May 11, 2024

If the new code matches the behavior of native windows, then check if ctx.os() == OperatingSystem::Windows

@rustbasic
Copy link
Contributor Author

If the new code matches the behavior of native windows, then check if ctx.os() == OperatingSystem::Windows

The is_word_char() function simply returns a bool value, so I think it's a good idea to keep it that way.
I think it would be better to fix the mac issue later.
Otherwise, please edit as you wish.

@emilk
Copy link
Owner

emilk commented May 11, 2024

I want to match how text editing works natively on whatever platform egui runs on.

If double-clicking foo-bar selects both foo and bar on windows, then let's make it work like that, but only on Windows (because on Mac, words don't extend across hyphen on double-click).

I don't know how Windows works though.

@rustbasic
Copy link
Contributor Author

I want to match how text editing works natively on whatever platform egui runs on.

If double-clicking foo-bar selects both foo and bar on windows, then let's make it work like that, but only on Windows (because on Mac, words don't extend across hyphen on double-click).

I don't know how Windows works though.

yes. In windows everything works fine.
Not only foo-bar, but also URL, e-mail, path, UTF8 characters (Korean), etc. all work well.
I think the reason it doesn't work on mac has nothing to do with this function.

@YgorSouza
Copy link
Contributor

I want to match how text editing works natively on whatever platform egui runs on.
If double-clicking foo-bar selects both foo and bar on windows, then let's make it work like that, but only on Windows (because on Mac, words don't extend across hyphen on double-click).
I don't know how Windows works though.

yes. In windows everything works fine. Not only foo-bar, but also URL, e-mail, path, UTF8 characters (Korean), etc. all work well. I think the reason it doesn't work on mac has nothing to do with this function.

Which Windows app works like that? Here is Notepad:

windows-word-boundaries.mp4

@rustbasic
Copy link
Contributor Author

rustbasic commented May 11, 2024

Which Windows app works like that? Here is Notepad:

This was a response to egui_demo_app that applied this commit.
I don't understand the nuances of English.

@YgorSouza
Copy link
Contributor

Which Windows app works like that? Here is Notepad:

This was a response to egui_demo_app that applied this commit. I don't understand the nuances of English.

What emilk is saying is that egui should work exactly like other programs in each operating system. So you should probably change:

    if matches!(
        c,
        '_' | '-' | ':' | '/' | '.' | '\\' | '@' | '#' | '?' | '='
    )

to

    if matches!(c, '_')

@rustbasic
Copy link
Contributor Author

rustbasic commented May 12, 2024

What emilk is saying is that egui should work exactly like other programs in each operating system.

In Notepad on Windows 10, many things such as ., _, -, ;, (, ) are selected together when double-clicked.
And what is selected when double-clicking is unique to egui and does not need to be copied by other programs.

@emilk emilk marked this pull request as draft May 27, 2024 14:31
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