BRL-CAD
Loading...
Searching...
No Matches
commands.h
Go to the documentation of this file.
1/* C O M M A N D S . H
2 * BRL-CAD
3 *
4 * Copyright (c) 2008-2025 United States Government as represented by
5 * the U.S. Army Research Laboratory.
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public License
9 * version 2.1 as published by the Free Software Foundation.
10 *
11 * This library is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this file; see the file named COPYING for more
18 * information.
19 */
20/** @addtogroup libged
21 *
22 * Geometry EDiting Library Commands
23 *
24 */
25/** @{ */
26/** @file ged/commands.h */
27/** @} */
28
29#ifndef GED_COMMANDS_H
30#define GED_COMMANDS_H
31
32#include "common.h"
33#include "ged/defines.h"
34
35
37
38/** @addtogroup ged_plugins */
39/** @{ */
40/** Execute plugin based command */
41#if !defined(GED_PLUGIN) && !defined(GED_EXEC_NORAW)
42GED_EXPORT extern int ged_exec(struct ged *gedp, int argc, const char *argv[]);
43#endif
44/** @} */
45
46/* LIBGED maintains this list - callers should regard it as read only. This
47 * list will change (size and pointers to individual command strings if
48 * commands are added or removed - caller is responsible for performing a new
49 * call to get an updated list and size if commands are altered. */
50GED_EXPORT size_t ged_cmd_list(const char * const **cmd_list);
51
52/* Report whether a string identifies a valid LIBGED command.
53 *
54 * Returns 1 if cmd is a valid GED command, else returns 0.
55 */
56GED_EXPORT int ged_cmd_exists(const char *cmd);
57
58/* Determine whether cmd1 and cmd2 both refer to the same function pointer
59 * (i.e., they are aliases for the same command.)
60 *
61 * Returns 1 if both cmd1 and cmd2 invoke the same LIBGED function, else
62 * returns 0
63 */
64GED_EXPORT int ged_cmd_same(const char *cmd1, const char *cmd2);
65
66/* Report whether a string identifies a valid LIBGED command. If func is
67 * non-NULL, check that cmd and func both refer to the same function pointer
68 * (i.e., they are aliases for the same command.)
69 *
70 * If func is NULL, a 0 return indicates an valid GED command and non-zero
71 * indicates an invalid command.
72 *
73 * If func is non-null:
74 * 0 indicates both cmd and func strings invoke the same LIBGED function
75 * 1 indicates that either or both of cmd and func were invalid GED commands
76 * 2 indicates that both were valid commands, but they did not match.
77 *
78 * DEPRECATED - use ged_cmd_same and ged_cmd_exists instead.
79 */
80DEPRECATED GED_EXPORT int ged_cmd_valid(const char *cmd, const char *func);
81
82/* Given a candidate cmd name, find the closest match to it among defined
83 * GED commands. Returns the bu_editdist distance between cmd and *ncmd
84 * (0 if they match exactly - i.e. cmd does define a command.)
85 *
86 * Useful for suggesting corrections to commands which are not found.
87 */
88GED_EXPORT extern int
89ged_cmd_lookup(const char **ncmd, const char *cmd);
90
91
92/* Given a partial command string, analyze it and return possible command
93 * completions of the seed string. Typically this functionality is used to
94 * implement "tab completion" or "tab expansion" features in applications. The
95 * possible completions are returned in the completions array, and the returned
96 * value is the count of possible completions found.
97 *
98 * If completions array returned is non-NULL, caller is responsible for freeing
99 * it using bu_argv_free.
100 */
101GED_EXPORT extern int
102ged_cmd_completions(const char ***completions, const char *seed);
103
104/* Given a object name or path string, analyze it and return possible
105 * object-based completions. Typically this functionality is used to implement
106 * "tab completion" or "tab expansion" features in applications. The possible
107 * completions are returned in the completions array, and the returned value is
108 * the count of possible completions found.
109 *
110 * If completions array returned is non-NULL, caller is responsible for freeing
111 * it using bu_argv_free.
112 */
113GED_EXPORT extern int
114ged_geom_completions(const char ***completions, struct bu_vls *cprefix, struct db_i *dbip, const char *seed);
115
116
117/**
118 * Use bu_editor to set up an editor for use with GED
119 * commands that require launching a text editor.
120 *
121 * Will first try to respect environment variables (including looking for
122 * terminal options to launch text editors normally used only in graphical
123 * mode) and then fall back to lookups.
124 *
125 * Applications may supply their own argv array of editors to check using
126 * app_editors_cnt and app_editors in the ged struct - see bu_editor
127 * documentation for more details.
128 */
129GED_EXPORT extern int ged_set_editor(struct ged *gedp, int non_gui);
130
131/**
132 * Clear editor data set by ged_set_editor. User specified app_editors data
133 * is left unchanged.
134 */
135GED_EXPORT extern void ged_clear_editor(struct ged *gedp);
136
137
138/* defined in track.c */
139GED_EXPORT extern int ged_track2(struct bu_vls *log_str, struct rt_wdb *wdbp, const char *argv[]);
140
141
142/* defined in wdb_importFg4Section.c */
143GED_EXPORT int wdb_importFg4Section_cmd(void *data, int argc, const char *argv[]);
144
145
146/* defined in inside.c */
147GED_EXPORT extern int ged_inside_internal(struct ged *gedp,
148 struct rt_db_internal *ip,
149 int argc,
150 const char *argv[],
151 int arg,
152 char *o_name);
153
154
155GED_EXPORT void draw_scene(struct bv_scene_obj *s, struct bview *v);
156
157
158/** @} */
159
160
162
163
164#endif /* GED_COMMANDS_H */
165
166/*
167 * Local Variables:
168 * tab-width: 8
169 * mode: C
170 * indent-tabs-mode: t
171 * c-file-style: "stroustrup"
172 * End:
173 * ex: shiftwidth=4 tabstop=8
174 */
Definition dvec.h:74
int ged_track2(struct bu_vls *log_str, struct rt_wdb *wdbp, const char *argv[])
void draw_scene(struct bv_scene_obj *s, struct bview *v)
void ged_clear_editor(struct ged *gedp)
int ged_set_editor(struct ged *gedp, int non_gui)
int ged_cmd_same(const char *cmd1, const char *cmd2)
int ged_cmd_completions(const char ***completions, const char *seed)
int ged_cmd_lookup(const char **ncmd, const char *cmd)
size_t ged_cmd_list(const char *const **cmd_list)
int ged_inside_internal(struct ged *gedp, struct rt_db_internal *ip, int argc, const char *argv[], int arg, char *o_name)
int ged_geom_completions(const char ***completions, struct bu_vls *cprefix, struct db_i *dbip, const char *seed)
DEPRECATED int ged_cmd_valid(const char *cmd, const char *func)
int ged_cmd_exists(const char *cmd)
int wdb_importFg4Section_cmd(void *data, int argc, const char *argv[])
Header file for the BRL-CAD common definitions.
#define DEPRECATED
Definition common.h:401
int ged_exec(struct ged *gedp, int argc, const char *argv[])
Definition vls.h:53
Definition defines.h:167
Definition wdb.h:62