Cube  Diff

Differences From Artifact [1d463d8f9f]:

To Artifact [a781a15ab9]:


58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
void
conoutf(OFConstantString *format, ...)
{
	va_list arguments;
	va_start(arguments, format);

	OFString *string = [[OFString alloc] initWithFormat: format
	                                          arguments: arguments];

	va_end(arguments);

	int n = 0;
	while (string.length > WORDWRAP) {
		conline([string substringToIndex: WORDWRAP], n++ != 0);
		string = [string substringFromIndex: WORDWRAP];
	}
	conline(string, n != 0);
}

// render buffer taking into account time & scrolling
void
renderconsole()
{
	int nd = 0;
	OFString *refs[ndraw];

	size_t i = 0;
	for (ConsoleLine *conline in conlines) {
		if (conskip ? i >= conskip - 1 || i >= conlines.count - ndraw
		            : lastmillis - conline.outtime < 20000) {
			refs[nd++] = conline.text;
			if (nd == ndraw)
				break;
		}

		i++;
	}







|




















|
|







58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
void
conoutf(OFConstantString *format, ...)
{
	va_list arguments;
	va_start(arguments, format);

	OFString *string = [[OFString alloc] initWithFormat: format
						  arguments: arguments];

	va_end(arguments);

	int n = 0;
	while (string.length > WORDWRAP) {
		conline([string substringToIndex: WORDWRAP], n++ != 0);
		string = [string substringFromIndex: WORDWRAP];
	}
	conline(string, n != 0);
}

// render buffer taking into account time & scrolling
void
renderconsole()
{
	int nd = 0;
	OFString *refs[ndraw];

	size_t i = 0;
	for (ConsoleLine *conline in conlines) {
		if (conskip ? i >= conskip - 1 || i >= conlines.count - ndraw :
		    lastmillis - conline.outtime < 20000) {
			refs[nd++] = conline.text;
			if (nd == ndraw)
				break;
		}

		i++;
	}
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
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] ==







|







103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
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] ==
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
			case SDLK_RETURN:
				break;

			case SDLK_BACKSPACE:
			case SDLK_LEFT:
				if (commandbuf.length > 0)
					[commandbuf deleteCharactersInRange:
					        OFMakeRange(
					            commandbuf.length - 1, 1)];

				resetcomplete();
				break;

			case SDLK_UP:
				if (histpos)
					commandbuf =







|
|







181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
			case SDLK_RETURN:
				break;

			case SDLK_BACKSPACE:
			case SDLK_LEFT:
				if (commandbuf.length > 0)
					[commandbuf deleteCharactersInRange:
					    OFMakeRange(
					    commandbuf.length - 1, 1)];

				resetcomplete();
				break;

			case SDLK_UP:
				if (histpos)
					commandbuf =
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
			default:
				resetcomplete();
			}
		} else {
			if (code == SDLK_RETURN) {
				if (commandbuf.length > 0) {
					if (vhistory == nil)
						vhistory =
						    [[OFMutableArray alloc]
						        init];

					if (vhistory.count == 0 ||
					    ![vhistory.lastObject isEqual:
					    commandbuf]) {
						// cap this?
						[vhistory addObject:
						    [commandbuf copy]];







|
<
|







217
218
219
220
221
222
223
224

225
226
227
228
229
230
231
232
			default:
				resetcomplete();
			}
		} else {
			if (code == SDLK_RETURN) {
				if (commandbuf.length > 0) {
					if (vhistory == nil)
						vhistory = [[OFMutableArray

						    alloc] init];

					if (vhistory.count == 0 ||
					    ![vhistory.lastObject isEqual:
					    commandbuf]) {
						// cap this?
						[vhistory addObject:
						    [commandbuf copy]];