@@ -6,6 +6,7 @@ import androidx.compose.ui.unit.Dp
6
6
import org.futo.inputmethod.keyboard.KeyConsts
7
7
import org.futo.inputmethod.keyboard.internal.KeyboardLayoutElement
8
8
import org.futo.inputmethod.keyboard.internal.KeyboardParams
9
+ import org.futo.inputmethod.keyboard.internal.isAlphabet
9
10
import org.futo.inputmethod.latin.R
10
11
import org.futo.inputmethod.latin.common.Constants
11
12
import org.futo.inputmethod.latin.uix.DynamicThemeProvider
@@ -499,7 +500,20 @@ data class LayoutEngine(
499
500
}
500
501
}
501
502
502
- private val validNumbersForHint = " 1234567890" .map { params.mTextsSet.resolveTextReference(" !text/keyspec_symbols_$it " ) ? : it }.toSet()
503
+ private val validNumbersForHint = " 1234567890" .map { it.toString() }.map { params.mTextsSet.resolveTextReference(" !text/keyspec_symbols_$it " ) ? : it }.toSet()
504
+ private val englishNumbers = " 1234567890" .map { it.toString() }.toSet()
505
+ private val blacklistedHintsForNumbers = buildList {
506
+ // Subscripts/superscripts, fractions
507
+ addAll((0x2070 .. 0x208E ).map { it.toChar() })
508
+ addAll((0x2150 .. 0x215F ).map { it.toChar() })
509
+ add(' \u00B0 ' )
510
+ add(' \u00B2 ' )
511
+ add(' \u00B3 ' )
512
+ add(' \u00B9 ' )
513
+ add(' \u00BC ' )
514
+ add(' \u00BD ' )
515
+ add(' \u00BE ' )
516
+ }.map { it.toString() }.toSet()
503
517
private val showAllHintsSetting = params.mId.mLongPressKeySettings.showHints
504
518
505
519
private fun computedKeyToKey (data : ComputedKeyData , x : Int , y : Int , width : Int , height : Int , leftGap : LayoutEntry .Gap ? , rightGap : LayoutEntry .Gap ? ): org.futo.inputmethod.keyboard.Key ? {
@@ -529,11 +543,21 @@ data class LayoutEngine(
529
543
hasExplicitHint -> data.hint
530
544
531
545
// If we have no explicit hint, and show hints setting is disabled,
532
- // then either show a number or nothing
533
- ! showAllHintsSetting ->
534
- data.moreKeys.mapNotNull { it.mLabel }.firstOrNull { validNumbersForHint.contains(it) } ? : " "
535
-
536
- // If we have no explicit hint and show hints setting is enabled,
546
+ // then in alphabet menu, either show a number or nothing
547
+ ! showAllHintsSetting && params.mId.mElement.kind.isAlphabet ->
548
+ data.moreKeys.mapNotNull { it.mLabel }.firstOrNull { validNumbersForHint.contains(it) && it != data.label } ? : " "
549
+
550
+ // In the situation that this is a number, only show a hint if it's not a tiny little
551
+ // superscript or subscript
552
+ englishNumbers.contains(data.label) && validNumbersForHint.contains(data.label)
553
+ ->
554
+ data.moreKeys.firstOrNull {
555
+ it.mLabel != null
556
+ && ! blacklistedHintsForNumbers.contains(it.mLabel)
557
+ && it.mLabel != data.label
558
+ }?.mLabel ? : " "
559
+
560
+ // If we have no explicit hint and show hints setting is enabled (or we are in symbols menu),
537
561
// set this to null which will later automatically select a hint based on
538
562
// the first element of moreKeys
539
563
else -> null
0 commit comments