Merge branch 'terminal' into 'master'
Fix emoji and number layouts See merge request Librem5/squeekboard!444
This commit is contained in:
@ -1,201 +0,0 @@
|
|||||||
---
|
|
||||||
outlines:
|
|
||||||
default: { width: 35.33, height: 46 }
|
|
||||||
action: { width: 59, height: 46 }
|
|
||||||
altline: { width: 52.67, height: 46 }
|
|
||||||
wide: { width: 59, height: 46 }
|
|
||||||
spaceline: { width: 140, height: 46 }
|
|
||||||
special: { width: 44, height: 46 }
|
|
||||||
small: { width: 59, height: 22 }
|
|
||||||
|
|
||||||
views:
|
|
||||||
base:
|
|
||||||
- "Ctrl Alt ↑ ↓ ← →"
|
|
||||||
- "q w e r t y u i o p"
|
|
||||||
- "a s d f g h j k l"
|
|
||||||
- "Shift_L z x c v b n m BackSpace"
|
|
||||||
- "show_numbers preferences space show_actions Return"
|
|
||||||
upper:
|
|
||||||
- "Ctrl Alt PgUp PgDn Home End"
|
|
||||||
- "Q W E R T Y U I O P"
|
|
||||||
- "A S D F G H J K L"
|
|
||||||
- "Shift_L Z X C V B N M BackSpace"
|
|
||||||
- "show_numbers preferences space show_actions Return"
|
|
||||||
numbers:
|
|
||||||
- "Ctrl Alt ↑ ↓ ← →"
|
|
||||||
- "1 2 3 4 5 6 7 8 9 0"
|
|
||||||
- "* # $ / & - _ + ( )"
|
|
||||||
- "show_symbols , \" ' colon ; ! ? BackSpace"
|
|
||||||
- "show_letters preferences space period Return"
|
|
||||||
symbols:
|
|
||||||
- "Ctrl Alt ↑ ↓ ← →"
|
|
||||||
- "~ ` | · √ π τ ÷ × ¶"
|
|
||||||
- "© ® £ € ¥ ^ ° @ { }"
|
|
||||||
- "show_numbers_from_symbols \\ % < > = [ ] BackSpace"
|
|
||||||
- "show_letters preferences space period Return"
|
|
||||||
actions:
|
|
||||||
- "Ctrl Alt PgUp PgDn Home End"
|
|
||||||
- "F1 F2 F3 F4 F5 F6"
|
|
||||||
- "F7 F8 F9 F10 F11 F12"
|
|
||||||
- "Esc Tab Pause Insert Up Del"
|
|
||||||
- "show_letters Menu Break Left Down Right"
|
|
||||||
|
|
||||||
buttons:
|
|
||||||
Shift_L:
|
|
||||||
action:
|
|
||||||
locking:
|
|
||||||
lock_view: "upper"
|
|
||||||
unlock_view: "base"
|
|
||||||
outline: "altline"
|
|
||||||
icon: "key-shift"
|
|
||||||
BackSpace:
|
|
||||||
outline: "altline"
|
|
||||||
icon: "edit-clear-symbolic"
|
|
||||||
action: erase
|
|
||||||
preferences:
|
|
||||||
action: "show_prefs"
|
|
||||||
outline: "special"
|
|
||||||
icon: "keyboard-mode-symbolic"
|
|
||||||
show_numbers:
|
|
||||||
action:
|
|
||||||
set_view: "numbers"
|
|
||||||
outline: "wide"
|
|
||||||
label: "123"
|
|
||||||
show_numbers_from_symbols:
|
|
||||||
action:
|
|
||||||
set_view: "numbers"
|
|
||||||
outline: "altline"
|
|
||||||
label: "123"
|
|
||||||
show_letters:
|
|
||||||
action:
|
|
||||||
set_view: "base"
|
|
||||||
outline: "wide"
|
|
||||||
label: "ABC"
|
|
||||||
show_symbols:
|
|
||||||
action:
|
|
||||||
set_view: "symbols"
|
|
||||||
outline: "altline"
|
|
||||||
label: "τ=\\"
|
|
||||||
show_actions:
|
|
||||||
action:
|
|
||||||
set_view: "actions"
|
|
||||||
outline: "altline"
|
|
||||||
label: ">_"
|
|
||||||
period:
|
|
||||||
outline: "altline"
|
|
||||||
text: "."
|
|
||||||
space:
|
|
||||||
outline: "spaceline"
|
|
||||||
text: " "
|
|
||||||
Return:
|
|
||||||
outline: "wide"
|
|
||||||
icon: "key-enter"
|
|
||||||
keysym: "Return"
|
|
||||||
colon:
|
|
||||||
text: ":"
|
|
||||||
F1:
|
|
||||||
outline: "action"
|
|
||||||
keysym: "F1"
|
|
||||||
F2:
|
|
||||||
outline: "action"
|
|
||||||
keysym: "F2"
|
|
||||||
F3:
|
|
||||||
outline: "action"
|
|
||||||
keysym: "F3"
|
|
||||||
F4:
|
|
||||||
outline: "action"
|
|
||||||
keysym: "F4"
|
|
||||||
F5:
|
|
||||||
outline: "action"
|
|
||||||
keysym: "F5"
|
|
||||||
F6:
|
|
||||||
outline: "action"
|
|
||||||
keysym: "F6"
|
|
||||||
F7:
|
|
||||||
outline: "action"
|
|
||||||
keysym: "F7"
|
|
||||||
F8:
|
|
||||||
outline: "action"
|
|
||||||
keysym: "F8"
|
|
||||||
F9:
|
|
||||||
outline: "action"
|
|
||||||
keysym: "F9"
|
|
||||||
F10:
|
|
||||||
outline: "action"
|
|
||||||
keysym: "F10"
|
|
||||||
F11:
|
|
||||||
outline: "action"
|
|
||||||
keysym: "F11"
|
|
||||||
F12:
|
|
||||||
outline: "action"
|
|
||||||
keysym: "F12"
|
|
||||||
Esc:
|
|
||||||
outline: "action"
|
|
||||||
keysym: "Escape"
|
|
||||||
Tab:
|
|
||||||
outline: "action"
|
|
||||||
keysym: "Tab"
|
|
||||||
Del:
|
|
||||||
outline: "action"
|
|
||||||
keysym: "Delete"
|
|
||||||
Insert:
|
|
||||||
outline: "action"
|
|
||||||
keysym: "Insert"
|
|
||||||
Menu:
|
|
||||||
outline: "action"
|
|
||||||
keysym: "Menu"
|
|
||||||
Pause:
|
|
||||||
outline: "action"
|
|
||||||
keysym: "Pause"
|
|
||||||
Break:
|
|
||||||
outline: "action"
|
|
||||||
keysym: "Break"
|
|
||||||
Home:
|
|
||||||
outline: "small"
|
|
||||||
keysym: "Home"
|
|
||||||
End:
|
|
||||||
outline: "small"
|
|
||||||
keysym: "End"
|
|
||||||
PgUp:
|
|
||||||
outline: "small"
|
|
||||||
keysym: "Page_Up"
|
|
||||||
PgDn:
|
|
||||||
outline: "small"
|
|
||||||
keysym: "Page_Down"
|
|
||||||
"↑":
|
|
||||||
outline: "small"
|
|
||||||
keysym: "Up"
|
|
||||||
"↓":
|
|
||||||
outline: "small"
|
|
||||||
keysym: "Down"
|
|
||||||
"←":
|
|
||||||
outline: "small"
|
|
||||||
keysym: "Left"
|
|
||||||
"→":
|
|
||||||
outline: "small"
|
|
||||||
keysym: "Right"
|
|
||||||
Up:
|
|
||||||
label: "↑"
|
|
||||||
outline: "action"
|
|
||||||
keysym: "Up"
|
|
||||||
Left:
|
|
||||||
label: "←"
|
|
||||||
outline: "action"
|
|
||||||
keysym: "Left"
|
|
||||||
Down:
|
|
||||||
label: "↓"
|
|
||||||
outline: "action"
|
|
||||||
keysym: "Down"
|
|
||||||
Right:
|
|
||||||
label: "→"
|
|
||||||
outline: "action"
|
|
||||||
keysym: "Right"
|
|
||||||
Ctrl:
|
|
||||||
modifier: "Control"
|
|
||||||
outline: "small"
|
|
||||||
label: "Ctrl"
|
|
||||||
Alt:
|
|
||||||
modifier: "Alt"
|
|
||||||
outline: "small"
|
|
||||||
label: "Alt"
|
|
||||||
|
|
||||||
@ -1,208 +0,0 @@
|
|||||||
---
|
|
||||||
outlines:
|
|
||||||
default: { width: 54, height: 37 }
|
|
||||||
action: { width: 90, height: 37 }
|
|
||||||
altline: { width: 81, height: 37 }
|
|
||||||
wide: { width: 90, height: 37 }
|
|
||||||
spaceline: { width: 225, height: 37 }
|
|
||||||
special: { width: 54, height: 37 }
|
|
||||||
small: { width: 67.4, height: 22 }
|
|
||||||
|
|
||||||
views:
|
|
||||||
base:
|
|
||||||
- "EscSmall TabSmall Ctrl Alt ↑ ↓ ← →"
|
|
||||||
- "q w e r t y u i o p"
|
|
||||||
- "a s d f g h j k l"
|
|
||||||
- "Shift_L z x c v b n m BackSpace"
|
|
||||||
- "show_numbers preferences space show_actions Return"
|
|
||||||
upper:
|
|
||||||
- "EscSmall TabSmall Ctrl Alt PgUp PgDn Home End"
|
|
||||||
- "Q W E R T Y U I O P"
|
|
||||||
- "A S D F G H J K L"
|
|
||||||
- "Shift_L Z X C V B N M BackSpace"
|
|
||||||
- "show_numbers preferences space show_actions Return"
|
|
||||||
numbers:
|
|
||||||
- "EscSmall TabSmall Ctrl Alt ↑ ↓ ← →"
|
|
||||||
- "1 2 3 4 5 6 7 8 9 0"
|
|
||||||
- "* # $ / & - _ + ( )"
|
|
||||||
- "show_symbols , \" ' colon ; ! ? BackSpace"
|
|
||||||
- "show_letters preferences space period Return"
|
|
||||||
symbols:
|
|
||||||
- "EscSmall TabSmall Ctrl Alt ↑ ↓ ← →"
|
|
||||||
- "~ ` | · √ π τ ÷ × ¶"
|
|
||||||
- "© ® £ € ¥ ^ ° @ { }"
|
|
||||||
- "show_numbers_from_symbols \\ % < > = [ ] BackSpace"
|
|
||||||
- "show_letters preferences space period Return"
|
|
||||||
actions:
|
|
||||||
- "EscSmall TabSmall Ctrl Alt PgUp PgDn Home End"
|
|
||||||
- "F1 F2 F3 F4 F5 F6"
|
|
||||||
- "F7 F8 F9 F10 F11 F12"
|
|
||||||
- "Esc Tab Pause Insert Up Del"
|
|
||||||
- "show_letters Menu Break Left Down Right"
|
|
||||||
|
|
||||||
buttons:
|
|
||||||
Shift_L:
|
|
||||||
action:
|
|
||||||
locking:
|
|
||||||
lock_view: "upper"
|
|
||||||
unlock_view: "base"
|
|
||||||
outline: "altline"
|
|
||||||
icon: "key-shift"
|
|
||||||
BackSpace:
|
|
||||||
outline: "altline"
|
|
||||||
icon: "edit-clear-symbolic"
|
|
||||||
action: erase
|
|
||||||
preferences:
|
|
||||||
action: "show_prefs"
|
|
||||||
outline: "special"
|
|
||||||
icon: "keyboard-mode-symbolic"
|
|
||||||
show_numbers:
|
|
||||||
action:
|
|
||||||
set_view: "numbers"
|
|
||||||
outline: "wide"
|
|
||||||
label: "123"
|
|
||||||
show_numbers_from_symbols:
|
|
||||||
action:
|
|
||||||
set_view: "numbers"
|
|
||||||
outline: "altline"
|
|
||||||
label: "123"
|
|
||||||
show_letters:
|
|
||||||
action:
|
|
||||||
set_view: "base"
|
|
||||||
outline: "wide"
|
|
||||||
label: "ABC"
|
|
||||||
show_symbols:
|
|
||||||
action:
|
|
||||||
set_view: "symbols"
|
|
||||||
outline: "altline"
|
|
||||||
label: "τ=\\"
|
|
||||||
show_actions:
|
|
||||||
action:
|
|
||||||
set_view: "actions"
|
|
||||||
outline: "altline"
|
|
||||||
label: ">_"
|
|
||||||
period:
|
|
||||||
outline: "altline"
|
|
||||||
text: "."
|
|
||||||
space:
|
|
||||||
outline: "spaceline"
|
|
||||||
text: " "
|
|
||||||
Return:
|
|
||||||
outline: "wide"
|
|
||||||
icon: "key-enter"
|
|
||||||
keysym: "Return"
|
|
||||||
colon:
|
|
||||||
text: ":"
|
|
||||||
F1:
|
|
||||||
outline: "action"
|
|
||||||
keysym: "F1"
|
|
||||||
F2:
|
|
||||||
outline: "action"
|
|
||||||
keysym: "F2"
|
|
||||||
F3:
|
|
||||||
outline: "action"
|
|
||||||
keysym: "F3"
|
|
||||||
F4:
|
|
||||||
outline: "action"
|
|
||||||
keysym: "F4"
|
|
||||||
F5:
|
|
||||||
outline: "action"
|
|
||||||
keysym: "F5"
|
|
||||||
F6:
|
|
||||||
outline: "action"
|
|
||||||
keysym: "F6"
|
|
||||||
F7:
|
|
||||||
outline: "action"
|
|
||||||
keysym: "F7"
|
|
||||||
F8:
|
|
||||||
outline: "action"
|
|
||||||
keysym: "F8"
|
|
||||||
F9:
|
|
||||||
outline: "action"
|
|
||||||
keysym: "F9"
|
|
||||||
F10:
|
|
||||||
outline: "action"
|
|
||||||
keysym: "F10"
|
|
||||||
F11:
|
|
||||||
outline: "action"
|
|
||||||
keysym: "F11"
|
|
||||||
F12:
|
|
||||||
outline: "action"
|
|
||||||
keysym: "F12"
|
|
||||||
Esc:
|
|
||||||
outline: "action"
|
|
||||||
keysym: "Escape"
|
|
||||||
EscSmall:
|
|
||||||
outline: "small"
|
|
||||||
keysym: "Escape"
|
|
||||||
label: "Esc"
|
|
||||||
Tab:
|
|
||||||
outline: "action"
|
|
||||||
keysym: "Tab"
|
|
||||||
TabSmall:
|
|
||||||
outline: "small"
|
|
||||||
keysym: "Tab"
|
|
||||||
label: "Tab"
|
|
||||||
Del:
|
|
||||||
outline: "action"
|
|
||||||
keysym: "Delete"
|
|
||||||
Insert:
|
|
||||||
outline: "action"
|
|
||||||
keysym: "Insert"
|
|
||||||
Menu:
|
|
||||||
outline: "action"
|
|
||||||
keysym: "Menu"
|
|
||||||
Pause:
|
|
||||||
outline: "action"
|
|
||||||
keysym: "Pause"
|
|
||||||
Break:
|
|
||||||
outline: "action"
|
|
||||||
keysym: "Break"
|
|
||||||
Home:
|
|
||||||
outline: "small"
|
|
||||||
keysym: "Home"
|
|
||||||
End:
|
|
||||||
outline: "small"
|
|
||||||
keysym: "End"
|
|
||||||
PgUp:
|
|
||||||
outline: "small"
|
|
||||||
keysym: "Page_Up"
|
|
||||||
PgDn:
|
|
||||||
outline: "small"
|
|
||||||
keysym: "Page_Down"
|
|
||||||
"↑":
|
|
||||||
outline: "small"
|
|
||||||
keysym: "Up"
|
|
||||||
"↓":
|
|
||||||
outline: "small"
|
|
||||||
keysym: "Down"
|
|
||||||
"←":
|
|
||||||
outline: "small"
|
|
||||||
keysym: "Left"
|
|
||||||
"→":
|
|
||||||
outline: "small"
|
|
||||||
keysym: "Right"
|
|
||||||
Up:
|
|
||||||
label: "↑"
|
|
||||||
outline: "action"
|
|
||||||
keysym: "Up"
|
|
||||||
Left:
|
|
||||||
label: "←"
|
|
||||||
outline: "action"
|
|
||||||
keysym: "Left"
|
|
||||||
Down:
|
|
||||||
label: "↓"
|
|
||||||
outline: "action"
|
|
||||||
keysym: "Down"
|
|
||||||
Right:
|
|
||||||
label: "→"
|
|
||||||
outline: "action"
|
|
||||||
keysym: "Right"
|
|
||||||
Ctrl:
|
|
||||||
modifier: "Control"
|
|
||||||
outline: "small"
|
|
||||||
label: "Ctrl"
|
|
||||||
Alt:
|
|
||||||
modifier: "Alt"
|
|
||||||
outline: "small"
|
|
||||||
label: "Alt"
|
|
||||||
@ -139,7 +139,7 @@ eekboard_context_service_use_layout(EekboardContextService *context, struct sque
|
|||||||
// overlay is "Normal" for most layouts, we will only look for "terminal" in rust code.
|
// overlay is "Normal" for most layouts, we will only look for "terminal" in rust code.
|
||||||
// for now just avoid passing a null pointer
|
// for now just avoid passing a null pointer
|
||||||
if (overlay_name == NULL) {
|
if (overlay_name == NULL) {
|
||||||
overlay_name = "Normal"; // fallback to Normal
|
overlay_name = ""; // fallback to Normal
|
||||||
}
|
}
|
||||||
|
|
||||||
// generic part follows
|
// generic part follows
|
||||||
|
|||||||
59
src/data.rs
59
src/data.rs
@ -77,7 +77,6 @@ pub mod c {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const FALLBACK_LAYOUT_NAME: &str = "us";
|
const FALLBACK_LAYOUT_NAME: &str = "us";
|
||||||
const FALLBACK_GENERIC_LAYOUT_NAME: &str = "terminal";
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum LoadError {
|
pub enum LoadError {
|
||||||
@ -119,49 +118,60 @@ type LayoutSource = (ArrangementKind, DataSource);
|
|||||||
/// Lists possible sources, with 0 as the most preferred one
|
/// Lists possible sources, with 0 as the most preferred one
|
||||||
/// Trying order: native lang of the right kind, native base,
|
/// Trying order: native lang of the right kind, native base,
|
||||||
/// fallback lang of the right kind, fallback base
|
/// fallback lang of the right kind, fallback base
|
||||||
|
/// The `purpose` argument is not ContentPurpose,
|
||||||
|
/// but rather ContentPurpose and overlay in one.
|
||||||
fn list_layout_sources(
|
fn list_layout_sources(
|
||||||
name: &str,
|
name: &str,
|
||||||
kind: ArrangementKind,
|
kind: ArrangementKind,
|
||||||
overlay: &str,
|
purpose: &str,
|
||||||
keyboards_path: Option<PathBuf>,
|
keyboards_path: Option<PathBuf>,
|
||||||
) -> Vec<LayoutSource> {
|
) -> Vec<LayoutSource> {
|
||||||
// Just a simplification of often called code.
|
// Just a simplification of often called code.
|
||||||
let add_by_name = |
|
let add_by_name = |
|
||||||
mut ret: Vec<LayoutSource>,
|
mut ret: Vec<LayoutSource>,
|
||||||
|
purpose: &str,
|
||||||
name: &str,
|
name: &str,
|
||||||
kind: &ArrangementKind,
|
kind: &ArrangementKind,
|
||||||
| -> Vec<LayoutSource> {
|
| -> Vec<LayoutSource> {
|
||||||
|
let name = if purpose == "" { name.into() }
|
||||||
|
else { format!("{}/{}", purpose, name) };
|
||||||
|
|
||||||
if let Some(path) = keyboards_path.clone() {
|
if let Some(path) = keyboards_path.clone() {
|
||||||
ret.push((
|
ret.push((
|
||||||
kind.clone(),
|
kind.clone(),
|
||||||
DataSource::File(
|
DataSource::File(
|
||||||
path.join(name.to_owned()).with_extension("yaml")
|
path.join(name.clone())
|
||||||
|
.with_extension("yaml")
|
||||||
)
|
)
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
ret.push((
|
ret.push((
|
||||||
kind.clone(),
|
kind.clone(),
|
||||||
DataSource::Resource(name.into())
|
DataSource::Resource(name)
|
||||||
));
|
));
|
||||||
ret
|
ret
|
||||||
};
|
};
|
||||||
|
|
||||||
// Another grouping.
|
// Another grouping.
|
||||||
let add_by_kind = |ret, name: &str, kind| {
|
let add_by_kind = |ret, purpose: &str, name: &str, kind| {
|
||||||
let ret = match kind {
|
let ret = match kind {
|
||||||
&ArrangementKind::Base => ret,
|
&ArrangementKind::Base => ret,
|
||||||
kind => add_by_name(
|
kind => add_by_name(
|
||||||
ret,
|
ret,
|
||||||
|
purpose,
|
||||||
&name_with_arrangement(name.into(), kind),
|
&name_with_arrangement(name.into(), kind),
|
||||||
kind,
|
kind,
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
add_by_name(ret, name, &ArrangementKind::Base)
|
add_by_name(ret, purpose, name, &ArrangementKind::Base)
|
||||||
};
|
};
|
||||||
|
|
||||||
fn name_with_arrangement(name: String, kind: &ArrangementKind) -> String {
|
fn name_with_arrangement(
|
||||||
|
name: String,
|
||||||
|
kind: &ArrangementKind,
|
||||||
|
) -> String {
|
||||||
match kind {
|
match kind {
|
||||||
ArrangementKind::Base => name,
|
ArrangementKind::Base => name,
|
||||||
ArrangementKind::Wide => name + "_wide",
|
ArrangementKind::Wide => name + "_wide",
|
||||||
@ -171,7 +181,7 @@ fn list_layout_sources(
|
|||||||
let ret = Vec::new();
|
let ret = Vec::new();
|
||||||
|
|
||||||
// Name as given takes priority.
|
// Name as given takes priority.
|
||||||
let ret = add_by_kind(ret, name, &kind);
|
let ret = add_by_kind(ret, purpose, name, &kind);
|
||||||
|
|
||||||
// Then try non-alternative name if applicable (`us` for `us+colemak`).
|
// Then try non-alternative name if applicable (`us` for `us+colemak`).
|
||||||
let ret = {
|
let ret = {
|
||||||
@ -181,7 +191,7 @@ fn list_layout_sources(
|
|||||||
// The name is already equal to base, so it was already added.
|
// The name is already equal to base, so it was already added.
|
||||||
if base == name { ret }
|
if base == name { ret }
|
||||||
else {
|
else {
|
||||||
add_by_kind(ret, base, &kind)
|
add_by_kind(ret, purpose, base, &kind)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// The layout's base name starts with a "+". Weird but OK.
|
// The layout's base name starts with a "+". Weird but OK.
|
||||||
@ -192,14 +202,7 @@ fn list_layout_sources(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// No other choices left, so give anything.
|
add_by_kind(ret, purpose, FALLBACK_LAYOUT_NAME.into(), &kind)
|
||||||
let mut fallback=FALLBACK_LAYOUT_NAME;
|
|
||||||
match overlay {
|
|
||||||
"terminal" => fallback = FALLBACK_GENERIC_LAYOUT_NAME,
|
|
||||||
_ => fallback = FALLBACK_LAYOUT_NAME,
|
|
||||||
};
|
|
||||||
|
|
||||||
add_by_kind(ret, fallback.into(), &kind)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,20 +238,14 @@ fn load_layout_data_with_fallback(
|
|||||||
let path = env::var_os("SQUEEKBOARD_KEYBOARDSDIR")
|
let path = env::var_os("SQUEEKBOARD_KEYBOARDSDIR")
|
||||||
.map(PathBuf::from)
|
.map(PathBuf::from)
|
||||||
.or_else(|| xdg::data_path("squeekboard/keyboards"));
|
.or_else(|| xdg::data_path("squeekboard/keyboards"));
|
||||||
|
|
||||||
// prefix the layout name if we are showing a terminal specific layout
|
|
||||||
let layout_name = match overlay {
|
|
||||||
"Normal" => format!("{}", name), // normal keyboard layouts
|
|
||||||
other => format!("{}-{}", other, name), // terminal and catch-all
|
|
||||||
};
|
|
||||||
|
|
||||||
log_print!(
|
log_print!(
|
||||||
logging::Level::Debug,
|
logging::Level::Debug,
|
||||||
"load_layout_data_with_fallback() -> name:{}, purpose:{:?}, overlay:{}, layout_name:{}",
|
"load_layout_data_with_fallback() -> name:{}, purpose:{:?}, overlay:{}, layout_name:{}",
|
||||||
name, purpose, overlay, &layout_name
|
name, purpose, overlay, &name
|
||||||
);
|
);
|
||||||
|
|
||||||
for (kind, source) in list_layout_sources(&layout_name, kind, overlay, path) {
|
for (kind, source) in list_layout_sources(&name, kind, overlay, path) {
|
||||||
let layout = load_layout_data(source.clone());
|
let layout = load_layout_data(source.clone());
|
||||||
match layout {
|
match layout {
|
||||||
Err(e) => match (e, source) {
|
Err(e) => match (e, source) {
|
||||||
@ -981,7 +978,7 @@ mod tests {
|
|||||||
/// First fallback should be to builtin, not to FALLBACK_LAYOUT_NAME
|
/// First fallback should be to builtin, not to FALLBACK_LAYOUT_NAME
|
||||||
#[test]
|
#[test]
|
||||||
fn fallbacks_order() {
|
fn fallbacks_order() {
|
||||||
let sources = list_layout_sources("nb", ArrangementKind::Base, "Normal", None);
|
let sources = list_layout_sources("nb", ArrangementKind::Base, "", None);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
sources,
|
sources,
|
||||||
@ -998,7 +995,7 @@ mod tests {
|
|||||||
/// If layout contains a "+", it should reach for what's in front of it too.
|
/// If layout contains a "+", it should reach for what's in front of it too.
|
||||||
#[test]
|
#[test]
|
||||||
fn fallbacks_order_base() {
|
fn fallbacks_order_base() {
|
||||||
let sources = list_layout_sources("nb+aliens", ArrangementKind::Base, "Normal", None);
|
let sources = list_layout_sources("nb+aliens", ArrangementKind::Base, "", None);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
sources,
|
sources,
|
||||||
@ -1015,16 +1012,16 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn fallbacks_terminal_order_base() {
|
fn fallbacks_terminal_order_base() {
|
||||||
let sources = list_layout_sources("terminal-nb+aliens", ArrangementKind::Base, "terminal", None);
|
let sources = list_layout_sources("nb+aliens", ArrangementKind::Base, "terminal", None);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
sources,
|
sources,
|
||||||
vec!(
|
vec!(
|
||||||
(ArrangementKind::Base, DataSource::Resource("terminal-nb+aliens".into())),
|
(ArrangementKind::Base, DataSource::Resource("terminal/nb+aliens".into())),
|
||||||
(ArrangementKind::Base, DataSource::Resource("terminal-nb".into())),
|
(ArrangementKind::Base, DataSource::Resource("terminal/nb".into())),
|
||||||
(
|
(
|
||||||
ArrangementKind::Base,
|
ArrangementKind::Base,
|
||||||
DataSource::Resource(FALLBACK_GENERIC_LAYOUT_NAME.into())
|
DataSource::Resource(format!("terminal/{}", FALLBACK_LAYOUT_NAME))
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|||||||
@ -80,19 +80,16 @@ const KEYBOARDS: &[(*const str, *const str)] = &[
|
|||||||
("us+dvorak_wide", include_str!("../data/keyboards/us+dvorak_wide.yaml")),
|
("us+dvorak_wide", include_str!("../data/keyboards/us+dvorak_wide.yaml")),
|
||||||
|
|
||||||
// Others
|
// Others
|
||||||
("number", include_str!("../data/keyboards/number.yaml")),
|
("number/us", include_str!("../data/keyboards/number/us.yaml")),
|
||||||
|
|
||||||
// Terminal
|
// Terminal
|
||||||
("terminal-generic", include_str!("../data/keyboards/terminal/generic.yaml")),
|
("terminal/fr", include_str!("../data/keyboards/terminal/fr.yaml")),
|
||||||
("terminal-generic_wide", include_str!("../data/keyboards/terminal/generic_wide.yaml")),
|
|
||||||
|
|
||||||
("terminal-fr", include_str!("../data/keyboards/terminal/fr.yaml")),
|
("terminal/us", include_str!("../data/keyboards/terminal/us.yaml")),
|
||||||
|
("terminal/us_wide", include_str!("../data/keyboards/terminal/us_wide.yaml")),
|
||||||
("terminal-us", include_str!("../data/keyboards/terminal/us.yaml")),
|
|
||||||
|
|
||||||
// Overlays
|
// Overlays
|
||||||
("emoji", include_str!("../data/keyboards/emoji.yaml")),
|
("emoji/us", include_str!("../data/keyboards/emoji/us.yaml")),
|
||||||
("terminal", include_str!("../data/keyboards/terminal/generic.yaml")),
|
|
||||||
];
|
];
|
||||||
|
|
||||||
pub fn get_keyboard(needle: &str) -> Option<&'static str> {
|
pub fn get_keyboard(needle: &str) -> Option<&'static str> {
|
||||||
@ -175,7 +172,7 @@ mod test {
|
|||||||
#[test]
|
#[test]
|
||||||
fn check_overlays_present() {
|
fn check_overlays_present() {
|
||||||
for name in get_overlays() {
|
for name in get_overlays() {
|
||||||
assert!(get_keyboard(name).is_some());
|
assert!(get_keyboard(&format!("{}/us", name)).is_some());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -86,16 +86,16 @@ foreach layout : [
|
|||||||
'us+dvorak', 'us+dvorak_wide',
|
'us+dvorak', 'us+dvorak_wide',
|
||||||
|
|
||||||
# Terminal keyboards
|
# Terminal keyboards
|
||||||
'terminal-generic', 'terminal-generic_wide',
|
'terminal/fr',
|
||||||
'terminal-fr',
|
'terminal/us',
|
||||||
'terminal-us',
|
'terminal/us_wide',
|
||||||
|
|
||||||
# Block: Not languages.
|
# Block: Not languages.
|
||||||
'emoji',
|
'emoji/us',
|
||||||
'number',
|
'number/us',
|
||||||
]
|
]
|
||||||
extra = []
|
extra = []
|
||||||
if layout == 'emoji'
|
if layout.startswith('emoji/')
|
||||||
extra += ['allow_missing_return']
|
extra += ['allow_missing_return']
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user