Mercurial > vim
comparison src/ui.c @ 17063:3147c7c2e86b v8.1.1531
patch 8.1.1531: clipboard type name is inconsistent
commit https://github.com/vim/vim/commit/0554fa478d27c611d23a814c987eb66f9daae6f7
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Jun 14 21:36:54 2019 +0200
patch 8.1.1531: clipboard type name is inconsistent
Problem: Clipboard type name is inconsistent.
Solution: Rename VimClipboard to Clipboard_T.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 14 Jun 2019 21:45:06 +0200 |
parents | 221d4b82bc0b |
children | 76ae212a9075 |
comparison
equal
deleted
inserted
replaced
17062:ee88967a2cd5 | 17063:3147c7c2e86b |
---|---|
722 * the GUI starts. | 722 * the GUI starts. |
723 */ | 723 */ |
724 void | 724 void |
725 clip_init(int can_use) | 725 clip_init(int can_use) |
726 { | 726 { |
727 VimClipboard *cb; | 727 Clipboard_T *cb; |
728 | 728 |
729 cb = &clip_star; | 729 cb = &clip_star; |
730 for (;;) | 730 for (;;) |
731 { | 731 { |
732 cb->available = can_use; | 732 cb->available = can_use; |
749 * lying around. If the VIsual mode has ended, make a copy of what was | 749 * lying around. If the VIsual mode has ended, make a copy of what was |
750 * selected so we can still give it to others. Will probably have to make sure | 750 * selected so we can still give it to others. Will probably have to make sure |
751 * this is called whenever VIsual mode is ended. | 751 * this is called whenever VIsual mode is ended. |
752 */ | 752 */ |
753 void | 753 void |
754 clip_update_selection(VimClipboard *clip) | 754 clip_update_selection(Clipboard_T *clip) |
755 { | 755 { |
756 pos_T start, end; | 756 pos_T start, end; |
757 | 757 |
758 /* If visual mode is only due to a redo command ("."), then ignore it */ | 758 /* If visual mode is only due to a redo command ("."), then ignore it */ |
759 if (!redo_VIsual_busy && VIsual_active && (State & NORMAL)) | 759 if (!redo_VIsual_busy && VIsual_active && (State & NORMAL)) |
784 } | 784 } |
785 } | 785 } |
786 } | 786 } |
787 | 787 |
788 void | 788 void |
789 clip_own_selection(VimClipboard *cbd) | 789 clip_own_selection(Clipboard_T *cbd) |
790 { | 790 { |
791 /* | 791 /* |
792 * Also want to check somehow that we are reading from the keyboard rather | 792 * Also want to check somehow that we are reading from the keyboard rather |
793 * than a mapping etc. | 793 * than a mapping etc. |
794 */ | 794 */ |
820 cbd->owned = (clip_gen_own_selection(cbd) == OK); | 820 cbd->owned = (clip_gen_own_selection(cbd) == OK); |
821 #endif | 821 #endif |
822 } | 822 } |
823 | 823 |
824 void | 824 void |
825 clip_lose_selection(VimClipboard *cbd) | 825 clip_lose_selection(Clipboard_T *cbd) |
826 { | 826 { |
827 #ifdef FEAT_X11 | 827 #ifdef FEAT_X11 |
828 int was_owned = cbd->owned; | 828 int was_owned = cbd->owned; |
829 #endif | 829 #endif |
830 int visual_selection = FALSE; | 830 int visual_selection = FALSE; |
858 } | 858 } |
859 #endif | 859 #endif |
860 } | 860 } |
861 | 861 |
862 static void | 862 static void |
863 clip_copy_selection(VimClipboard *clip) | 863 clip_copy_selection(Clipboard_T *clip) |
864 { | 864 { |
865 if (VIsual_active && (State & NORMAL) && clip->available) | 865 if (VIsual_active && (State & NORMAL) && clip->available) |
866 { | 866 { |
867 clip_update_selection(clip); | 867 clip_update_selection(clip); |
868 clip_free_selection(clip); | 868 clip_free_selection(clip); |
988 * Stuff for general mouse selection, without using Visual mode. | 988 * Stuff for general mouse selection, without using Visual mode. |
989 */ | 989 */ |
990 | 990 |
991 static void clip_invert_area(int, int, int, int, int how); | 991 static void clip_invert_area(int, int, int, int, int how); |
992 static void clip_invert_rectangle(int row, int col, int height, int width, int invert); | 992 static void clip_invert_rectangle(int row, int col, int height, int width, int invert); |
993 static void clip_get_word_boundaries(VimClipboard *, int, int); | 993 static void clip_get_word_boundaries(Clipboard_T *, int, int); |
994 static int clip_get_line_end(int); | 994 static int clip_get_line_end(int); |
995 static void clip_update_modeless_selection(VimClipboard *, int, int, | 995 static void clip_update_modeless_selection(Clipboard_T *, int, int, int, int); |
996 int, int); | |
997 | 996 |
998 /* flags for clip_invert_area() */ | 997 /* flags for clip_invert_area() */ |
999 #define CLIP_CLEAR 1 | 998 #define CLIP_CLEAR 1 |
1000 #define CLIP_SET 2 | 999 #define CLIP_SET 2 |
1001 #define CLIP_TOGGLE 3 | 1000 #define CLIP_TOGGLE 3 |
1056 * Start the selection | 1055 * Start the selection |
1057 */ | 1056 */ |
1058 void | 1057 void |
1059 clip_start_selection(int col, int row, int repeated_click) | 1058 clip_start_selection(int col, int row, int repeated_click) |
1060 { | 1059 { |
1061 VimClipboard *cb = &clip_star; | 1060 Clipboard_T *cb = &clip_star; |
1062 | 1061 |
1063 if (cb->state == SELECT_DONE) | 1062 if (cb->state == SELECT_DONE) |
1064 clip_clear_selection(cb); | 1063 clip_clear_selection(cb); |
1065 | 1064 |
1066 row = check_row(row); | 1065 row = check_row(row); |
1128 int button, | 1127 int button, |
1129 int col, | 1128 int col, |
1130 int row, | 1129 int row, |
1131 int_u repeated_click) | 1130 int_u repeated_click) |
1132 { | 1131 { |
1133 VimClipboard *cb = &clip_star; | 1132 Clipboard_T *cb = &clip_star; |
1134 int diff; | 1133 int diff; |
1135 int slen = 1; /* cursor shape width */ | 1134 int slen = 1; // cursor shape width |
1136 | 1135 |
1137 if (button == MOUSE_RELEASE) | 1136 if (button == MOUSE_RELEASE) |
1138 { | 1137 { |
1139 /* Check to make sure we have something selected */ | 1138 /* Check to make sure we have something selected */ |
1140 if (cb->start.lnum == cb->end.lnum && cb->start.col == cb->end.col) | 1139 if (cb->start.lnum == cb->end.lnum && cb->start.col == cb->end.col) |
1324 | 1323 |
1325 /* | 1324 /* |
1326 * Called from outside to clear selected region from the display | 1325 * Called from outside to clear selected region from the display |
1327 */ | 1326 */ |
1328 void | 1327 void |
1329 clip_clear_selection(VimClipboard *cbd) | 1328 clip_clear_selection(Clipboard_T *cbd) |
1330 { | 1329 { |
1331 | 1330 |
1332 if (cbd->state == SELECT_CLEARED) | 1331 if (cbd->state == SELECT_CLEARED) |
1333 return; | 1332 return; |
1334 | 1333 |
1649 * column. Only white-separated words are recognized here. | 1648 * column. Only white-separated words are recognized here. |
1650 */ | 1649 */ |
1651 #define CHAR_CLASS(c) (c <= ' ' ? ' ' : vim_iswordc(c)) | 1650 #define CHAR_CLASS(c) (c <= ' ' ? ' ' : vim_iswordc(c)) |
1652 | 1651 |
1653 static void | 1652 static void |
1654 clip_get_word_boundaries(VimClipboard *cb, int row, int col) | 1653 clip_get_word_boundaries(Clipboard_T *cb, int row, int col) |
1655 { | 1654 { |
1656 int start_class; | 1655 int start_class; |
1657 int temp_col; | 1656 int temp_col; |
1658 char_u *p; | 1657 char_u *p; |
1659 int mboff; | 1658 int mboff; |
1710 * Update the currently selected region by adding and/or subtracting from the | 1709 * Update the currently selected region by adding and/or subtracting from the |
1711 * beginning or end and inverting the changed area(s). | 1710 * beginning or end and inverting the changed area(s). |
1712 */ | 1711 */ |
1713 static void | 1712 static void |
1714 clip_update_modeless_selection( | 1713 clip_update_modeless_selection( |
1715 VimClipboard *cb, | 1714 Clipboard_T *cb, |
1716 int row1, | 1715 int row1, |
1717 int col1, | 1716 int col1, |
1718 int row2, | 1717 int row2, |
1719 int col2) | 1718 int col2) |
1720 { | 1719 { |
1736 cb->end.col = col2; | 1735 cb->end.col = col2; |
1737 } | 1736 } |
1738 } | 1737 } |
1739 | 1738 |
1740 int | 1739 int |
1741 clip_gen_own_selection(VimClipboard *cbd) | 1740 clip_gen_own_selection(Clipboard_T *cbd) |
1742 { | 1741 { |
1743 #ifdef FEAT_XCLIPBOARD | 1742 #ifdef FEAT_XCLIPBOARD |
1744 # ifdef FEAT_GUI | 1743 # ifdef FEAT_GUI |
1745 if (gui.in_use) | 1744 if (gui.in_use) |
1746 return clip_mch_own_selection(cbd); | 1745 return clip_mch_own_selection(cbd); |
1751 return clip_mch_own_selection(cbd); | 1750 return clip_mch_own_selection(cbd); |
1752 #endif | 1751 #endif |
1753 } | 1752 } |
1754 | 1753 |
1755 void | 1754 void |
1756 clip_gen_lose_selection(VimClipboard *cbd) | 1755 clip_gen_lose_selection(Clipboard_T *cbd) |
1757 { | 1756 { |
1758 #ifdef FEAT_XCLIPBOARD | 1757 #ifdef FEAT_XCLIPBOARD |
1759 # ifdef FEAT_GUI | 1758 # ifdef FEAT_GUI |
1760 if (gui.in_use) | 1759 if (gui.in_use) |
1761 clip_mch_lose_selection(cbd); | 1760 clip_mch_lose_selection(cbd); |
1766 clip_mch_lose_selection(cbd); | 1765 clip_mch_lose_selection(cbd); |
1767 #endif | 1766 #endif |
1768 } | 1767 } |
1769 | 1768 |
1770 void | 1769 void |
1771 clip_gen_set_selection(VimClipboard *cbd) | 1770 clip_gen_set_selection(Clipboard_T *cbd) |
1772 { | 1771 { |
1773 if (!clip_did_set_selection) | 1772 if (!clip_did_set_selection) |
1774 { | 1773 { |
1775 /* Updating postponed, so that accessing the system clipboard won't | 1774 /* Updating postponed, so that accessing the system clipboard won't |
1776 * hang Vim when accessing it many times (e.g. on a :g command). */ | 1775 * hang Vim when accessing it many times (e.g. on a :g command). */ |
1792 clip_mch_set_selection(cbd); | 1791 clip_mch_set_selection(cbd); |
1793 #endif | 1792 #endif |
1794 } | 1793 } |
1795 | 1794 |
1796 void | 1795 void |
1797 clip_gen_request_selection(VimClipboard *cbd) | 1796 clip_gen_request_selection(Clipboard_T *cbd) |
1798 { | 1797 { |
1799 #ifdef FEAT_XCLIPBOARD | 1798 #ifdef FEAT_XCLIPBOARD |
1800 # ifdef FEAT_GUI | 1799 # ifdef FEAT_GUI |
1801 if (gui.in_use) | 1800 if (gui.in_use) |
1802 clip_mch_request_selection(cbd); | 1801 clip_mch_request_selection(cbd); |
1808 #endif | 1807 #endif |
1809 } | 1808 } |
1810 | 1809 |
1811 #if (defined(FEAT_X11) && defined(USE_SYSTEM)) || defined(PROTO) | 1810 #if (defined(FEAT_X11) && defined(USE_SYSTEM)) || defined(PROTO) |
1812 int | 1811 int |
1813 clip_gen_owner_exists(VimClipboard *cbd UNUSED) | 1812 clip_gen_owner_exists(Clipboard_T *cbd UNUSED) |
1814 { | 1813 { |
1815 #ifdef FEAT_XCLIPBOARD | 1814 #ifdef FEAT_XCLIPBOARD |
1816 # ifdef FEAT_GUI_GTK | 1815 # ifdef FEAT_GUI_GTK |
1817 if (gui.in_use) | 1816 if (gui.in_use) |
1818 return clip_gtk_owner_exists(cbd); | 1817 return clip_gtk_owner_exists(cbd); |
2370 { | 2369 { |
2371 int motion_type = MAUTO; | 2370 int motion_type = MAUTO; |
2372 long_u len; | 2371 long_u len; |
2373 char_u *p; | 2372 char_u *p; |
2374 char **text_list = NULL; | 2373 char **text_list = NULL; |
2375 VimClipboard *cbd; | 2374 Clipboard_T *cbd; |
2376 char_u *tmpbuf = NULL; | 2375 char_u *tmpbuf = NULL; |
2377 | 2376 |
2378 if (*sel_atom == clip_plus.sel_atom) | 2377 if (*sel_atom == clip_plus.sel_atom) |
2379 cbd = &clip_plus; | 2378 cbd = &clip_plus; |
2380 else | 2379 else |
2461 | 2460 |
2462 void | 2461 void |
2463 clip_x11_request_selection( | 2462 clip_x11_request_selection( |
2464 Widget myShell, | 2463 Widget myShell, |
2465 Display *dpy, | 2464 Display *dpy, |
2466 VimClipboard *cbd) | 2465 Clipboard_T *cbd) |
2467 { | 2466 { |
2468 XEvent event; | 2467 XEvent event; |
2469 Atom type; | 2468 Atom type; |
2470 static int success; | 2469 static int success; |
2471 int i; | 2470 int i; |
2564 { | 2563 { |
2565 static char_u *save_result = NULL; | 2564 static char_u *save_result = NULL; |
2566 static long_u save_length = 0; | 2565 static long_u save_length = 0; |
2567 char_u *string; | 2566 char_u *string; |
2568 int motion_type; | 2567 int motion_type; |
2569 VimClipboard *cbd; | 2568 Clipboard_T *cbd; |
2570 int i; | 2569 int i; |
2571 | 2570 |
2572 if (*sel_atom == clip_plus.sel_atom) | 2571 if (*sel_atom == clip_plus.sel_atom) |
2573 cbd = &clip_plus; | 2572 cbd = &clip_plus; |
2574 else | 2573 else |
2690 else | 2689 else |
2691 clip_lose_selection(&clip_star); | 2690 clip_lose_selection(&clip_star); |
2692 } | 2691 } |
2693 | 2692 |
2694 void | 2693 void |
2695 clip_x11_lose_selection(Widget myShell, VimClipboard *cbd) | 2694 clip_x11_lose_selection(Widget myShell, Clipboard_T *cbd) |
2696 { | 2695 { |
2697 XtDisownSelection(myShell, cbd->sel_atom, | 2696 XtDisownSelection(myShell, cbd->sel_atom, |
2698 XtLastTimestampProcessed(XtDisplay(myShell))); | 2697 XtLastTimestampProcessed(XtDisplay(myShell))); |
2699 } | 2698 } |
2700 | 2699 |
2703 { | 2702 { |
2704 /* To prevent automatically freeing the selection value. */ | 2703 /* To prevent automatically freeing the selection value. */ |
2705 } | 2704 } |
2706 | 2705 |
2707 int | 2706 int |
2708 clip_x11_own_selection(Widget myShell, VimClipboard *cbd) | 2707 clip_x11_own_selection(Widget myShell, Clipboard_T *cbd) |
2709 { | 2708 { |
2710 /* When using the GUI we have proper timestamps, use the one of the last | 2709 /* When using the GUI we have proper timestamps, use the one of the last |
2711 * event. When in the console we don't get events (the terminal gets | 2710 * event. When in the console we don't get events (the terminal gets |
2712 * them), Get the time by a zero-length append, clip_x11_timestamp_cb will | 2711 * them), Get the time by a zero-length append, clip_x11_timestamp_cb will |
2713 * be called with the current timestamp. */ | 2712 * be called with the current timestamp. */ |
2735 /* | 2734 /* |
2736 * Send the current selection to the clipboard. Do nothing for X because we | 2735 * Send the current selection to the clipboard. Do nothing for X because we |
2737 * will fill in the selection only when requested by another app. | 2736 * will fill in the selection only when requested by another app. |
2738 */ | 2737 */ |
2739 void | 2738 void |
2740 clip_x11_set_selection(VimClipboard *cbd UNUSED) | 2739 clip_x11_set_selection(Clipboard_T *cbd UNUSED) |
2741 { | 2740 { |
2742 } | 2741 } |
2743 | 2742 |
2744 #if (defined(FEAT_X11) && defined(FEAT_XCLIPBOARD) && defined(USE_SYSTEM)) \ | 2743 #if (defined(FEAT_X11) && defined(FEAT_XCLIPBOARD) && defined(USE_SYSTEM)) \ |
2745 || defined(PROTO) | 2744 || defined(PROTO) |
2746 int | 2745 int |
2747 clip_x11_owner_exists(VimClipboard *cbd) | 2746 clip_x11_owner_exists(Clipboard_T *cbd) |
2748 { | 2747 { |
2749 return XGetSelectionOwner(X_DISPLAY, cbd->sel_atom) != None; | 2748 return XGetSelectionOwner(X_DISPLAY, cbd->sel_atom) != None; |
2750 } | 2749 } |
2751 #endif | 2750 #endif |
2752 #endif | 2751 #endif |
2755 || defined(FEAT_GUI_GTK) || defined(PROTO) | 2754 || defined(FEAT_GUI_GTK) || defined(PROTO) |
2756 /* | 2755 /* |
2757 * Get the contents of the X CUT_BUFFER0 and put it in "cbd". | 2756 * Get the contents of the X CUT_BUFFER0 and put it in "cbd". |
2758 */ | 2757 */ |
2759 void | 2758 void |
2760 yank_cut_buffer0(Display *dpy, VimClipboard *cbd) | 2759 yank_cut_buffer0(Display *dpy, Clipboard_T *cbd) |
2761 { | 2760 { |
2762 int nbytes = 0; | 2761 int nbytes = 0; |
2763 char_u *buffer = (char_u *)XFetchBuffer(dpy, &nbytes, 0); | 2762 char_u *buffer = (char_u *)XFetchBuffer(dpy, &nbytes, 0); |
2764 | 2763 |
2765 if (nbytes > 0) | 2764 if (nbytes > 0) |