Find a style for a string.
293{
295 struct QuoteStyle *qc = NULL, *tmp = NULL, *ptr = NULL, *save = NULL;
296 const char *tail_qptr = NULL;
297 size_t offset, tail_lng;
298 int index = -1;
299
300
301 while (q_list)
302 {
304 {
305
306
308 {
310 return q_list;
311
312
313 if (tmp)
314 {
315
316
317
319
320
325
326
328
329 while (ptr->next)
335
337
338
339 q_list = save;
340 }
341 else
342 {
343
346 tmp->prefix_len = length;
347
348
350 {
351 tmp->next = q_list->
next;
353 }
355 {
358 }
359
360
363
364
367
368
369 if (q_list == *quote_list)
370 *quote_list = tmp;
371
373
374
375 qc = tmp;
376
377
378
379
381 }
382
383
384 *force_redraw = true;
385 continue;
386 }
387 else
388 {
389
390 q_list = q_list->
next;
391 continue;
392 }
393 }
394 else
395 {
396
397
398
400 {
401
402
403 ptr = q_list;
405
406 q_list = q_list->
down;
407 tail_lng = length - offset;
408 tail_qptr = qptr + offset;
409
410 while (q_list)
411 {
413 {
415 {
416
418 return q_list;
419
420
421 if (!tmp)
422 {
423
426 tmp->prefix_len = length;
427
428
430 {
431 tmp->next = q_list->
next;
433 }
435 {
438 }
439
440
442 tmp->
up = q_list->
up;
444 if (tmp->up->down == q_list)
446
447
450
452
453
454 qc = tmp;
455
456
458 }
459 else
460 {
461
462
463
465
466
471
472
474 while (ptr->next)
480
482
483
484 q_list = save;
485 }
486
487
488 *force_redraw = true;
489 continue;
490 }
491 else
492 {
493 q_list = q_list->
next;
494 continue;
495 }
496 }
497 else
498 {
499
502 {
503
504 ptr = q_list;
506
507 q_list = q_list->
down;
508 tail_lng = length - offset;
509 tail_qptr = qptr + offset;
510
511 continue;
512 }
513 else
514 {
515
516 q_list = q_list->
next;
517 continue;
518 }
519 }
520 }
521
522
523 if (!qc)
524 {
527 tmp->prefix_len = length;
528
529 if (ptr->down)
530 {
531 tmp->next = ptr->down;
532 ptr->down->prev = tmp;
533 }
534 ptr->down = tmp;
535 tmp->up = ptr;
536
537 tmp->quote_n = (*q_level)++;
539
540 return tmp;
541 }
542 else
543 {
544 if (index != -1)
546
547 return qc;
548 }
549 }
550 else
551 {
552
553 q_list = q_list->
next;
554 continue;
555 }
556 }
557 }
558
559 if (!qc)
560 {
561
567
568 if (*quote_list)
569 {
570 if ((*quote_list)->next)
571 {
574 }
575 (*quote_list)->
next = qc;
576 qc->
prev = *quote_list;
577 }
578 else
579 {
580 *quote_list = qc;
581 }
582 }
583
584 if (index != -1)
586
587 return qc;
588}
char * mutt_strn_dup(const char *begin, size_t len)
Duplicate a sub-string.
bool mutt_strn_equal(const char *a, const char *b, size_t num)
Check for equality of two strings (to a maximum), safely.
struct AttrColor * quoted_colors_get(int q)
Return the color of a quote, cycling through the used quotes.
static void qstyle_insert(struct QuoteStyle *quote_list, struct QuoteStyle *new_class, int index, int *q_level)
Insert a new quote colour class into a list.
static struct QuoteStyle * qstyle_new(void)
Create a new QuoteStyle.
struct AttrColor * attr_color
Colour and attribute of the text.
struct QuoteStyle * next
Different quoting styles at the same level.
size_t prefix_len
Length of the prefix string.
char * prefix
Prefix string, e.g. "> ".
struct QuoteStyle * down
Parent (less quoted) and child (more quoted) levels.
int quote_n
The quoteN colour index for this level.