57 offset += cl->len + 1;
60 char *buf_str =
nullptr;
66 if (sel[0] <= cl->len && sel[1] >= 0) {
67 int sta =
max_ii(sel[0], 0);
68 int end =
min_ii(sel[1], cl->len);
77 sel[0] -= cl->len + 1;
78 sel[1] -= cl->len + 1;
126 if (del_end > cl->
len) {
131 const int len = del_end - del_start;
132 memmove(cl->
line + cl->
len - del_end, cl->
line + cl->
len - del_start, del_start);
146 View2D *v2d = ®ion->v2d;
153 View2D *v2d = ®ion->v2d;
194 else if (cursor > cl->
len) {
195 cursor_new = cl->
len;
201 if (cursor_new == cl->
cursor) {
210static void console_lb_debug__internal(
ListBase *lb)
215 for (cl = lb->
first; cl; cl = cl->
next) {
221static void console_history_debug(
const bContext *C)
225 console_lb_debug__internal(&sc->
history);
238 ci->
cursor = from->cursor;
239 ci->
type = from->type;
269 const int str_len = strlen(
str);
310 int new_len =
len + 1;
312 int new_len = (
len + 1) * 2;
350 offset += cl->
len + 1;
359 *r_cl_offset = offset;
360 *r_col = offset -
pos;
374 {
LINE_BEGIN,
"LINE_BEGIN", 0,
"Line Begin",
""},
375 {
LINE_END,
"LINE_END", 0,
"Line End",
""},
376 {
PREV_CHAR,
"PREVIOUS_CHARACTER", 0,
"Previous Character",
""},
377 {
NEXT_CHAR,
"NEXT_CHARACTER", 0,
"Next Character",
""},
378 {
PREV_WORD,
"PREVIOUS_WORD", 0,
"Previous Word",
""},
379 {
NEXT_WORD,
"NEXT_WORD", 0,
"Next Word",
""},
380 {0,
nullptr, 0,
nullptr,
nullptr},
474 ot->
srna,
"select",
false,
"Select",
"Whether to select while moving");
488 while (
len > 0 &&
str[
len - 1] ==
'\n') {
493 if (strchr(
str,
'\n')) {
558 ot->
srna,
"text",
nullptr, 0,
"Text",
"Text to insert at the cursor position");
569 bool text_before_cursor =
false;
575 if (!
ELEM(ci->
line[i],
' ',
'\t')) {
576 text_before_cursor =
true;
581 if (text_before_cursor) {
593 ot->
name =
"Indent or Autocomplete";
594 ot->
idname =
"CONSOLE_OT_indent_or_autocomplete";
621 for (spaces = 0; spaces < ci->
len; spaces++) {
622 if (ci->
line[spaces] !=
' ') {
670 for (spaces = 0; spaces < ci->
len; spaces++) {
671 if (ci->
line[spaces] !=
' ') {
716 {
DEL_PREV_CHAR,
"PREVIOUS_CHARACTER", 0,
"Previous Character",
""},
719 {0,
nullptr, 0,
nullptr,
nullptr},
824 "Which part of the text to delete");
856 ot->
idname =
"CONSOLE_OT_clear_line";
920 int prev_len = ci->
len;
925 if (old_index <= 0) {
929 new_index = old_index + 1;
933 if (old_index <= 0) {
934 new_index = -old_index;
937 new_index = old_index - 1;
946 ci_prev = ci_prev->
prev;
952 for (
int i = 0; i < new_index; i++) {
953 if (!ci_prev->
prev) {
957 ci_prev = ci_prev->
prev;
984 ot->
name =
"History Cycle";
986 ot->
idname =
"CONSOLE_OT_history_cycle";
1008 int prev_len = ci->
len;
1046 ot->
name =
"History Append";
1048 ot->
idname =
"CONSOLE_OT_history_append";
1057 ot->
srna,
"current_character", 0, 0, INT_MAX,
"Cursor",
"The index of the cursor", 0, 10000);
1059 "remove_duplicates",
1061 "Remove Duplicates",
1062 "Remove duplicate items in the history");
1098 {0,
nullptr, 0,
nullptr,
nullptr},
1102 ot->
name =
"Scrollback Append";
1104 ot->
idname =
"CONSOLE_OT_scrollback_append";
1114 console_line_type_items,
1117 "Console output type");
1124 if (buf ==
nullptr) {
1148 ot->
name =
"Copy to Clipboard";
1161 "Whether to delete the selection after copying");
1176 if (buf_str ==
nullptr) {
1179 if (*buf_str ==
'\0') {
1183 const char *buf_step = buf_str;
1185 const char *buf = buf_step;
1187 const int buf_len = buf_step - buf;
1188 if (buf != buf_str) {
1195 }
while (*buf_step ? ((
void)buf_step++,
true) :
false);
1210 ot->
name =
"Paste from Clipboard";
1224 "Paste text selected elsewhere rather than copied (X11/Wayland only)");
1239 bool dragging =
event->type ==
MOUSEMOVE;
1262 if (cl !=
nullptr) {
1312 if (cl !=
nullptr) {
1338 switch (event->
type) {
1369 ot->
name =
"Set Selection";
1370 ot->
idname =
"CONSOLE_OT_select_set";
1387 int offset = strlen(sc->
prompt);
1390 offset += cl->
len + 1;
1395 offset += cl->
len + 1;
1410 ot->
idname =
"CONSOLE_OT_select_all";
1434 int sel[2] = {n, n};
1438 sel[0] = offset - sel[0];
1439 sel[1] = offset - sel[1];
1466 ot->
name =
"Select Word";
1468 ot->
idname =
"CONSOLE_OT_select_word";
SpaceConsole * CTX_wm_space_console(const bContext *C)
ScrArea * CTX_wm_area(const bContext *C)
void BKE_report(ReportList *reports, eReportType type, const char *message)
ARegion * BKE_area_find_region_type(const ScrArea *area, int region_type)
A dynamically sized string ADT.
char * BLI_dynstr_get_cstring(const DynStr *ds) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
void BLI_dynstr_nappend(DynStr *__restrict ds, const char *cstr, int len) ATTR_NONNULL()
int BLI_dynstr_get_len(const DynStr *ds) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
DynStr * BLI_dynstr_new(void) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
void BLI_dynstr_free(DynStr *ds) ATTR_NONNULL()
void BLI_dynstr_append(DynStr *__restrict ds, const char *cstr) ATTR_NONNULL()
#define LISTBASE_FOREACH(type, var, list)
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void BLI_remlink(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
int BLI_listbase_count(const struct ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
MINLINE int min_ii(int a, int b)
MINLINE int max_ii(int a, int b)
char * BLI_strdupn(const char *str, size_t len) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
char char size_t char const char * BLI_strchr_or_end(const char *str, char ch) ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL ATTR_NONNULL(1)
void BLI_str_cursor_step_utf8(const char *str, int str_maxlen, int *pos, eStrCursorJumpDirection direction, eStrCursorJumpType jump, bool use_init_step)
void BLI_str_cursor_step_bounds_utf8(const char *str, int str_maxlen, int pos, int *r_start, int *r_end)
int BLI_str_utf8_size_safe(const char *p) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void ED_area_tag_redraw(ScrArea *area)
bool ED_operator_console_active(bContext *C)
Read Guarded memory(de)allocation.
void UI_view2d_totRect_set(View2D *v2d, int width, int height)
@ WM_CAPABILITY_PRIMARY_CLIPBOARD
void console_scrollback_prompt_end(SpaceConsole *sc, ConsoleLine *cl_dummy)
int console_textview_height(SpaceConsole *sc, const ARegion *region)
void console_scrollback_prompt_begin(SpaceConsole *sc, ConsoleLine *cl_dummy)
int console_char_pick(SpaceConsole *sc, const ARegion *region, const int mval[2])
static int console_indent_exec(bContext *C, wmOperator *)
static bool console_line_cursor_set(ConsoleLine *cl, int cursor)
void CONSOLE_OT_select_all(wmOperatorType *ot)
static int console_unindent_exec(bContext *C, wmOperator *)
static ConsoleLine * console_history_add(SpaceConsole *sc, ConsoleLine *from)
static void console_modal_select_apply(bContext *C, wmOperator *op, const wmEvent *event)
static void console_select_update_primary_clipboard(SpaceConsole *sc)
static void console_modal_select_cancel(bContext *C, wmOperator *op)
static void console_line_verify_length(ConsoleLine *ci, int len)
static int console_selectword_invoke(bContext *C, wmOperator *, const wmEvent *event)
void CONSOLE_OT_copy(wmOperatorType *ot)
void CONSOLE_OT_clear(wmOperatorType *ot)
static const EnumPropertyItem console_move_type_items[]
static const EnumPropertyItem console_delete_type_items[]
static bool console_line_column_from_index(SpaceConsole *sc, const int pos, ConsoleLine **r_cl, int *r_cl_offset, int *r_col)
void console_textview_update_rect(SpaceConsole *sc, ARegion *region)
static void console_cursor_set_exit(bContext *C, wmOperator *op)
void CONSOLE_OT_select_word(wmOperatorType *ot)
void CONSOLE_OT_delete(wmOperatorType *ot)
static char * console_select_to_buffer(SpaceConsole *sc)
void CONSOLE_OT_indent(wmOperatorType *ot)
void CONSOLE_OT_select_set(wmOperatorType *ot)
static int console_history_append_exec(bContext *C, wmOperator *op)
static int console_clear_line_exec(bContext *C, wmOperator *)
static void console_scrollback_limit(SpaceConsole *sc)
static int console_history_cycle_exec(bContext *C, wmOperator *op)
static int console_insert_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static int console_scrollback_append_exec(bContext *C, wmOperator *op)
static int console_copy_exec(bContext *C, wmOperator *op)
static int console_move_exec(bContext *C, wmOperator *op)
void CONSOLE_OT_indent_or_autocomplete(wmOperatorType *ot)
void CONSOLE_OT_move(wmOperatorType *ot)
static int console_modal_select(bContext *C, wmOperator *op, const wmEvent *event)
static void console_scroll_bottom(ARegion *region)
void console_history_free(SpaceConsole *sc, ConsoleLine *cl)
void console_scrollback_free(SpaceConsole *sc, ConsoleLine *cl)
void CONSOLE_OT_clear_line(wmOperatorType *ot)
static int console_insert_exec(bContext *C, wmOperator *op)
void CONSOLE_OT_scrollback_append(wmOperatorType *ot)
void CONSOLE_OT_insert(wmOperatorType *ot)
static ConsoleLine * console_lb_add__internal(ListBase *lb, ConsoleLine *from)
ConsoleLine * console_history_add_str(SpaceConsole *sc, char *str, bool own)
static void console_line_insert(ConsoleLine *ci, const char *str, int len)
static ConsoleLine * console_lb_add_str__internal(ListBase *lb, char *str, bool own)
static bool console_copy_poll(bContext *C)
void CONSOLE_OT_history_cycle(wmOperatorType *ot)
void CONSOLE_OT_unindent(wmOperatorType *ot)
static int console_delete_exec(bContext *C, wmOperator *op)
static int console_indent_or_autocomplete_exec(bContext *C, wmOperator *)
void CONSOLE_OT_history_append(wmOperatorType *ot)
static int console_delete_editable_selection(SpaceConsole *sc)
static int console_clear_exec(bContext *C, wmOperator *op)
void CONSOLE_OT_paste(wmOperatorType *ot)
static int console_modal_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static int console_modal_select_all_invoke(bContext *C, wmOperator *, const wmEvent *)
ConsoleLine * console_history_verify(const bContext *C)
static void console_cursor_set_to_pos(SpaceConsole *sc, ARegion *region, SetConsoleCursor *scu, const wmEvent *event)
static void console_select_offset(SpaceConsole *sc, const int offset)
static int console_paste_exec(bContext *C, wmOperator *op)
ConsoleLine * console_scrollback_add_str(SpaceConsole *sc, char *str, bool own)
draw_view in_light_buf[] float
void *(* MEM_recallocN_id)(void *vmemh, size_t len, const char *str)
void MEM_freeN(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
ccl_device_inline float4 select(const int4 mask, const float4 a, const float4 b)
void RNA_string_set(PointerRNA *ptr, const char *name, const char *value)
int RNA_int_get(PointerRNA *ptr, const char *name)
char * RNA_string_get_alloc(PointerRNA *ptr, const char *name, char *fixedbuf, int fixedlen, int *r_len)
int RNA_string_length(PointerRNA *ptr, const char *name)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
int RNA_enum_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, const int default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
struct ConsoleLine * next
struct ConsoleLine * prev
bool(* poll)(bContext *C) ATTR_WARN_UNUSED_RESULT
int(* modal)(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
int(* invoke)(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
int(* exec)(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
void(* cancel)(bContext *C, wmOperator *op)
struct ReportList * reports
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
int WM_operator_name_call(bContext *C, const char *opstring, wmOperatorCallContext context, PointerRNA *properties, const wmEvent *event)
void WM_clipboard_text_set(const char *buf, bool selection)
char * WM_clipboard_text_get(bool selection, bool ensure_utf8, int *r_len)
eWM_CapabilitiesFlag WM_capabilities_flag()