diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-10-19 01:07:40 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-10-19 01:18:22 +0300 |
commit | a30c9f710a64d0adca1597c0d0404713a26a401e (patch) | |
tree | 40fc7724b8a362dc08745ad766e6ee7e025479db /source/blender/blenkernel/intern/text.c | |
parent | 642b77e874e787b04e28dc68af3ac4bd7aed5b2e (diff) |
Partial revert '#if 0' cleanup
Partially revert 41216d5ad4c722e2ad9f15c968af454fc7566d5e
Some of this code had comments to be left as is for readability,
or comment the code should be kept.
Other functions were only for debugging.
Diffstat (limited to 'source/blender/blenkernel/intern/text.c')
-rw-r--r-- | source/blender/blenkernel/intern/text.c | 172 |
1 files changed, 172 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index 5dc8d6133eb..d512c4ac78e 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -1472,6 +1472,178 @@ static void txt_undo_end(Text *UNUSED(text), TextUndoBuf *utxt) utxt->buf[undo_pos_end] = '\0'; } +/* Call once undo is done. */ +#ifndef NDEBUG + +#endif + +#if 0 /* UNUSED */ +static void dump_buffer(TextUndoBuf *utxt) +{ + int i = 0; + + while (i++ < utxt->undo_pos) printf("%d: %d %c\n", i, utxt->buf[i], utxt->buf[i]); +} + +/* Note: this function is outdated and must be updated if needed for future use */ +void txt_print_undo(Text *text) +{ + int i = 0; + int op; + const char *ops; + int linep, charp; + + dump_buffer(text); + + printf("---< Undo Buffer >---\n"); + + printf("UndoPosition is %d\n", utxt->pos); + + while (i <= utxt->pos) { + op = utxt->buf[i]; + + if (op == UNDO_INSERT_1) { + ops = "Insert ascii "; + } + else if (op == UNDO_INSERT_2) { + ops = "Insert 2 bytes "; + } + else if (op == UNDO_INSERT_3) { + ops = "Insert 3 bytes "; + } + else if (op == UNDO_INSERT_4) { + ops = "Insert unicode "; + } + else if (op == UNDO_BS_1) { + ops = "Backspace for ascii "; + } + else if (op == UNDO_BS_2) { + ops = "Backspace for 2 bytes "; + } + else if (op == UNDO_BS_3) { + ops = "Backspace for 3 bytes "; + } + else if (op == UNDO_BS_4) { + ops = "Backspace for unicode "; + } + else if (op == UNDO_DEL_1) { + ops = "Delete ascii "; + } + else if (op == UNDO_DEL_2) { + ops = "Delete 2 bytes "; + } + else if (op == UNDO_DEL_3) { + ops = "Delete 3 bytes "; + } + else if (op == UNDO_DEL_4) { + ops = "Delete unicode "; + } + else if (op == UNDO_DBLOCK) { + ops = "Delete text block"; + } + else if (op == UNDO_IBLOCK) { + ops = "Insert text block"; + } + else if (op == UNDO_INDENT) { + ops = "Indent "; + } + else if (op == UNDO_UNINDENT) { + ops = "Unindent "; + } + else if (op == UNDO_COMMENT) { + ops = "Comment "; + } + else if (op == UNDO_UNCOMMENT) { + ops = "Uncomment "; + } + else { + ops = "Unknown"; + } + + printf("Op (%o) at %d = %s", op, i, ops); + if (op >= UNDO_INSERT_1 && op <= UNDO_DEL_4) { + i++; + printf(" - Char is "); + switch (op) { + case UNDO_INSERT_1: case UNDO_BS_1: case UNDO_DEL_1: + printf("%c", utxt->buf[i]); + i++; + break; + case UNDO_INSERT_2: case UNDO_BS_2: case UNDO_DEL_2: + printf("%c%c", utxt->buf[i], utxt->buf[i + 1]); + i += 2; + break; + case UNDO_INSERT_3: case UNDO_BS_3: case UNDO_DEL_3: + printf("%c%c%c", utxt->buf[i], utxt->buf[i + 1], utxt->buf[i + 2]); + i += 3; + break; + case UNDO_INSERT_4: case UNDO_BS_4: case UNDO_DEL_4: + { + unsigned int uc; + char c[BLI_UTF8_MAX + 1]; + size_t c_len; + uc = utxt->buf[i]; i++; + uc = uc + (utxt->buf[i] << 8); i++; + uc = uc + (utxt->buf[i] << 16); i++; + uc = uc + (utxt->buf[i] << 24); i++; + c_len = BLI_str_utf8_from_unicode(uc, c); + c[c_len] = '\0'; + puts(c); + break; + } + } + } + else if (op == UNDO_DBLOCK || op == UNDO_IBLOCK) { + i++; + + linep = utxt->buf[i]; i++; + linep = linep + (utxt->buf[i] << 8); i++; + linep = linep + (utxt->buf[i] << 16); i++; + linep = linep + (utxt->buf[i] << 24); i++; + + printf(" (length %d) <", linep); + + while (linep > 0) { + putchar(utxt->buf[i]); + linep--; i++; + } + + linep = utxt->buf[i]; i++; + linep = linep + (utxt->buf[i] << 8); i++; + linep = linep + (utxt->buf[i] << 16); i++; + linep = linep + (utxt->buf[i] << 24); i++; + printf("> (%d)", linep); + } + else if (op == UNDO_INDENT || op == UNDO_UNINDENT) { + i++; + + charp = utxt->buf[i]; i++; + charp = charp + (utxt->buf[i] << 8); i++; + + linep = utxt->buf[i]; i++; + linep = linep + (utxt->buf[i] << 8); i++; + linep = linep + (utxt->buf[i] << 16); i++; + linep = linep + (utxt->buf[i] << 24); i++; + + printf("to <%d, %d> ", linep, charp); + + charp = utxt->buf[i]; i++; + charp = charp + (utxt->buf[i] << 8); i++; + + linep = utxt->buf[i]; i++; + linep = linep + (utxt->buf[i] << 8); i++; + linep = linep + (utxt->buf[i] << 16); i++; + linep = linep + (utxt->buf[i] << 24); i++; + + printf("from <%d, %d>", linep, charp); + } + + printf(" %d\n", i); + i++; + } +} +#endif + static void txt_undo_store_uint16(char *undo_buf, int *undo_pos, unsigned short value) { undo_buf[*undo_pos] = (value) & 0xff; |