]> git.gir.st - VimFx.git/blob - extension/lib/migrations.coffee
Major refactor: Rework all UI and related improvements
[VimFx.git] / extension / lib / migrations.coffee
1 ###
2 # Copyright Simon Lydell 2015.
3 #
4 # This file is part of VimFx.
5 #
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.
10 #
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.
15 #
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/>.
18 ###
19
20 legacy = require('./legacy')
21 prefs = require('./prefs')
22
23 migrations = []
24
25 migrations[0] = ->
26 conversions =
27 'focus': 'normal.focus_location_bar'
28 'focus_search': 'normal.focus_search_bar'
29 'paste': 'normal.paste_and_go'
30 'paste_tab': 'normal.paste_and_go_in_tab'
31 'marker_yank': 'normal.follow_copy'
32 'marker_focus': 'normal.follow_focus'
33 'yank': 'normal.copy_current_url'
34 'reload': 'normal.reload'
35 'reload_force': 'normal.reload_force'
36 'reload_all': 'normal.reload_all'
37 'reload_all_force': 'normal.reload_all_force'
38 'stop': 'normal.stop'
39 'stop_all': 'normal.stop_all'
40
41 'scroll_to_top': 'normal.scroll_to_top'
42 'scroll_to_bottom': 'normal.scroll_to_bottom'
43 'scroll_to_left': 'normal.scroll_to_left'
44 'scroll_to_right': 'normal.scroll_to_right'
45 'scroll_down': 'normal.scroll_down'
46 'scroll_up': 'normal.scroll_up'
47 'scroll_left': 'normal.scroll_left'
48 'scroll_right': 'normal.scroll_right'
49 'scroll_half_page_down': 'normal.scroll_half_page_down'
50 'scroll_half_page_up': 'normal.scroll_half_page_up'
51 'scroll_page_down': 'normal.scroll_page_down'
52 'scroll_page_up': 'normal.scroll_page_up'
53
54 'open_tab': 'normal.tab_new'
55 'tab_prev': 'normal.tab_select_previous'
56 'tab_next': 'normal.tab_select_next'
57 'tab_move_left': 'normal.tab_move_backward'
58 'tab_move_right': 'normal.tab_move_forward'
59 'home': 'normal.go_home'
60 'tab_first': 'normal.tab_select_first'
61 'tab_first_non_pinned': 'normal.tab_select_first_non_pinned'
62 'tab_last': 'normal.tab_select_last'
63 'toggle_pin_tab': 'normal.tab_toggle_pinned'
64 'duplicate_tab': 'normal.tab_duplicate'
65 'close_tabs_to_end': 'normal.tab_close_to_end'
66 'close_other_tabs': 'normal.tab_close_other'
67 'close_tab': 'normal.tab_close'
68 'restore_tab': 'normal.tab_restore'
69
70 'follow': 'normal.follow'
71 'follow_in_tab': 'normal.follow_in_tab'
72 'follow_in_focused_tab': 'normal.follow_in_focused_tab'
73 'follow_multiple': 'normal.follow_multiple'
74 'follow_previous': 'normal.follow_previous'
75 'follow_next': 'normal.follow_next'
76 'text_input': 'normal.text_input'
77 'go_up_path': 'normal.go_up_path'
78 'go_to_root': 'normal.go_to_root'
79 'back': 'normal.history_back'
80 'forward': 'normal.history_forward'
81
82 'find': 'normal.find'
83 'find_hl': 'normal.find_highlight_all'
84 'find_next': 'normal.find_next'
85 'find_prev': 'normal.find_previous'
86 'insert_mode': 'normal.enter_mode_insert'
87 'quote': 'normal.quote'
88 'help': 'normal.help'
89 'dev': 'normal.dev'
90 'Esc': 'normal.esc'
91
92 'mode_insert_exit': 'insert.exit'
93
94 'mode_hints_exit': 'hints.exit'
95 'mode_hints_rotate_markers_forward': 'hints.rotate_markers_forward'
96 'mode_hints_rotate_markers_backward': 'hints.rotate_markers_backward'
97 'mode_hints_delete_hint_char': 'hints.delete_hint_char'
98
99 'mode_find_exit': 'find.exit'
100
101
102 convert = (value) ->
103 keys =
104 try JSON.parse(value)
105 catch then []
106 for key, index in keys when typeof key == 'string'
107 keys[index] = legacy.convertKey(key)
108 return keys.map((key) -> key.join('')).join(' ')
109
110 for name, newName of conversions
111 pref = "commands.#{ name }.keys"
112 prefs.set("mode.#{ newName }", convert(prefs.get(pref))) if prefs.has(pref)
113 return
114
115 migrations[1] = ->
116 pref = 'black_list'
117 return unless prefs.has(pref)
118 blacklist = prefs.get(pref)
119 prefs.set(pref, legacy.splitListString(blacklist).join(' '))
120
121 migrations[2] = ->
122 convert = (pref) ->
123 return unless prefs.has(pref)
124 patterns = prefs.get(pref)
125 converted = legacy.splitListString(patterns)
126 .map(legacy.convertPattern)
127 .join(' ')
128 prefs.set(pref, converted)
129
130 convert('prev_patterns')
131 convert('next_patterns')
132
133 module.exports = migrations
Imprint / Impressum