2 # Copyright Simon Lydell 2015.
4 # This file is part of VimFx.
6 # VimFx is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # VimFx is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with VimFx. If not, see <http://www.gnu.org/licenses/>.
20 # This file contains a list of functions that upgrade certain parts of VimFx
21 # from an old format to a new one, without breaking backwards compatibility.
23 legacy = require('./legacy')
24 prefs = require('./prefs')
30 'focus': 'normal.focus_location_bar'
31 'focus_search': 'normal.focus_search_bar'
32 'paste': 'normal.paste_and_go'
33 'paste_tab': 'normal.paste_and_go_in_tab'
34 'marker_yank': 'normal.follow_copy'
35 'marker_focus': 'normal.follow_focus'
36 'yank': 'normal.copy_current_url'
37 'reload': 'normal.reload'
38 'reload_force': 'normal.reload_force'
39 'reload_all': 'normal.reload_all'
40 'reload_all_force': 'normal.reload_all_force'
42 'stop_all': 'normal.stop_all'
44 'scroll_to_top': 'normal.scroll_to_top'
45 'scroll_to_bottom': 'normal.scroll_to_bottom'
46 'scroll_to_left': 'normal.scroll_to_left'
47 'scroll_to_right': 'normal.scroll_to_right'
48 'scroll_down': 'normal.scroll_down'
49 'scroll_up': 'normal.scroll_up'
50 'scroll_left': 'normal.scroll_left'
51 'scroll_right': 'normal.scroll_right'
52 'scroll_half_page_down': 'normal.scroll_half_page_down'
53 'scroll_half_page_up': 'normal.scroll_half_page_up'
54 'scroll_page_down': 'normal.scroll_page_down'
55 'scroll_page_up': 'normal.scroll_page_up'
57 'open_tab': 'normal.tab_new'
58 'tab_prev': 'normal.tab_select_previous'
59 'tab_next': 'normal.tab_select_next'
60 'tab_move_left': 'normal.tab_move_backward'
61 'tab_move_right': 'normal.tab_move_forward'
62 'home': 'normal.go_home'
63 'tab_first': 'normal.tab_select_first'
64 'tab_first_non_pinned': 'normal.tab_select_first_non_pinned'
65 'tab_last': 'normal.tab_select_last'
66 'toggle_pin_tab': 'normal.tab_toggle_pinned'
67 'duplicate_tab': 'normal.tab_duplicate'
68 'close_tabs_to_end': 'normal.tab_close_to_end'
69 'close_other_tabs': 'normal.tab_close_other'
70 'close_tab': 'normal.tab_close'
71 'restore_tab': 'normal.tab_restore'
73 'follow': 'normal.follow'
74 'follow_in_tab': 'normal.follow_in_tab'
75 'follow_in_focused_tab': 'normal.follow_in_focused_tab'
76 'follow_multiple': 'normal.follow_multiple'
77 'follow_previous': 'normal.follow_previous'
78 'follow_next': 'normal.follow_next'
79 'text_input': 'normal.text_input'
80 'go_up_path': 'normal.go_up_path'
81 'go_to_root': 'normal.go_to_root'
82 'back': 'normal.history_back'
83 'forward': 'normal.history_forward'
86 'find_hl': 'normal.find_highlight_all'
87 'find_next': 'normal.find_next'
88 'find_prev': 'normal.find_previous'
89 'insert_mode': 'normal.enter_mode_ignore'
90 'quote': 'normal.quote'
95 'mode_insert_exit': 'ignore.exit'
97 'mode_hints_exit': 'hints.exit'
98 'mode_hints_rotate_markers_forward': 'hints.rotate_markers_forward'
99 'mode_hints_rotate_markers_backward': 'hints.rotate_markers_backward'
100 'mode_hints_delete_hint_char': 'hints.delete_hint_char'
102 'mode_find_exit': 'find.exit'
107 try JSON.parse(value)
109 for key, index in keys when typeof key == 'string'
110 keys[index] = legacy.convertKey(key)
111 return keys.map((key) -> key.join('')).join(' ')
113 for name, newName of conversions
114 pref = "commands.#{ name }.keys"
115 prefs.set("mode.#{ newName }", convert(prefs.get(pref))) if prefs.has(pref)
120 return unless prefs.has(pref)
121 blacklist = prefs.get(pref)
122 prefs.set(pref, legacy.splitListString(blacklist).join(' '))
126 return unless prefs.has(pref)
127 patterns = prefs.get(pref)
128 converted = legacy.splitListString(patterns)
129 .map(legacy.convertPattern)
131 prefs.set(pref, converted)
133 convert('prev_patterns')
134 convert('next_patterns')
136 module.exports = migrations