Differences From Artifact [1ac50365c9]:
- File
src/console.m
— part of check-in
[6b85eefc85]
at
2025-03-23 02:47:40
on branch trunk
— Remove loop[ijkl]
They confused clang-format a lot. (user: js, size: 5786) [annotate] [blame] [check-ins using]
To Artifact [d7f7b48227]:
- File src/console.m — part of check-in [d7661be1b1] at 2025-03-23 19:40:00 on branch trunk — Clean up identifiers, use blocks for commands (user: js, size: 5782) [annotate] [blame] [check-ins using]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | // console.cpp: the console buffer, its display, and command line control #include "cube.h" #include <ctype.h> #import "ConsoleLine.h" #import "KeyMapping.h" #import "OFString+Cube.h" static OFMutableArray<ConsoleLine *> *conlines; const int ndraw = 5; const int WORDWRAP = 80; int conskip = 0; bool saycommandon = false; static OFMutableString *commandbuf; | > < | < | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | // console.cpp: the console buffer, its display, and command line control #include "cube.h" #include <ctype.h> #import "Command.h" #import "ConsoleLine.h" #import "KeyMapping.h" #import "OFString+Cube.h" static OFMutableArray<ConsoleLine *> *conlines; const int ndraw = 5; const int WORDWRAP = 80; int conskip = 0; bool saycommandon = false; static OFMutableString *commandbuf; COMMAND(conskip, ARG_1INT, ^(int n) { conskip += n; if (conskip < 0) conskip = 0; }) static void conline(OFString *sf, bool highlight) // add a line to the console buffer { OFMutableString *text; // constrain the buffer size |
︙ | ︙ | |||
100 101 102 103 104 105 106 | (FONTH / 4 * 5) * (nd - j - 1) + FONTH / 3, 2); } // keymap is defined externally in keymap.cfg static OFMutableArray<KeyMapping *> *keyMappings = nil; | < | < | < < | < | < > | | < < | > > | > | < < | < | < | 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | (FONTH / 4 * 5) * (nd - j - 1) + FONTH / 3, 2); } // keymap is defined externally in keymap.cfg static OFMutableArray<KeyMapping *> *keyMappings = nil; COMMAND(keymap, ARG_3STR, ^(OFString *code, OFString *key, OFString *action) { if (keyMappings == nil) keyMappings = [[OFMutableArray alloc] init]; KeyMapping *mapping = [KeyMapping mappingWithCode:code.cube_intValue name:key]; mapping.action = action; [keyMappings addObject:mapping]; }) COMMAND(bind, ARG_2STR, ^(OFString *key, OFString *action) { for (KeyMapping *mapping in keyMappings) { if ([mapping.name caseInsensitiveCompare:key] == OFOrderedSame) { mapping.action = action; return; } } conoutf(@"unknown key \"%@\"", key); }) // turns input to the command line on or off static void saycommand(OFString *init) { saycommandon = (init != nil); if (saycommandon) SDL_StartTextInput(); else SDL_StopTextInput(); if (!editmode) Cube.sharedInstance.repeatsKeys = saycommandon; if (init == nil) init = @""; commandbuf = [init mutableCopy]; } COMMAND(saycommand, ARG_VARI, ^(OFString *init) { saycommand(init); }) COMMAND(mapmsg, ARG_1STR, ^(OFString *s) { memset(hdr.maptitle, '\0', sizeof(hdr.maptitle)); strncpy(hdr.maptitle, s.UTF8String, 127); }) void pasteconsole() { [commandbuf appendString:@(SDL_GetClipboardText())]; } static OFMutableArray<OFString *> *vhistory; static int histpos = 0; COMMAND(history, ARG_1INT, ^(int n) { static bool rec = false; if (!rec && n >= 0 && n < vhistory.count) { rec = true; execute(vhistory[vhistory.count - n - 1], true); rec = false; } }) void keypress(int code, bool isDown) { // keystrokes go to commandline if (saycommandon) { if (isDown) { |
︙ | ︙ |