To: vim_dev@googlegroups.com Subject: Patch 8.2.1478 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.1478 Problem: Vim9: cannot use "true" for some popup options. Solution: Add dict_get_bool(). (closes #6725) Files: src/dict.c, src/proto/dict.pro, src/popupwin.c *** ../vim-8.2.1477/src/dict.c 2020-08-13 22:47:20.373992741 +0200 --- src/dict.c 2020-08-18 12:48:31.588701285 +0200 *************** *** 703,708 **** --- 703,723 ---- } /* + * Get a bool item (number or true/false) from a dictionary. + * Returns "def" if the entry doesn't exist. + */ + varnumber_T + dict_get_bool(dict_T *d, char_u *key, int def) + { + dictitem_T *di; + + di = dict_find(d, key, -1); + if (di == NULL) + return def; + return tv_get_bool(&di->di_tv); + } + + /* * Return an allocated string with the string representation of a Dictionary. * May return NULL. */ *** ../vim-8.2.1477/src/proto/dict.pro 2020-06-27 14:11:50.494644105 +0200 --- src/proto/dict.pro 2020-08-18 12:49:45.720268015 +0200 *************** *** 31,36 **** --- 31,37 ---- varnumber_T dict_get_number(dict_T *d, char_u *key); varnumber_T dict_get_number_def(dict_T *d, char_u *key, int def); varnumber_T dict_get_number_check(dict_T *d, char_u *key); + varnumber_T dict_get_bool(dict_T *d, char_u *key, int def); char_u *dict2string(typval_T *tv, int copyID, int restore_copyID); int eval_dict(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int literal); void dict_extend(dict_T *d1, dict_T *d2, char_u *action); *** ../vim-8.2.1477/src/popupwin.c 2020-08-10 21:19:04.283641797 +0200 --- src/popupwin.c 2020-08-18 12:58:12.257308835 +0200 *************** *** 438,446 **** if (nr != MAXCOL) wp->w_wantcol = nr; ! di = dict_find(d, (char_u *)"fixed", -1); ! if (di != NULL) ! wp->w_popup_fixed = dict_get_number(d, (char_u *)"fixed") != 0; { poppos_T ppt = get_pos_entry(d, TRUE); --- 438,447 ---- if (nr != MAXCOL) wp->w_wantcol = nr; ! ! nr = dict_get_bool(d, (char_u *)"fixed", -1); ! if (nr != -1) ! wp->w_popup_fixed = nr != 0; { poppos_T ppt = get_pos_entry(d, TRUE); *************** *** 674,710 **** wp->w_popup_title = vim_strsave(str); } ! di = dict_find(dict, (char_u *)"wrap", -1); ! if (di != NULL) ! { ! nr = dict_get_number(dict, (char_u *)"wrap"); wp->w_p_wrap = nr != 0; - } ! di = dict_find(dict, (char_u *)"drag", -1); ! if (di != NULL) { - nr = dict_get_number(dict, (char_u *)"drag"); if (nr) wp->w_popup_flags |= POPF_DRAG; else wp->w_popup_flags &= ~POPF_DRAG; } ! di = dict_find(dict, (char_u *)"posinvert", -1); ! if (di != NULL) { - nr = dict_get_number(dict, (char_u *)"posinvert"); if (nr) wp->w_popup_flags |= POPF_POSINVERT; else wp->w_popup_flags &= ~POPF_POSINVERT; } ! di = dict_find(dict, (char_u *)"resize", -1); ! if (di != NULL) { - nr = dict_get_number(dict, (char_u *)"resize"); if (nr) wp->w_popup_flags |= POPF_RESIZE; else --- 675,705 ---- wp->w_popup_title = vim_strsave(str); } ! nr = dict_get_bool(dict, (char_u *)"wrap", -1); ! if (nr != -1) wp->w_p_wrap = nr != 0; ! nr = dict_get_bool(dict, (char_u *)"drag", -1); ! if (nr != -1) { if (nr) wp->w_popup_flags |= POPF_DRAG; else wp->w_popup_flags &= ~POPF_DRAG; } ! nr = dict_get_bool(dict, (char_u *)"posinvert", -1); ! if (nr != -1) { if (nr) wp->w_popup_flags |= POPF_POSINVERT; else wp->w_popup_flags &= ~POPF_POSINVERT; } ! nr = dict_get_bool(dict, (char_u *)"resize", -1); ! if (nr != -1) { if (nr) wp->w_popup_flags |= POPF_RESIZE; else *************** *** 902,911 **** set_callback(&wp->w_filter_cb, &callback); } } ! di = dict_find(dict, (char_u *)"mapping", -1); ! if (di != NULL) { - nr = dict_get_number(dict, (char_u *)"mapping"); if (nr) wp->w_popup_flags |= POPF_MAPPING; else --- 897,905 ---- set_callback(&wp->w_filter_cb, &callback); } } ! nr = dict_get_bool(dict, (char_u *)"mapping", -1); ! if (nr != -1) { if (nr) wp->w_popup_flags |= POPF_MAPPING; else *************** *** 950,956 **** apply_general_options(wp, dict); ! nr = dict_get_number(dict, (char_u *)"hidden"); if (nr > 0) wp->w_popup_flags |= POPF_HIDDEN; --- 944,950 ---- apply_general_options(wp, dict); ! nr = dict_get_bool(dict, (char_u *)"hidden", FALSE); if (nr > 0) wp->w_popup_flags |= POPF_HIDDEN; *** ../vim-8.2.1477/src/version.c 2020-08-17 22:21:32.751993070 +0200 --- src/version.c 2020-08-18 13:03:20.155510888 +0200 *************** *** 756,757 **** --- 756,759 ---- { /* Add new patch number below this line */ + /**/ + 1478, /**/ -- hundred-and-one symptoms of being an internet addict: 232. You start conversations with, "Have you gotten an ISDN line?" /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///