Changeset View
Changeset View
Standalone View
Standalone View
src/syntax/katehighlight.cpp
Show First 20 Lines • Show All 540 Lines • ▼ Show 20 Line(s) | 537 | for (const auto &format : m_formats) { | |||
---|---|---|---|---|---|
541 | setTheme(currentTheme); | 541 | setTheme(currentTheme); | ||
542 | 542 | | |||
543 | /** | 543 | /** | ||
544 | * create a KTextEditor attribute matching the given format | 544 | * create a KTextEditor attribute matching the given format | ||
545 | */ | 545 | */ | ||
546 | KTextEditor::Attribute::Ptr newAttribute(new KTextEditor::Attribute(nameForAttrib(array.size()), textStyleToDefaultStyle(format.textStyle()))); | 546 | KTextEditor::Attribute::Ptr newAttribute(new KTextEditor::Attribute(nameForAttrib(array.size()), textStyleToDefaultStyle(format.textStyle()))); | ||
547 | 547 | | |||
548 | /** | 548 | /** | ||
549 | * NOTE: if "theme()" returns an empty theme, only the | 549 | * NOTE: if "theme()" returns an empty/invalid theme, only the | ||
550 | * attribute styles set in the XML files will be applied here. | 550 | * attribute styles set in the XML files will be applied here. | ||
551 | * FIXME: if the theme is invalid/empty, the attributes turned off in the | | |||
552 | * XML file don't work. This is so, because there the theme isn't applied by | | |||
553 | * KSyntaxHighlighting and the methods "Format::isBold(...)", "Format::isItalic(...)", | | |||
554 | * etc., return the combination between the syntax definition and the theme. | | |||
555 | */ | 551 | */ | ||
556 | if (format.hasTextColor(theme())) { | 552 | if (format.hasTextColor(theme())) { | ||
557 | newAttribute->setForeground(format.textColor(theme())); | 553 | newAttribute->setForeground(format.textColor(theme())); | ||
558 | newAttribute->setSelectedForeground(format.selectedTextColor(theme())); | 554 | newAttribute->setSelectedForeground(format.selectedTextColor(theme())); | ||
559 | } | 555 | } | ||
560 | 556 | | |||
561 | if (format.hasBackgroundColor(theme())) { | 557 | if (format.hasBackgroundColor(theme())) { | ||
562 | newAttribute->setBackground(format.backgroundColor(theme())); | 558 | newAttribute->setBackground(format.backgroundColor(theme())); | ||
563 | newAttribute->setSelectedBackground(format.selectedBackgroundColor(theme())); | 559 | newAttribute->setSelectedBackground(format.selectedBackgroundColor(theme())); | ||
564 | } | 560 | } | ||
565 | 561 | | |||
566 | if (theme().isValid()) { | 562 | /** | ||
563 | * Two cases: | ||||
564 | * - Valid theme: "isBold(...)", "isItalic(...)", etc. returns the combination | ||||
565 | * between the attributes set in the syntax definition files and the theme. | ||||
566 | * - Invalid/empty theme: the theme doesn't exist in KSyntaxHighlighting and is | ||||
567 | * already applied. Then it's checked if the bold, italic, underline & strikeout | ||||
568 | * attributes are specifically set in the syntax definition XML file to be applied. | ||||
569 | * | ||||
570 | * In both cases, it's allowed to turn off the bold, italic, underline and strikeout | ||||
571 | * attributes in the XML files (see bug #143399). | ||||
572 | */ | ||||
573 | if (theme().isValid() || format.definitionHasBold()) { | ||||
567 | if (format.isBold(theme())) { | 574 | if (format.isBold(theme())) { | ||
568 | newAttribute->setFontBold(true); | 575 | newAttribute->setFontBold(true); | ||
569 | } else { | 576 | } else { | ||
570 | newAttribute->setFontBold(false); | 577 | newAttribute->setFontBold(false); | ||
571 | } | 578 | } | ||
579 | } | ||||
572 | 580 | | |||
581 | if (theme().isValid() || format.definitionHasItalic()) { | ||||
573 | if (format.isItalic(theme())) { | 582 | if (format.isItalic(theme())) { | ||
574 | newAttribute->setFontItalic(true); | 583 | newAttribute->setFontItalic(true); | ||
575 | } else { | 584 | } else { | ||
576 | newAttribute->setFontItalic(false); | 585 | newAttribute->setFontItalic(false); | ||
577 | } | 586 | } | ||
587 | } | ||||
578 | 588 | | |||
589 | if (theme().isValid() || format.definitionHasUnderline()) { | ||||
579 | if (format.isUnderline(theme())) { | 590 | if (format.isUnderline(theme())) { | ||
580 | newAttribute->setFontUnderline(true); | 591 | newAttribute->setFontUnderline(true); | ||
581 | } else { | 592 | } else { | ||
582 | newAttribute->setFontUnderline(false); | 593 | newAttribute->setFontUnderline(false); | ||
583 | } | 594 | } | ||
595 | } | ||||
584 | 596 | | |||
597 | if (theme().isValid() || format.definitionHasStrikeThrough()) { | ||||
585 | if (format.isStrikeThrough(theme())) { | 598 | if (format.isStrikeThrough(theme())) { | ||
586 | newAttribute->setFontStrikeOut(true); | 599 | newAttribute->setFontStrikeOut(true); | ||
587 | } else { | 600 | } else { | ||
588 | newAttribute->setFontStrikeOut(false); | 601 | newAttribute->setFontStrikeOut(false); | ||
589 | } | 602 | } | ||
590 | } else { | | |||
591 | if (format.isBold(theme())) { | | |||
592 | newAttribute->setFontBold(true); | | |||
593 | } | | |||
594 | | ||||
595 | if (format.isItalic(theme())) { | | |||
596 | newAttribute->setFontItalic(true); | | |||
597 | } | | |||
598 | | ||||
599 | if (format.isUnderline(theme())) { | | |||
600 | newAttribute->setFontUnderline(true); | | |||
601 | } | | |||
602 | | ||||
603 | if (format.isStrikeThrough(theme())) { | | |||
604 | newAttribute->setFontStrikeOut(true); | | |||
605 | } | | |||
606 | } | 603 | } | ||
607 | 604 | | |||
608 | newAttribute->setSkipSpellChecking(format.spellCheck()); | 605 | newAttribute->setSkipSpellChecking(format.spellCheck()); | ||
609 | 606 | | |||
610 | array.append(newAttribute); | 607 | array.append(newAttribute); | ||
611 | } | 608 | } | ||
612 | return array; | 609 | return array; | ||
613 | } | 610 | } | ||
▲ Show 20 Lines • Show All 112 Lines • Show Last 20 Lines |