2 /* This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 /* Modification History */
19 /* Created on 10/05/01 by Dan Espen (dane):
20 Extracted from fvwm/cursor.c.
21 Contains common routine to verify and convert a cursor name
22 into a cursor number from X11/cursorfont.h.
23 Used by fvwm CursorStyle command and FvwmForm.
28 #include <X11/cursorfont.h>
32 * fvwmCursorNameToIndex: return the number of a X11 cursor from its
33 * name, if not found return -1.
35 int fvwmCursorNameToIndex (char *cursor_name
)
37 static const struct CursorNameIndex
{
42 {"based_arrow_down", XC_based_arrow_down
},
43 {"based_arrow_up", XC_based_arrow_up
},
45 {"bogosity", XC_bogosity
},
46 {"bottom_left_corner", XC_bottom_left_corner
},
47 {"bottom_right_corner", XC_bottom_right_corner
},
48 {"bottom_side", XC_bottom_side
},
49 {"bottom_tee", XC_bottom_tee
},
50 {"box_spiral", XC_box_spiral
},
51 {"center_ptr", XC_center_ptr
},
52 {"circle", XC_circle
},
54 {"coffee_mug", XC_coffee_mug
},
56 {"cross_reverse", XC_cross_reverse
},
57 {"crosshair", XC_crosshair
},
58 {"diamond_cross", XC_diamond_cross
},
60 {"dotbox", XC_dotbox
},
61 {"double_arrow", XC_double_arrow
},
62 {"draft_large", XC_draft_large
},
63 {"draft_small", XC_draft_small
},
64 {"draped_box", XC_draped_box
},
65 {"exchange", XC_exchange
},
67 {"gobbler", XC_gobbler
},
73 {"iron_cross", XC_iron_cross
},
74 {"left_ptr", XC_left_ptr
},
75 {"left_side", XC_left_side
},
76 {"left_tee", XC_left_tee
},
77 {"leftbutton", XC_leftbutton
},
78 {"ll_angle", XC_ll_angle
},
79 {"lr_angle", XC_lr_angle
},
81 {"middlebutton", XC_middlebutton
},
83 {"pencil", XC_pencil
},
84 {"pirate", XC_pirate
},
86 {"question_arrow", XC_question_arrow
},
87 {"right_ptr", XC_right_ptr
},
88 {"right_side", XC_right_side
},
89 {"right_tee", XC_right_tee
},
90 {"rightbutton", XC_rightbutton
},
91 {"rtl_logo", XC_rtl_logo
},
92 {"sailboat", XC_sailboat
},
93 {"sb_down_arrow", XC_sb_down_arrow
},
94 {"sb_h_double_arrow", XC_sb_h_double_arrow
},
95 {"sb_left_arrow", XC_sb_left_arrow
},
96 {"sb_right_arrow", XC_sb_right_arrow
},
97 {"sb_up_arrow", XC_sb_up_arrow
},
98 {"sb_v_double_arrow", XC_sb_v_double_arrow
},
99 {"sizing", XC_sizing
},
100 {"spider", XC_spider
},
101 {"spraycan", XC_spraycan
},
103 {"target", XC_target
},
104 {"tcross", XC_tcross
},
105 {"top_left_arrow", XC_top_left_arrow
},
106 {"top_left_corner", XC_top_left_corner
},
107 {"top_right_corner", XC_top_right_corner
},
108 {"top_side", XC_top_side
},
109 {"top_tee", XC_top_tee
},
111 {"ul_angle", XC_ul_angle
},
112 {"umbrella", XC_umbrella
},
113 {"ur_angle", XC_ur_angle
},
115 {"x_cursor", XC_X_cursor
},
121 int up
= (sizeof cursor_table
/ sizeof cursor_table
[0]) - 1;
126 if (!cursor_name
|| cursor_name
[0] == 0 ||
127 strlen(cursor_name
) >= sizeof temp
)
129 strcpy(temp
, cursor_name
);
131 for (s
= temp
; *s
!= 0; s
++)
137 middle
= (down
+ up
) / 2;
138 if ((cond
= strcmp(temp
, cursor_table
[middle
].name
)) < 0)
143 return cursor_table
[middle
].number
;