Differences From Artifact [c4ec2131b8]:
- File
src/console.mm
— part of check-in
[489124a92f]
at
2025-03-16 10:11:39
on branch trunk
— Use one autorelease pool per frame
This way, nowhere else autorelease pools need to be managed. (user: js, size: 6146) [annotate] [blame] [check-ins using]
To Artifact [555c5a6eb3]:
- File src/console.mm — part of check-in [89fbd7a152] at 2025-03-20 13:21:56 on branch trunk — Make more use of convenience methods (user: js, size: 5767) [annotate] [blame] [check-ins using]
1 2 3 4 5 6 7 8 9 | // console.cpp: the console buffer, its display, and command line control #include "cube.h" #include <ctype.h> #import "KeyMapping.h" #import "OFString+Cube.h" | > < < < < < < < < < < < < < < < < < < < < < < < < | 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; |
︙ | ︙ | |||
55 56 57 58 59 60 61 | OFMutableString *text; // constrain the buffer size if (conlines.count > 100) { text = [conlines.lastObject.text mutableCopy]; [conlines removeLastObject]; } else | | | | | 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | OFMutableString *text; // constrain the buffer size if (conlines.count > 100) { text = [conlines.lastObject.text mutableCopy]; [conlines removeLastObject]; } else text = [OFMutableString string]; if (highlight) // show line in a different colour, for chat etc. [text appendString:@"\f"]; [text appendString:sf]; if (conlines == nil) conlines = [[OFMutableArray alloc] init]; [conlines insertObject:[ConsoleLine lineWithText:text outtime:lastmillis] atIndex:0]; puts(text.UTF8String); #ifndef OF_WINDOWS fflush(stdout); #endif } |
︙ | ︙ | |||
131 132 133 134 135 136 137 | void keymap(OFString *code, OFString *key, OFString *action) { if (keyMappings == nil) keyMappings = [[OFMutableArray alloc] init]; | | | | 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | void keymap(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(keymap, ARG_3STR) void bindkey(OFString *key, OFString *action) |
︙ | ︙ |