Mercurial > vim
comparison src/evalwindow.c @ 18049:a9f1656f13c9 v8.1.2020
patch 8.1.2020: it is not easy to change the window layout
Commit: https://github.com/vim/vim/commit/d20dcb3d011da6111153109f6e46fbd5c7fe9fb6
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Sep 10 21:22:58 2019 +0200
patch 8.1.2020: it is not easy to change the window layout
Problem: It is not easy to change the window layout.
Solution: Add win_splitmove(). (Andy Massimino, closes https://github.com/vim/vim/issues/4561)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 10 Sep 2019 21:30:05 +0200 |
parents | cf8e0c7e0cb9 |
children | f4b51934d4f8 |
comparison
equal
deleted
inserted
replaced
18048:ceafe0986ad7 | 18049:a9f1656f13c9 |
---|---|
742 list_append_number(rettv->vval.v_list, wp == NULL ? 0 : wp->w_winrow + 1); | 742 list_append_number(rettv->vval.v_list, wp == NULL ? 0 : wp->w_winrow + 1); |
743 list_append_number(rettv->vval.v_list, wp == NULL ? 0 : wp->w_wincol + 1); | 743 list_append_number(rettv->vval.v_list, wp == NULL ? 0 : wp->w_wincol + 1); |
744 } | 744 } |
745 | 745 |
746 /* | 746 /* |
747 * Move the window wp into a new split of targetwin in a given direction | |
748 */ | |
749 static void | |
750 win_move_into_split(win_T *wp, win_T *targetwin, int size, int flags) | |
751 { | |
752 int dir; | |
753 int height = wp->w_height; | |
754 win_T *oldwin = curwin; | |
755 | |
756 if (wp == targetwin) | |
757 return; | |
758 | |
759 // Jump to the target window | |
760 if (curwin != targetwin) | |
761 win_goto(targetwin); | |
762 | |
763 // Remove the old window and frame from the tree of frames | |
764 (void)winframe_remove(wp, &dir, NULL); | |
765 win_remove(wp, NULL); | |
766 last_status(FALSE); // may need to remove last status line | |
767 (void)win_comp_pos(); // recompute window positions | |
768 | |
769 // Split a window on the desired side and put the old window there | |
770 (void)win_split_ins(size, flags, wp, dir); | |
771 | |
772 // If splitting horizontally, try to preserve height | |
773 if (size == 0 && !(flags & WSP_VERT)) | |
774 { | |
775 win_setheight_win(height, wp); | |
776 if (p_ea) | |
777 win_equal(wp, TRUE, 'v'); | |
778 } | |
779 | |
780 #if defined(FEAT_GUI) | |
781 // When 'guioptions' includes 'L' or 'R' may have to remove or add | |
782 // scrollbars. Have to update them anyway. | |
783 gui_may_update_scrollbars(); | |
784 #endif | |
785 | |
786 if (oldwin != curwin) | |
787 win_goto(oldwin); | |
788 } | |
789 | |
790 /* | |
791 * "win_splitmove()" function | |
792 */ | |
793 void | |
794 f_win_splitmove(typval_T *argvars, typval_T *rettv) | |
795 { | |
796 win_T *wp; | |
797 win_T *targetwin; | |
798 int flags = 0, size = 0; | |
799 | |
800 wp = find_win_by_nr_or_id(&argvars[0]); | |
801 targetwin = find_win_by_nr_or_id(&argvars[1]); | |
802 | |
803 if (wp == NULL || targetwin == NULL || wp == targetwin) | |
804 { | |
805 emsg(_(e_invalwindow)); | |
806 rettv->vval.v_number = -1; | |
807 return; | |
808 } | |
809 | |
810 if (argvars[2].v_type != VAR_UNKNOWN) | |
811 { | |
812 dict_T *d; | |
813 dictitem_T *di; | |
814 | |
815 if (argvars[2].v_type != VAR_DICT || argvars[2].vval.v_dict == NULL) | |
816 { | |
817 emsg(_(e_invarg)); | |
818 return; | |
819 } | |
820 | |
821 d = argvars[2].vval.v_dict; | |
822 if (dict_get_number(d, (char_u *)"vertical")) | |
823 flags |= WSP_VERT; | |
824 if ((di = dict_find(d, (char_u *)"rightbelow", -1)) != NULL) | |
825 flags |= tv_get_number(&di->di_tv) ? WSP_BELOW : WSP_ABOVE; | |
826 size = (int)dict_get_number(d, (char_u *)"size"); | |
827 } | |
828 | |
829 win_move_into_split(wp, targetwin, size, flags); | |
830 } | |
831 | |
832 /* | |
747 * "winbufnr(nr)" function | 833 * "winbufnr(nr)" function |
748 */ | 834 */ |
749 void | 835 void |
750 f_winbufnr(typval_T *argvars, typval_T *rettv) | 836 f_winbufnr(typval_T *argvars, typval_T *rettv) |
751 { | 837 { |