on main help sign in
lint: modernize new pointer creation (e.g. new(true))
6e56a7fChristian Rocha
internal/ui/styles/styles.go+68−72
@@ -632,14 +632,14 @@ func DefaultStyles() Styles {
632 StylePrimitive: ansi.StylePrimitive{
632 StylePrimitive: ansi.StylePrimitive{
633 // BlockPrefix: "\n",
633 // BlockPrefix: "\n",
634 // BlockSuffix: "\n",
634 // BlockSuffix: "\n",
635− Color: stringPtr(charmtone.Smoke.Hex()),
635+ Color: new(charmtone.Smoke.Hex()),
636 },
636 },
637− // Margin: uintPtr(defaultMargin),
637+ // Margin: new(uint(defaultMargin)),
638 },
638 },
639 BlockQuote: ansi.StyleBlock{
639 BlockQuote: ansi.StyleBlock{
640 StylePrimitive: ansi.StylePrimitive{},
640 StylePrimitive: ansi.StylePrimitive{},
641− Indent: uintPtr(1),
641+ Indent: new(uint(1)),
642− IndentToken: stringPtr("│ "),
642+ IndentToken: new("│ "),
643 },
643 },
644 List: ansi.StyleList{
644 List: ansi.StyleList{
645 LevelIndent: defaultListIndent,
645 LevelIndent: defaultListIndent,
@@ -647,17 +647,17 @@ func DefaultStyles() Styles {
647 Heading: ansi.StyleBlock{
647 Heading: ansi.StyleBlock{
648 StylePrimitive: ansi.StylePrimitive{
648 StylePrimitive: ansi.StylePrimitive{
649 BlockSuffix: "\n",
649 BlockSuffix: "\n",
650− Color: stringPtr(charmtone.Malibu.Hex()),
650+ Color: new(charmtone.Malibu.Hex()),
651− Bold: boolPtr(true),
651+ Bold: new(true),
652 },
652 },
653 },
653 },
654 H1: ansi.StyleBlock{
654 H1: ansi.StyleBlock{
655 StylePrimitive: ansi.StylePrimitive{
655 StylePrimitive: ansi.StylePrimitive{
656 Prefix: " ",
656 Prefix: " ",
657 Suffix: " ",
657 Suffix: " ",
658− Color: stringPtr(charmtone.Zest.Hex()),
658+ Color: new(charmtone.Zest.Hex()),
659− BackgroundColor: stringPtr(charmtone.Charple.Hex()),
659+ BackgroundColor: new(charmtone.Charple.Hex()),
660− Bold: boolPtr(true),
660+ Bold: new(true),
661 },
661 },
662 },
662 },
663 H2: ansi.StyleBlock{
663 H2: ansi.StyleBlock{
@@ -683,21 +683,21 @@ func DefaultStyles() Styles {
683 H6: ansi.StyleBlock{
683 H6: ansi.StyleBlock{
684 StylePrimitive: ansi.StylePrimitive{
684 StylePrimitive: ansi.StylePrimitive{
685 Prefix: "###### ",
685 Prefix: "###### ",
686− Color: stringPtr(charmtone.Guac.Hex()),
686+ Color: new(charmtone.Guac.Hex()),
687− Bold: boolPtr(false),
687+ Bold: new(false),
688 },
688 },
689 },
689 },
690 Strikethrough: ansi.StylePrimitive{
690 Strikethrough: ansi.StylePrimitive{
691− CrossedOut: boolPtr(true),
691+ CrossedOut: new(true),
692 },
692 },
693 Emph: ansi.StylePrimitive{
693 Emph: ansi.StylePrimitive{
694− Italic: boolPtr(true),
694+ Italic: new(true),
695 },
695 },
696 Strong: ansi.StylePrimitive{
696 Strong: ansi.StylePrimitive{
697− Bold: boolPtr(true),
697+ Bold: new(true),
698 },
698 },
699 HorizontalRule: ansi.StylePrimitive{
699 HorizontalRule: ansi.StylePrimitive{
700− Color: stringPtr(charmtone.Charcoal.Hex()),
700+ Color: new(charmtone.Charcoal.Hex()),
701 Format: "\n--------\n",
701 Format: "\n--------\n",
702 },
702 },
703 Item: ansi.StylePrimitive{
703 Item: ansi.StylePrimitive{
@@ -712,117 +712,117 @@ func DefaultStyles() Styles {
712 Unticked: "[ ] ",
712 Unticked: "[ ] ",
713 },
713 },
714 Link: ansi.StylePrimitive{
714 Link: ansi.StylePrimitive{
715− Color: stringPtr(charmtone.Zinc.Hex()),
715+ Color: new(charmtone.Zinc.Hex()),
716− Underline: boolPtr(true),
716+ Underline: new(true),
717 },
717 },
718 LinkText: ansi.StylePrimitive{
718 LinkText: ansi.StylePrimitive{
719− Color: stringPtr(charmtone.Guac.Hex()),
719+ Color: new(charmtone.Guac.Hex()),
720− Bold: boolPtr(true),
720+ Bold: new(true),
721 },
721 },
722 Image: ansi.StylePrimitive{
722 Image: ansi.StylePrimitive{
723− Color: stringPtr(charmtone.Cheeky.Hex()),
723+ Color: new(charmtone.Cheeky.Hex()),
724− Underline: boolPtr(true),
724+ Underline: new(true),
725 },
725 },
726 ImageText: ansi.StylePrimitive{
726 ImageText: ansi.StylePrimitive{
727− Color: stringPtr(charmtone.Squid.Hex()),
727+ Color: new(charmtone.Squid.Hex()),
728 Format: "Image: {{.text}} →",
728 Format: "Image: {{.text}} →",
729 },
729 },
730 Code: ansi.StyleBlock{
730 Code: ansi.StyleBlock{
731 StylePrimitive: ansi.StylePrimitive{
731 StylePrimitive: ansi.StylePrimitive{
732 Prefix: " ",
732 Prefix: " ",
733 Suffix: " ",
733 Suffix: " ",
734− Color: stringPtr(charmtone.Coral.Hex()),
734+ Color: new(charmtone.Coral.Hex()),
735− BackgroundColor: stringPtr(charmtone.Charcoal.Hex()),
735+ BackgroundColor: new(charmtone.Charcoal.Hex()),
736 },
736 },
737 },
737 },
738 CodeBlock: ansi.StyleCodeBlock{
738 CodeBlock: ansi.StyleCodeBlock{
739 StyleBlock: ansi.StyleBlock{
739 StyleBlock: ansi.StyleBlock{
740 StylePrimitive: ansi.StylePrimitive{
740 StylePrimitive: ansi.StylePrimitive{
741− Color: stringPtr(charmtone.Charcoal.Hex()),
741+ Color: new(charmtone.Charcoal.Hex()),
742 },
742 },
743− Margin: uintPtr(defaultMargin),
743+ Margin: new(uint(defaultMargin)),
744 },
744 },
745 Chroma: &ansi.Chroma{
745 Chroma: &ansi.Chroma{
746 Text: ansi.StylePrimitive{
746 Text: ansi.StylePrimitive{
747− Color: stringPtr(charmtone.Smoke.Hex()),
747+ Color: new(charmtone.Smoke.Hex()),
748 },
748 },
749 Error: ansi.StylePrimitive{
749 Error: ansi.StylePrimitive{
750− Color: stringPtr(charmtone.Butter.Hex()),
750+ Color: new(charmtone.Butter.Hex()),
751− BackgroundColor: stringPtr(charmtone.Sriracha.Hex()),
751+ BackgroundColor: new(charmtone.Sriracha.Hex()),
752 },
752 },
753 Comment: ansi.StylePrimitive{
753 Comment: ansi.StylePrimitive{
754− Color: stringPtr(charmtone.Oyster.Hex()),
754+ Color: new(charmtone.Oyster.Hex()),
755 },
755 },
756 CommentPreproc: ansi.StylePrimitive{
756 CommentPreproc: ansi.StylePrimitive{
757− Color: stringPtr(charmtone.Bengal.Hex()),
757+ Color: new(charmtone.Bengal.Hex()),
758 },
758 },
759 Keyword: ansi.StylePrimitive{
759 Keyword: ansi.StylePrimitive{
760− Color: stringPtr(charmtone.Malibu.Hex()),
760+ Color: new(charmtone.Malibu.Hex()),
761 },
761 },
762 KeywordReserved: ansi.StylePrimitive{
762 KeywordReserved: ansi.StylePrimitive{
763− Color: stringPtr(charmtone.Pony.Hex()),
763+ Color: new(charmtone.Pony.Hex()),
764 },
764 },
765 KeywordNamespace: ansi.StylePrimitive{
765 KeywordNamespace: ansi.StylePrimitive{
766− Color: stringPtr(charmtone.Pony.Hex()),
766+ Color: new(charmtone.Pony.Hex()),
767 },
767 },
768 KeywordType: ansi.StylePrimitive{
768 KeywordType: ansi.StylePrimitive{
769− Color: stringPtr(charmtone.Guppy.Hex()),
769+ Color: new(charmtone.Guppy.Hex()),
770 },
770 },
771 Operator: ansi.StylePrimitive{
771 Operator: ansi.StylePrimitive{
772− Color: stringPtr(charmtone.Salmon.Hex()),
772+ Color: new(charmtone.Salmon.Hex()),
773 },
773 },
774 Punctuation: ansi.StylePrimitive{
774 Punctuation: ansi.StylePrimitive{
775− Color: stringPtr(charmtone.Zest.Hex()),
775+ Color: new(charmtone.Zest.Hex()),
776 },
776 },
777 Name: ansi.StylePrimitive{
777 Name: ansi.StylePrimitive{
778− Color: stringPtr(charmtone.Smoke.Hex()),
778+ Color: new(charmtone.Smoke.Hex()),
779 },
779 },
780 NameBuiltin: ansi.StylePrimitive{
780 NameBuiltin: ansi.StylePrimitive{
781− Color: stringPtr(charmtone.Cheeky.Hex()),
781+ Color: new(charmtone.Cheeky.Hex()),
782 },
782 },
783 NameTag: ansi.StylePrimitive{
783 NameTag: ansi.StylePrimitive{
784− Color: stringPtr(charmtone.Mauve.Hex()),
784+ Color: new(charmtone.Mauve.Hex()),
785 },
785 },
786 NameAttribute: ansi.StylePrimitive{
786 NameAttribute: ansi.StylePrimitive{
787− Color: stringPtr(charmtone.Hazy.Hex()),
787+ Color: new(charmtone.Hazy.Hex()),
788 },
788 },
789 NameClass: ansi.StylePrimitive{
789 NameClass: ansi.StylePrimitive{
790− Color: stringPtr(charmtone.Salt.Hex()),
790+ Color: new(charmtone.Salt.Hex()),
791− Underline: boolPtr(true),
791+ Underline: new(true),
792− Bold: boolPtr(true),
792+ Bold: new(true),
793 },
793 },
794 NameDecorator: ansi.StylePrimitive{
794 NameDecorator: ansi.StylePrimitive{
795− Color: stringPtr(charmtone.Citron.Hex()),
795+ Color: new(charmtone.Citron.Hex()),
796 },
796 },
797 NameFunction: ansi.StylePrimitive{
797 NameFunction: ansi.StylePrimitive{
798− Color: stringPtr(charmtone.Guac.Hex()),
798+ Color: new(charmtone.Guac.Hex()),
799 },
799 },
800 LiteralNumber: ansi.StylePrimitive{
800 LiteralNumber: ansi.StylePrimitive{
801− Color: stringPtr(charmtone.Julep.Hex()),
801+ Color: new(charmtone.Julep.Hex()),
802 },
802 },
803 LiteralString: ansi.StylePrimitive{
803 LiteralString: ansi.StylePrimitive{
804− Color: stringPtr(charmtone.Cumin.Hex()),
804+ Color: new(charmtone.Cumin.Hex()),
805 },
805 },
806 LiteralStringEscape: ansi.StylePrimitive{
806 LiteralStringEscape: ansi.StylePrimitive{
807− Color: stringPtr(charmtone.Bok.Hex()),
807+ Color: new(charmtone.Bok.Hex()),
808 },
808 },
809 GenericDeleted: ansi.StylePrimitive{
809 GenericDeleted: ansi.StylePrimitive{
810− Color: stringPtr(charmtone.Coral.Hex()),
810+ Color: new(charmtone.Coral.Hex()),
811 },
811 },
812 GenericEmph: ansi.StylePrimitive{
812 GenericEmph: ansi.StylePrimitive{
813− Italic: boolPtr(true),
813+ Italic: new(true),
814 },
814 },
815 GenericInserted: ansi.StylePrimitive{
815 GenericInserted: ansi.StylePrimitive{
816− Color: stringPtr(charmtone.Guac.Hex()),
816+ Color: new(charmtone.Guac.Hex()),
817 },
817 },
818 GenericStrong: ansi.StylePrimitive{
818 GenericStrong: ansi.StylePrimitive{
819− Bold: boolPtr(true),
819+ Bold: new(true),
820 },
820 },
821 GenericSubheading: ansi.StylePrimitive{
821 GenericSubheading: ansi.StylePrimitive{
822− Color: stringPtr(charmtone.Squid.Hex()),
822+ Color: new(charmtone.Squid.Hex()),
823 },
823 },
824 Background: ansi.StylePrimitive{
824 Background: ansi.StylePrimitive{
825− BackgroundColor: stringPtr(charmtone.Charcoal.Hex()),
825+ BackgroundColor: new(charmtone.Charcoal.Hex()),
826 },
826 },
827 },
827 },
828 },
828 },
@@ -837,8 +837,8 @@ func DefaultStyles() Styles {
837 }
837 }
838
838
839 // PlainMarkdown style - muted colors on subtle background for thinking content.
839 // PlainMarkdown style - muted colors on subtle background for thinking content.
840− plainBg := stringPtr(bgBaseLighter.Hex())
840+ plainBg := new(bgBaseLighter.Hex())
841− plainFg := stringPtr(fgMuted.Hex())
841+ plainFg := new(fgMuted.Hex())
842 s.PlainMarkdown = ansi.StyleConfig{
842 s.PlainMarkdown = ansi.StyleConfig{
843 Document: ansi.StyleBlock{
843 Document: ansi.StyleBlock{
844 StylePrimitive: ansi.StylePrimitive{
844 StylePrimitive: ansi.StylePrimitive{
@@ -851,8 +851,8 @@ func DefaultStyles() Styles {
851 Color: plainFg,
851 Color: plainFg,
852 BackgroundColor: plainBg,
852 BackgroundColor: plainBg,
853 },
853 },
854− Indent: uintPtr(1),
854+ Indent: new(uint(1)),
855− IndentToken: stringPtr("│ "),
855+ IndentToken: new("│ "),
856 },
856 },
857 List: ansi.StyleList{
857 List: ansi.StyleList{
858 LevelIndent: defaultListIndent,
858 LevelIndent: defaultListIndent,
@@ -860,7 +860,7 @@ func DefaultStyles() Styles {
860 Heading: ansi.StyleBlock{
860 Heading: ansi.StyleBlock{
861 StylePrimitive: ansi.StylePrimitive{
861 StylePrimitive: ansi.StylePrimitive{
862 BlockSuffix: "\n",
862 BlockSuffix: "\n",
863− Bold: boolPtr(true),
863+ Bold: new(true),
864 Color: plainFg,
864 Color: plainFg,
865 BackgroundColor: plainBg,
865 BackgroundColor: plainBg,
866 },
866 },
@@ -869,7 +869,7 @@ func DefaultStyles() Styles {
869 StylePrimitive: ansi.StylePrimitive{
869 StylePrimitive: ansi.StylePrimitive{
870 Prefix: " ",
870 Prefix: " ",
871 Suffix: " ",
871 Suffix: " ",
872− Bold: boolPtr(true),
872+ Bold: new(true),
873 Color: plainFg,
873 Color: plainFg,
874 BackgroundColor: plainBg,
874 BackgroundColor: plainBg,
875 },
875 },
@@ -910,17 +910,17 @@ func DefaultStyles() Styles {
910 },
910 },
911 },
911 },
912 Strikethrough: ansi.StylePrimitive{
912 Strikethrough: ansi.StylePrimitive{
913− CrossedOut: boolPtr(true),
913+ CrossedOut: new(true),
914 Color: plainFg,
914 Color: plainFg,
915 BackgroundColor: plainBg,
915 BackgroundColor: plainBg,
916 },
916 },
917 Emph: ansi.StylePrimitive{
917 Emph: ansi.StylePrimitive{
918− Italic: boolPtr(true),
918+ Italic: new(true),
919 Color: plainFg,
919 Color: plainFg,
920 BackgroundColor: plainBg,
920 BackgroundColor: plainBg,
921 },
921 },
922 Strong: ansi.StylePrimitive{
922 Strong: ansi.StylePrimitive{
923− Bold: boolPtr(true),
923+ Bold: new(true),
924 Color: plainFg,
924 Color: plainFg,
925 BackgroundColor: plainBg,
925 BackgroundColor: plainBg,
926 },
926 },
@@ -948,17 +948,17 @@ func DefaultStyles() Styles {
948 Unticked: "[ ] ",
948 Unticked: "[ ] ",
949 },
949 },
950 Link: ansi.StylePrimitive{
950 Link: ansi.StylePrimitive{
951− Underline: boolPtr(true),
951+ Underline: new(true),
952 Color: plainFg,
952 Color: plainFg,
953 BackgroundColor: plainBg,
953 BackgroundColor: plainBg,
954 },
954 },
955 LinkText: ansi.StylePrimitive{
955 LinkText: ansi.StylePrimitive{
956− Bold: boolPtr(true),
956+ Bold: new(true),
957 Color: plainFg,
957 Color: plainFg,
958 BackgroundColor: plainBg,
958 BackgroundColor: plainBg,
959 },
959 },
960 Image: ansi.StylePrimitive{
960 Image: ansi.StylePrimitive{
961− Underline: boolPtr(true),
961+ Underline: new(true),
962 Color: plainFg,
962 Color: plainFg,
963 BackgroundColor: plainBg,
963 BackgroundColor: plainBg,
964 },
964 },
@@ -981,7 +981,7 @@ func DefaultStyles() Styles {
981 Color: plainFg,
981 Color: plainFg,
982 BackgroundColor: plainBg,
982 BackgroundColor: plainBg,
983 },
983 },
984− Margin: uintPtr(defaultMargin),
984+ Margin: new(uint(defaultMargin)),
985 },
985 },
986 },
986 },
987 Table: ansi.StyleTable{
987 Table: ansi.StyleTable{
@@ -1368,10 +1368,6 @@ func DefaultStyles() Styles {
1368 return s
1368 return s
1369}
1369}
1370
1370
1371−// Helper functions for style pointers
1372−func boolPtr(b bool) *bool { return &b }
1373−func stringPtr(s string) *string { return &s }
1374−func uintPtr(u uint) *uint { return &u }
1375func chromaStyle(style ansi.StylePrimitive) string {
1371func chromaStyle(style ansi.StylePrimitive) string {
1376 var s strings.Builder
1372 var s strings.Builder
1377
1373