microsoft / PowerToys

Windows system utilities to maximize productivity
MIT License
109.6k stars 6.46k forks source link

Add new language for math and science to Quick Accent #26270

Open Cheese-Echidna opened 1 year ago

Cheese-Echidna commented 1 year ago

Description of the new feature / enhancement

I would really like to add a new language for math and science to Quick Accent.

I am a student studying, among other things, Physics and Computer Science, and Quick Accent has been really helpful for me as I often need Greek letters to use in maths equations. (π, ε, Δ, Σ, etc) and the other symbols that can be used in maths (≥, ≠, ±) but I feel like many are missing that could be very useful, but don't fit into a specific language group: ∫, ⋃, √, ∀, ∞; and there are many others that I don't think I will ever use, but since there is no dedicated option, I need to leave enabled.

I propose that there be a separate language called "Math" or "Science" or something similar designed for English speakers who do not want access to the various language characters but would like to use the Greek letters that permeate maths and other symbols used in the same field.

Another solution to the problem might be to allow the user to define their own language set/keyboard mapping.

Scenario when this would be used?

This would be super helpful for anyone who needs to type out complex math expressions and is not in an environment that supports latex, or would like to quickly write an equation.

Supporting information

No response

Ekareya commented 1 year ago

Having it work with fraction, exposant and indice would also be a nice add. ½¾¹²³

Cheese-Echidna commented 1 year ago

Here is my current implementation for the GetDefaultLetter function for the Math language. (From Languages.cs) As per your suggestion, I have added the fractions to the slash symbol. Feel free to give input if you think there are any missing.

private static string[] GetDefaultLetterKeyMATH(LetterKey letter)
        {
            return letter switch
            {
                LetterKey.VK_0 => new string[] { "₀", "⁰" },
                LetterKey.VK_1 => new string[] { "₁", "¹" },
                LetterKey.VK_2 => new string[] { "₂", "²" },
                LetterKey.VK_3 => new string[] { "₃", "³" },
                LetterKey.VK_4 => new string[] { "₄", "⁴" },
                LetterKey.VK_5 => new string[] { "₅", "⁵" },
                LetterKey.VK_6 => new string[] { "₆", "⁶" },
                LetterKey.VK_7 => new string[] { "₇", "⁷" },
                LetterKey.VK_8 => new string[] { "₈", "⁸" },
                LetterKey.VK_9 => new string[] { "₉", "⁹" },
                LetterKey.VK_A => new string[] { "α", "⋀", "∀" },
                LetterKey.VK_B => new string[] { "β" },
                LetterKey.VK_C => new string[] { "∛", "χ" }
                LetterKey.VK_D => new string[] { "δ" },
                LetterKey.VK_E => new string[] { "∈", "ε", "∃" },
                LetterKey.VK_F => new string[] { "ƒ" },
                LetterKey.VK_G => new string[] { "γ" },
                LetterKey.VK_I => new string[] { "∞", "∫", "⇔", "⇒", "⇐", "⋃" },
                LetterKey.VK_L => new string[] { "λ" },
                LetterKey.VK_M => new string[] { "μ" },
                LetterKey.VK_N => new string[] { "ⁿ", "ν", "⋂" },
                LetterKey.VK_O => new string[] { "ø", "ω", "⋁" },
                LetterKey.VK_P => new string[] { "π", "φ", "ψ" },
                LetterKey.VK_R => new string[] { "ρ" },
                LetterKey.VK_S => new string[] { "√", "σ", "ß", "⊇", "⊆" },
                LetterKey.VK_T => new string[] { "θ", "τ", "þ" },
                LetterKey.VK_U => new string[] { "υ"},
                LetterKey.VK_X => new string[] { "ξ" },
                LetterKey.VK_Z => new string[] { "ζ" },
                LetterKey.VK_COMMA => new string[] { "¿", "¡", "∙", "₋", "⁻", "–", "≤", "≥", "≠", "≈", "≙", "±", "₊", "⁺" },
                LetterKey.VK_SLASH => new string[] { "½", "⅓", "⅔", "¼", "¾" },
                LetterKey.VK_PERIOD => new string[] { "\u0300", "\u0301", "\u0302", "\u0303", "\u0304", "\u0308", "\u030C" },
                LetterKey.VK_MINUS => new string[] { "~", "‐", "‑", "‒", "–", "—", "―", "⁓", "−", "⸺", "⸻" },
                _ => Array.Empty<string>(),
            };
Ekareya commented 1 year ago

for some missing ones: ≡, ¬, ∄, ⊕, ×,⋅,÷,‰, ⊥,≪,≫, all the greek in caps (∑ and Π comes to mind) ,⊄,⊅,∉.

Most of your maths symbols are linked to the English words for it, like √ is in S, would be better to put it to ² or to 2 in order to be used by non english speaker.

I would have put ≤,⇐,⊆,⊂ with < ≥,⇒,⊇,⊃ with > ≠,≈,⇔,≡ with = ⋃, ⋁with | ( to stay with the programming logical OR ) ⋂,⋀ with & ( to stay with the programming logical AND) ¡,¬ with ! ¿ with ? ₊,⁺ with + ×,⋅ with * ∫ with S ( it means sums afterall) √ with ² or/and 2 ∛ with 3 ∞ with 8

And the options to add those key in addition to the user accentuated key would be great. ( I still need my accentuated letters ^^) example:

Cheese-Echidna commented 1 year ago

Here is my updated code:

        private static string[] GetDefaultLetterKeyMATH(LetterKey letter)
        {
            return letter switch
            {
                LetterKey.VK_0 => new string[] { "₀", "⁰" },
                LetterKey.VK_1 => new string[] { "₁", "¹", "¬" },
                LetterKey.VK_2 => new string[] { "₂", "²",  "√" },
                LetterKey.VK_3 => new string[] { "₃", "³", "∛" },
                LetterKey.VK_4 => new string[] { "₄", "⁴" },
                LetterKey.VK_5 => new string[] { "₅", "⁵" },
                LetterKey.VK_6 => new string[] { "₆", "⁶" },
                LetterKey.VK_7 => new string[] { "₇", "⁷", "⋂", "⋀" },
                LetterKey.VK_8 => new string[] { "₈", "⁸", "×", "⋅" },
                LetterKey.VK_9 => new string[] { "₉", "⁹" },
                LetterKey.VK_A => new string[] { "α", "∀" },
                LetterKey.VK_B => new string[] { "β" },
                LetterKey.VK_C => new string[] { "χ" }
                LetterKey.VK_D => new string[] { "δ" },
                LetterKey.VK_E => new string[] { "ε", "∃", "∄" },
                LetterKey.VK_F => new string[] { "ƒ" },
                LetterKey.VK_G => new string[] { "γ" },
                LetterKey.VK_I => new string[] { "∞", "∫" },
                LetterKey.VK_L => new string[] { "λ" },
                LetterKey.VK_M => new string[] { "μ" },
                LetterKey.VK_N => new string[] { "ⁿ", "ν" },
                LetterKey.VK_O => new string[] { "ø", "ω" },
                LetterKey.VK_P => new string[] { "π", "φ", "ψ", "⊥" },
                LetterKey.VK_R => new string[] { "ρ" },
                LetterKey.VK_S => new string[] { "σ", "ß", "⊇", "⊆" },
                LetterKey.VK_T => new string[] { "θ", "τ", "þ" },
                LetterKey.VK_U => new string[] { "υ"},
                LetterKey.VK_X => new string[] { "ξ", "⊕" },
                LetterKey.VK_Z => new string[] { "ζ" },
                LetterKey.VK_BACKSLASH => new string { "⋃", "⋁" }
                LetterKey.VK_EQUALS => new string[] {"≠","≈","⇔","≡", "≙", "±", "₊", "⁺" },
                LetterKey.VK_COMMA => new string[] { "≤", "⇐", "⊆", "⊂", "⊄", "∌", "∋", "≪"},
                LetterKey.VK_PERIOD => new string[] { "≥", "⇒", "⊇", "⊃", "⊅", "∈", "∉", "≫" },
                LetterKey.VK_SLASH => new string[] {  "÷", "½", "⅓", "⅔", "¼", "¾", "‰" },
                _ => Array.Empty<string>(),
            };
        }

I have taken on most of your feedback, and I definitely agree about the missing symbols. Just so you know, the capital versions of the Greek letters do not need to be specified in the file as they will replace the slower-case versions if the user is pressing shift or has caps lock on when pressing the key.

The only things I disagree on are integral and infinity which to me both feel like they should remain with the letter i.

Also, (and I don't know this) but given there is an "all" option within the software, I assume that's where you would need to go if you want accents and maths characters.

Also, I can't decide if "‰" should go with "/" where the other fractions are or with "%", what do you think?

Ekareya commented 1 year ago

I would have put it with % but I don't know about the ease of access on your keyboard layout.

Ekareya commented 1 year ago

Not all keyboard have the same layout, especially with the number row and punctuation mark. for example on my keyboard, the 8 key is where I have _ and \ but on yours you have . so my questions is, do you know if it's possible to assign "×", "⋅" to and not to 8 in order to not depend on the keyboard layout? https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes

Cheese-Echidna commented 1 year ago

I think there is "VK_MULTIPLY" but I think that refers to the * on the Numpad. For me, % is on the 5 key.

Ali-C-Ila commented 1 year ago

This is what I've been thinking! Are you going to make a PR? (I personally want to add degree, as in 100°C)(maybe map it to key 0)

Some opinions:

  1. Quick accent should not utilize the numpad, as a lot of laptops and smaller keyboards do not have them.
  2. Different keyboard layouts could be a problem. I have little knowledge about them though.
  3. Greek letters already exists. No need for the redundancy.
  4. I agree with Ekareya on these

The mapping now is too English-centered.

Ekareya commented 1 year ago

concerning the numpad, I could be nice to have though. As long as there is an alternative for those that don't have it.

Cheese-Echidna commented 1 year ago

For now, I think it would be better to make changes that do not use the numpad. If someone else wants to do numpad bindings they are welcome. As for the Greek letters, although they are already in many of the other languages, there is no way to pick and choose just some of the languages, and as such including them in the "Math" language seems appropriate. Here is the current code, note I have added the ° symbol (thanks for the idea) and moved the "‰" to %.

        private static string[] GetDefaultLetterKeyMATH(LetterKey letter)
        {
            return letter switch
            {
                LetterKey.VK_0 => new string[] { "₀", "⁰", "°" },
                LetterKey.VK_1 => new string[] { "₁", "¹", "¬" },
                LetterKey.VK_2 => new string[] { "₂", "²",  "√" },
                LetterKey.VK_3 => new string[] { "₃", "³", "∛" },
                LetterKey.VK_4 => new string[] { "₄", "⁴" },
                LetterKey.VK_5 => new string[] { "₅", "⁵", "‰" },
                LetterKey.VK_6 => new string[] { "₆", "⁶" },
                LetterKey.VK_7 => new string[] { "₇", "⁷", "⋂", "⋀" },
                LetterKey.VK_8 => new string[] { "₈", "⁸", "∞", "×", "⋅" },
                LetterKey.VK_9 => new string[] { "₉", "⁹" },
                LetterKey.VK_A => new string[] { "α", "∀" },
                LetterKey.VK_B => new string[] { "β" },
                LetterKey.VK_C => new string[] { "χ" }
                LetterKey.VK_D => new string[] { "δ" },
                LetterKey.VK_E => new string[] { "ε", "∃", "∄" },
                LetterKey.VK_F => new string[] { "ƒ" },
                LetterKey.VK_G => new string[] { "γ" },
                LetterKey.VK_L => new string[] { "λ" },
                LetterKey.VK_M => new string[] { "μ" },
                LetterKey.VK_N => new string[] { "ⁿ", "ν" },
                LetterKey.VK_O => new string[] { "ø", "ω" },
                LetterKey.VK_P => new string[] { "π", "φ", "ψ", "⊥" },
                LetterKey.VK_R => new string[] { "ρ" },
                LetterKey.VK_S => new string[] { "σ", "ß", "∫" },
                LetterKey.VK_T => new string[] { "θ", "τ", "þ" },
                LetterKey.VK_U => new string[] { "υ"},
                LetterKey.VK_X => new string[] { "ξ", "⊕" },
                LetterKey.VK_Z => new string[] { "ζ" },
                LetterKey.VK_BACKSLASH => new string { "⋃", "⋁" }
                LetterKey.VK_EQUALS => new string[] {"≠","≈","⇔","≡", "≙", "±", "₊", "⁺" },
                LetterKey.VK_COMMA => new string[] { "≤", "⇐", "⊆", "⊂", "⊄", "∌", "∋", "≪"},
                LetterKey.VK_PERIOD => new string[] { "≥", "⇒", "⊇", "⊃", "⊅", "∈", "∉", "≫" },
                LetterKey.VK_SLASH => new string[] {  "÷", "½", "⅓", "⅔", "¼", "¾" },
                _ => Array.Empty<string>(),
            };
        }
Ali-C-Ila commented 1 year ago

Yeah, that's great! Why not make a pull request?

Cheese-Echidna commented 1 year ago

Ah, it seems there is no binding for the "|" key in the LetterKey enum. For now, I will make a push request without the changes.

jaimecbernardo commented 1 year ago

This has sort of been closed as not planned before in #21439, but some other symbols have gotten in already... Let's discuss this on the PR anyway.

Jay-o-Way commented 1 year ago

CC @damienleroy

htcfreek commented 3 weeks ago

@octastylos-pseudodipteros Your contribution is welcome and thank you for your work on this. Feel free to open a PR. If you have any further questions don't worry to ask them.