]> git.gir.st - VimFx.git/blob - extension/lib/migrations.coffee
Recognozie more ARIA roles as clickable
[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 # 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.
22
23 legacy = require('./legacy')
24 prefs = require('./prefs')
25
26 migrations = []
27
28 migrations[0] = ->
29 conversions =
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'
41 'stop': 'normal.stop'
42 'stop_all': 'normal.stop_all'
43
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'
56
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'
72
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'
84
85 'find': 'normal.find'
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'
91 'help': 'normal.help'
92 'dev': 'normal.dev'
93 'Esc': 'normal.esc'
94
95 'mode_insert_exit': 'ignore.exit'
96
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'
101
102 'mode_find_exit': 'find.exit'
103
104
105 convert = (value) ->
106 keys = try JSON.parse(value)
107 keys = [] unless Array.isArray(keys)
108 for key, index in keys when typeof key == 'string'
109 keys[index] = legacy.convertKey(key)
110 return keys.map((key) -> key.join('')).join(' ')
111
112 for name, newName of conversions
113 pref = "commands.#{name}.keys"
114 prefs.set("mode.#{newName}", convert(prefs.get(pref))) if prefs.has(pref)
115 return
116
117 migrations[1] = ->
118 pref = 'black_list'
119 return unless prefs.has(pref)
120 blacklist = prefs.get(pref)
121 prefs.set(pref, legacy.splitListString(blacklist).join(' '))
122
123 migrations[2] = ->
124 convert = (pref) ->
125 return unless prefs.has(pref)
126 patterns = prefs.get(pref)
127 converted = legacy.splitListString(patterns)
128 .map(legacy.convertPattern)
129 .join(' ')
130 prefs.set(pref, converted)
131
132 convert('prev_patterns')
133 convert('next_patterns')
134
135 migrations[3] = ->
136 pref = 'mode.normal.esc'
137 return unless prefs.has(pref)
138 prefs.set(pref, prefs.get(pref).replace(
139 /(^|\s)(?!(?:<late>)?<force>)(?=\S)/g,
140 '$1<force>'
141 ))
142
143 migrations[4] = ->
144 pref = 'last_scroll_position_mark'
145 return unless prefs.has(pref)
146 prefs.set('scroll.last_position_mark', prefs.get(pref))
147
148 module.exports = migrations
Imprint / Impressum