Cleanup: 'return' parameters to the end of functions, and use 'r_' prefix for them.
This commit is contained in:
parent
947cdb3acd
commit
9133f5a357
|
@ -960,9 +960,7 @@ static bool ui_but_event_operator_string(const bContext *C, uiBut *but, char *bu
|
|||
if (but->optype) {
|
||||
IDProperty *prop = (but->opptr) ? but->opptr->data : NULL;
|
||||
|
||||
if (WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, true,
|
||||
buf, buf_len))
|
||||
{
|
||||
if (WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, true, buf_len, buf)) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
@ -977,8 +975,7 @@ static bool ui_but_event_operator_string(const bContext *C, uiBut *but, char *bu
|
|||
|
||||
IDP_AssignString(prop_menu_name, mt->idname, sizeof(mt->idname));
|
||||
|
||||
if (WM_key_event_operator_string(C, "WM_OT_call_menu", WM_OP_INVOKE_REGION_WIN, prop_menu, true,
|
||||
buf, buf_len))
|
||||
if (WM_key_event_operator_string(C, "WM_OT_call_menu", WM_OP_INVOKE_REGION_WIN, prop_menu, true, buf_len, buf))
|
||||
{
|
||||
found = true;
|
||||
}
|
||||
|
@ -1083,7 +1080,7 @@ static bool ui_but_event_property_operator_string(const bContext *C, uiBut *but,
|
|||
for (i = 0; (i < num_ops) && (ctx_toggle_opnames[i]); i++) {
|
||||
//printf("\t%s\n", ctx_toggle_opnames[i]);
|
||||
if (WM_key_event_operator_string(C, ctx_toggle_opnames[i], WM_OP_INVOKE_REGION_WIN, prop_path, false,
|
||||
buf, buf_len))
|
||||
buf_len, buf))
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
|
|
|
@ -6287,7 +6287,7 @@ static void but_shortcut_name_func(bContext *C, void *arg1, int UNUSED(event))
|
|||
|
||||
/* complex code to change name of button */
|
||||
if (WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, true,
|
||||
shortcut_str, sizeof(shortcut_str)))
|
||||
sizeof(shortcut_str), shortcut_str))
|
||||
{
|
||||
ui_but_add_shortcut(but, shortcut_str, true);
|
||||
}
|
||||
|
|
|
@ -668,7 +668,7 @@ static uiBut *ui_item_with_label(uiLayout *layout, uiBlock *block, const char *n
|
|||
if (RNA_struct_is_a(ptr->type, &RNA_KeyMapItem)) {
|
||||
char buf[128];
|
||||
|
||||
WM_keymap_item_to_string(ptr->data, buf, sizeof(buf), false);
|
||||
WM_keymap_item_to_string(ptr->data, false, sizeof(buf), buf);
|
||||
|
||||
but = uiDefButR_prop(block, UI_BTYPE_HOTKEY_EVENT, 0, buf, x, y, w, h, ptr, prop, 0, 0, 0, -1, -1, NULL);
|
||||
UI_but_func_set(but, ui_keymap_but_cb, but, NULL);
|
||||
|
@ -1921,7 +1921,7 @@ void uiItemMenuEnumO(uiLayout *layout, bContext *C, const char *opname, const ch
|
|||
{
|
||||
char keybuf[128];
|
||||
if (WM_key_event_operator_string(C, ot->idname, layout->root->opcontext, NULL, false,
|
||||
keybuf, sizeof(keybuf)))
|
||||
sizeof(keybuf), keybuf))
|
||||
{
|
||||
ui_but_add_shortcut(but, keybuf, false);
|
||||
}
|
||||
|
|
|
@ -3299,7 +3299,7 @@ static void operator_search_cb(const bContext *C, void *UNUSED(arg), const char
|
|||
/* check for hotkey */
|
||||
if (len < sizeof(name) - 6) {
|
||||
if (WM_key_event_operator_string(C, ot->idname, WM_OP_EXEC_DEFAULT, NULL, true,
|
||||
&name[len + 1], sizeof(name) - len - 1))
|
||||
sizeof(name) - len - 1, &name[len + 1]))
|
||||
{
|
||||
name[len] = UI_SEP_CHAR;
|
||||
}
|
||||
|
|
|
@ -4422,7 +4422,7 @@ static void applyShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
|
|||
if (t->keymap) {
|
||||
wmKeyMapItem *kmi = WM_modalkeymap_find_propvalue(t->keymap, TFM_MODAL_RESIZE);
|
||||
if (kmi) {
|
||||
ofs += WM_keymap_item_to_string(kmi, str + ofs, MAX_INFO_LEN - ofs, false);
|
||||
ofs += WM_keymap_item_to_string(kmi, false, MAX_INFO_LEN - ofs, str + ofs);
|
||||
}
|
||||
}
|
||||
BLI_snprintf(str + ofs, MAX_INFO_LEN - ofs, IFACE_(" or Alt) Even Thickness %s"),
|
||||
|
@ -7743,7 +7743,7 @@ static void headerSeqSlide(TransInfo *t, const float val[2], char str[MAX_INFO_L
|
|||
if (t->keymap) {
|
||||
wmKeyMapItem *kmi = WM_modalkeymap_find_propvalue(t->keymap, TFM_MODAL_TRANSLATE);
|
||||
if (kmi) {
|
||||
ofs += WM_keymap_item_to_string(kmi, str + ofs, MAX_INFO_LEN - ofs, false);
|
||||
ofs += WM_keymap_item_to_string(kmi, false, MAX_INFO_LEN - ofs, str + ofs);
|
||||
}
|
||||
}
|
||||
ofs += BLI_snprintf(str + ofs, MAX_INFO_LEN - ofs, IFACE_(" or Alt) Expand to fit %s"),
|
||||
|
|
|
@ -68,7 +68,7 @@ wmKeyMapItem *WM_keymap_add_menu_pie(struct wmKeyMap *keymap, const char *idname
|
|||
int val, int modifier, int keymodifier);
|
||||
|
||||
bool WM_keymap_remove_item(struct wmKeyMap *keymap, struct wmKeyMapItem *kmi);
|
||||
int WM_keymap_item_to_string(wmKeyMapItem *kmi, char *str, const int len, const bool compact);
|
||||
int WM_keymap_item_to_string(wmKeyMapItem *kmi, const bool compact, const int len, char *r_str);
|
||||
|
||||
wmKeyMap *WM_keymap_list_find(ListBase *lb, const char *idname, int spaceid, int regionid);
|
||||
wmKeyMap *WM_keymap_find(struct wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid);
|
||||
|
@ -82,11 +82,11 @@ int WM_keymap_item_compare(struct wmKeyMapItem *k1, struct wmKeyMapItem *k2);
|
|||
|
||||
/* Modal Keymap */
|
||||
|
||||
int WM_modalkeymap_operator_items_to_string(struct wmOperatorType *ot, const int propvalue,
|
||||
char *str, const int len, const bool compact);
|
||||
int WM_modalkeymap_operator_items_to_string(
|
||||
struct wmOperatorType *ot, const int propvalue, const bool compact, const int len, char *r_str);
|
||||
char *WM_modalkeymap_operator_items_to_string_buf(
|
||||
struct wmOperatorType *ot, const int propvalue,
|
||||
char **str, int *available_len, const int max_len, const bool compact);
|
||||
struct wmOperatorType *ot, const int propvalue, const bool compact,
|
||||
const int max_len, int *r_available_len, char **r_str);
|
||||
|
||||
wmKeyMap *WM_modalkeymap_add(struct wmKeyConfig *keyconf, const char *idname, struct EnumPropertyItem *items);
|
||||
wmKeyMap *WM_modalkeymap_get(struct wmKeyConfig *keyconf, const char *idname);
|
||||
|
@ -107,14 +107,14 @@ int WM_keymap_map_type_get(struct wmKeyMapItem *kmi);
|
|||
const char *WM_key_event_string(const short type, const bool compact);
|
||||
int WM_keymap_item_raw_to_string(
|
||||
const short shift, const short ctrl, const short alt, const short oskey, const short keymodifier,
|
||||
const short type, char *str, const int len, const bool compact);
|
||||
const short type, const bool compact, const int len, char *r_str);
|
||||
int WM_key_event_operator_id(
|
||||
const struct bContext *C, const char *opname, int opcontext,
|
||||
struct IDProperty *properties, const bool is_hotkey,
|
||||
struct wmKeyMap **r_keymap);
|
||||
char *WM_key_event_operator_string(
|
||||
const struct bContext *C, const char *opname, int opcontext,
|
||||
struct IDProperty *properties, const bool is_strict, char *str, int len);
|
||||
struct IDProperty *properties, const bool is_strict, int len, char *r_str);
|
||||
|
||||
const char *WM_bool_as_string(bool test);
|
||||
|
||||
|
|
|
@ -901,8 +901,8 @@ const char *WM_key_event_string(const short type, const bool compact)
|
|||
|
||||
/* TODO: also support (some) value, like e.g. double-click? */
|
||||
int WM_keymap_item_raw_to_string(const short shift, const short ctrl, const short alt, const short oskey,
|
||||
const short keymodifier, const short type,
|
||||
char *str, const int len, const bool compact)
|
||||
const short keymodifier, const short type, const bool compact,
|
||||
const int len, char *r_str)
|
||||
{
|
||||
#define ADD_SEP if (p != buf) *p++ = ' '; (void)0
|
||||
|
||||
|
@ -959,19 +959,19 @@ int WM_keymap_item_raw_to_string(const short shift, const short ctrl, const shor
|
|||
BLI_assert(p - buf < sizeof(buf));
|
||||
|
||||
/* We need utf8 here, otherwise we may 'cut' some unicode chars like arrows... */
|
||||
return BLI_strncpy_utf8_rlen(str, buf, len);
|
||||
return BLI_strncpy_utf8_rlen(r_str, buf, len);
|
||||
|
||||
#undef ADD_SEP
|
||||
}
|
||||
|
||||
int WM_keymap_item_to_string(wmKeyMapItem *kmi, char *str, const int len, const bool compact)
|
||||
int WM_keymap_item_to_string(wmKeyMapItem *kmi, const bool compact, const int len, char *r_str)
|
||||
{
|
||||
return WM_keymap_item_raw_to_string(kmi->shift, kmi->ctrl, kmi->alt, kmi->oskey,
|
||||
kmi->keymodifier, kmi->type, str, len, compact);
|
||||
kmi->keymodifier, kmi->type, compact, len, r_str);
|
||||
}
|
||||
|
||||
int WM_modalkeymap_operator_items_to_string(
|
||||
wmOperatorType *ot, const int propvalue, char *str, const int len, const bool compact)
|
||||
wmOperatorType *ot, const int propvalue, const bool compact, const int len, char *r_str)
|
||||
{
|
||||
wmKeyMap *km = ot->modalkeymap;
|
||||
int totlen = 0;
|
||||
|
@ -986,13 +986,13 @@ int WM_modalkeymap_operator_items_to_string(
|
|||
kmi = wm_modalkeymap_find_propvalue_iter(km, kmi, propvalue))
|
||||
{
|
||||
if (add_sep) {
|
||||
str[totlen++] = '/';
|
||||
str[totlen] = '\0';
|
||||
r_str[totlen++] = '/';
|
||||
r_str[totlen] = '\0';
|
||||
}
|
||||
else {
|
||||
add_sep = true;
|
||||
}
|
||||
totlen += WM_keymap_item_to_string(kmi, &str[totlen], len - totlen, compact);
|
||||
totlen += WM_keymap_item_to_string(kmi, compact, len - totlen, &r_str[totlen]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1000,18 +1000,19 @@ int WM_modalkeymap_operator_items_to_string(
|
|||
}
|
||||
|
||||
char *WM_modalkeymap_operator_items_to_string_buf(
|
||||
wmOperatorType *ot, const int propvalue, char **str, int *available_len, const int max_len, const bool compact)
|
||||
wmOperatorType *ot, const int propvalue, const bool compact,
|
||||
const int max_len, int *r_available_len, char **r_str)
|
||||
{
|
||||
char *ret = *str;
|
||||
char *ret = *r_str;
|
||||
|
||||
if (*available_len > 1) {
|
||||
if (*r_available_len > 1) {
|
||||
int used_len = WM_modalkeymap_operator_items_to_string(
|
||||
ot, propvalue, ret, min_ii(*available_len, max_len), compact) + 1;
|
||||
ot, propvalue, compact, min_ii(*r_available_len, max_len), ret) + 1;
|
||||
|
||||
*available_len -= used_len;
|
||||
*str += used_len;
|
||||
if (*available_len == 0) {
|
||||
(*str)--; /* So that *str keeps pointing on a valid char, we'll stay on it anyway. */
|
||||
*r_available_len -= used_len;
|
||||
*r_str += used_len;
|
||||
if (*r_available_len == 0) {
|
||||
(*r_str)--; /* So that *str keeps pointing on a valid char, we'll stay on it anyway. */
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -1078,7 +1079,7 @@ static wmKeyMapItem *wm_keymap_item_find_handlers(
|
|||
|
||||
if (IDP_EqualsProperties_ex(properties, properties_default, is_strict)) {
|
||||
char kmi_str[128];
|
||||
WM_keymap_item_to_string(kmi, kmi_str, sizeof(kmi_str), false);
|
||||
WM_keymap_item_to_string(kmi, false, sizeof(kmi_str), kmi_str);
|
||||
/* Note gievn properties could come from other things than menu entry... */
|
||||
printf("%s: Some set values in menu entry match default op values, "
|
||||
"this might not be desired!\n", opname);
|
||||
|
@ -1228,7 +1229,7 @@ static wmKeyMapItem *wm_keymap_item_find(
|
|||
kmi = wm_keymap_item_find_props(C, opname, opcontext, properties_default, is_strict, is_hotkey, &km);
|
||||
if (kmi) {
|
||||
char kmi_str[128];
|
||||
WM_keymap_item_to_string(kmi, kmi_str, sizeof(kmi_str), false);
|
||||
WM_keymap_item_to_string(kmi, false, sizeof(kmi_str), kmi_str);
|
||||
printf("%s: Some set values in keymap entry match default op values, "
|
||||
"this might not be desired!\n", opname);
|
||||
printf("\tkm: '%s', kmi: '%s'\n", km->idname, kmi_str);
|
||||
|
@ -1254,13 +1255,13 @@ static wmKeyMapItem *wm_keymap_item_find(
|
|||
|
||||
char *WM_key_event_operator_string(
|
||||
const bContext *C, const char *opname, int opcontext,
|
||||
IDProperty *properties, const bool is_strict, char *str, int len)
|
||||
IDProperty *properties, const bool is_strict, int len, char *r_str)
|
||||
{
|
||||
wmKeyMapItem *kmi = wm_keymap_item_find(C, opname, opcontext, properties, false, is_strict, NULL);
|
||||
|
||||
if (kmi) {
|
||||
WM_keymap_item_to_string(kmi, str, len, false);
|
||||
return str;
|
||||
WM_keymap_item_to_string(kmi, false, len, r_str);
|
||||
return r_str;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
|
Loading…
Reference in New Issue