From d5df15a674d2d8e42cf051d63288509c69e85f98 Mon Sep 17 00:00:00 2001 From: anon Date: Sat, 17 Feb 2024 16:07:17 +0100 Subject: [PATCH] now it actually works --- plugin/escape_dictionary.vim | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/plugin/escape_dictionary.vim b/plugin/escape_dictionary.vim index 0f00201..2534225 100644 --- a/plugin/escape_dictionary.vim +++ b/plugin/escape_dictionary.vim @@ -1,25 +1,14 @@ -let s:colorDictionary = { - \ 'red': '31', - \ 'green': '32', - \ 'yellow': '33', - \ 'blue': '34', - \ 'magenta': '35', - \ 'cyan': '36', - \ 'black': '30', - \ 'white': '37', - \ 'bold': '1', - \ 'italics': '3', - \ 'normal': '0', - \ 'reverse': '7' - \ } +" NOTE: keys() & values() return their results in arbitrary order +let s:colorKeys = ['red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'black', 'white', 'bold', 'italics', 'normal', 'reverse'] +let s:colorValues = [ '31', '32', '33', '34', '35', '36', '30', '37', '1', '3', '0', '7'] function! s:ColorSelected(id, result) - let val = '\033[' . values(s:colorDictionary)[a:result] . 'm' + let val = '\033[' . s:colorValues[a:result-1] . 'm' exec 'normal! i' . val endfunction function! ShowEscapeDictionary() - call popup_menu(keys(s:colorDictionary), #{ + call popup_menu(s:colorKeys, #{ \ callback: 's:ColorSelected', \ }) endfunction