summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThang Pham <phamducthang1234@gmail.com>2021-05-17 00:43:06 +0900
committerThang Pham <phamducthang1234@gmail.com>2021-05-17 00:47:19 +0900
commit9680fea0a63e9f9ac6f8d6f7f04617bbf2e6e4d7 (patch)
tree63f3e5c06be790ad7640c7443b039c6d7358063d
parente41ceeb6a336a048093bcf7c4548d966abbff56e (diff)
add default for custom_keymap and add more documentation for custom_keymap in the default config file
-rw-r--r--src/hn-tui-default.toml55
-rw-r--r--src/keybindings.rs1
2 files changed, 32 insertions, 24 deletions
diff --git a/src/hn-tui-default.toml b/src/hn-tui-default.toml
index b16b705..74aef24 100644
--- a/src/hn-tui-default.toml
+++ b/src/hn-tui-default.toml
@@ -144,30 +144,37 @@ toggle_raw_markdown_mode = "T"
# custom keymap
# ---------------------
-# User now can define a custom keymap to navigate
-# between different kinds of StoryView using
-# HN Alogilia "numericFilters" query parameter
-# Below is two examples of such keymap.
-
-# [[keymap.custom_keymap.custom_view_navigation]]
-# key = "M-1"
-# view = "story"
-# by_date = false
-
-# [keymap.custom_keymap.custom_view_navigation.numeric_filters]
-# elapsed_days_interval = {start = 0, end = 3}
-# points_interval = {start = 10}
-# num_comments_interval = {}
-
-# [[keymap.custom_keymap.custom_view_navigation]]
-# key = "M-2"
-# view = "show_hn"
-# by_date = true
-
-# [keymap.custom_keymap.custom_view_navigation.numeric_filters]
-# elapsed_days_interval = {}
-# points_interval = {start = 100, end = 200}
-# num_comments_interval = { end = 100 }
+# User now can define custom keymaps to navigate
+# between different kinds of StoryViews using
+# HN Alogilia "numericFilters" query parameter.
+
+# "custom_view_navigation" is a struct used to define such keymap.
+# Two examples of "keymap.custom_keymap.custom_view_navigation".
+#
+# possible values for "view"
+# - "front_page" -> "Story View - Front Page"
+# - "story" -> "Story View - All Stories"
+# - "ask_hn" -> "Story View - Ask HN"
+# - "show_hn" -> "Story View - Show HN"
+# - "job" -> "Story View - Jobs"
+
+[[keymap.custom_keymap.custom_view_navigation]]
+key = "M-1"
+view = "story"
+by_date = false
+[keymap.custom_keymap.custom_view_navigation.numeric_filters]
+elapsed_days_interval = {start = 0, end = 3} # stories posted between 0 day and 3 days ago
+points_interval = {start = 10} # stories with points >= 10
+num_comments_interval = {} # no restriction on the number of comments
+
+[[keymap.custom_keymap.custom_view_navigation]]
+key = "M-2"
+view = "show_hn"
+by_date = true
+[keymap.custom_keymap.custom_view_navigation.numeric_filters]
+elapsed_days_interval = {}
+points_interval = {start = 50, end = 200}
+num_comments_interval = {end = 100}
# --------------------------
# List of supported keys:
diff --git a/src/keybindings.rs b/src/keybindings.rs
index 190d6fb..ed1829f 100644
--- a/src/keybindings.rs
+++ b/src/keybindings.rs
@@ -7,6 +7,7 @@ use crate::hn_client;
#[derive(Debug, Clone, Deserialize)]
pub struct KeyMap {
+ #[serde(default)]
pub custom_keymap: CustomKeyMap,
pub global_keymap: GlobalKeyMap,
pub story_view_keymap: StoryViewKeyMap,