summary refs log tree commit diff stats
path: root/tests/generics
Commit message (Expand)AuthorAgeFilesLines
* fixes subtype relation regressionAraq2019-05-221-1/+1
* fixes #11239Araq2019-05-221-1/+1
* fixes #6732 (#11255)Andreas Rumpf2019-05-151-0/+21
* fixes #88 (#11243)Andreas Rumpf2019-05-151-2/+25
* 32 bit fixes (#10608)Arne Döring2019-02-131-0/+2
* Propagate tfGcSafe flag to generic instantiations (#10620)LemonBoy2019-02-131-0/+11
* Fix for issue #10342. better message for generic subclass instantiation (#10354)Ray Imber2019-01-222-1/+12
* add `isNamedTuple`; make $(1, 2) be (1, 2) instead of (Field0: 1, Field1: 2) ...Timothee Cour2019-01-081-1/+1
* megatest: make it green on LinuxAraq2018-12-113-4/+3
* make more tests greenAraq2018-12-112-36/+8
* testament: joinable is now an explicit concept of a test specAndreas Rumpf2018-12-111-0/+3
* Testament: refactoring; makes the test joiner greenAraq2018-12-116-2/+10
* lots of small changesArne Döring2018-12-114-4/+4
* megatest checks output and nimoutArne Döring2018-12-114-133/+127
* require errormsg to be specified before file.Arne Döring2018-12-116-16/+3
* cleanup tests; don't use non-working 'msg' spec fieldAraq2018-11-231-1/+1
* updated tests to be executedArne Döring2018-11-232-2/+13
* make run the default action of a test in testerArne Döring2018-11-232-1/+13
* disable some tests for the C++ target; refs #7870Araq2018-11-151-9/+10
* adopt testsArne Döring2018-11-081-1/+1
* More descriptive names of test files (#9531)Miran2018-10-293-6/+8
* closes #6220Araq2018-10-181-0/+415
* make some tests faster (#9413)Miran2018-10-171-5/+5
* Merge tests into a larger file (part 5 of ∞) (#9368)Miran2018-10-161-1/+1
* Merge tests into a larger file (part 3 of ∞: generics) (#9347)Miran2018-10-1465-1276/+1236
* add issue #5707 as test case (#9361)Vindaar2018-10-141-0/+6
* fix tests/generics/t8694.nim: runnableExamples were not run because of #9216 ...Timothee Cour2018-10-091-3/+3
* Fix regression with runnableExamples in generic exprLemonBoy2018-09-302-0/+64
* fixes #8883Araq2018-09-141-0/+657
* fixes #7854Araq2018-08-301-0/+36
* make generic tests green againAndreas Rumpf2018-08-131-2/+2
* Merge branch 'devel' into araq-miscAndreas Rumpf2018-08-102-0/+39
|\
| * Tests for v1 closed generics/static issues (#8572)Mamy Ratsimbazafy2018-08-082-0/+39
* | make test green againAraq2018-08-081-6/+6
|/
* Try conversion to static[T] in generic instantation (#8443)LemonBoy2018-07-301-0/+10
* Allow use of typedesc as type converters (#8409)LemonBoy2018-07-241-0/+11
* Do not crash while instantiating a generic outside a call (#8279)LemonBoy2018-07-141-0/+7
* Reset typedescMatched before paramTypesMatch (#8250)LemonBoy2018-07-091-0/+15
* make tests green againAndreas Rumpf2018-07-054-5/+5
* fix #6928; fix #7208Zahary Karadjov2018-06-161-0/+21
* fixes #7222; fixes #5595; fixes #3747Zahary Karadjov2018-06-161-0/+124
* fix #7653Zahary Karadjov2018-06-101-1/+3
* Fix type inference with static literals.LemonBoy2018-06-101-0/+12
* Bugfix: The compiler were not inserting proper downcasts for generic typesZahary Karadjov2018-05-072-1/+21
* fixes #7247Andreas Rumpf2018-02-231-6/+15
* make more tests greenAraq2018-02-102-2/+2
* better type inference for numerical types; prerequisitive for version 1Andreas Rumpf2018-02-021-0/+12
* Improved collection-to-string behavior (#6825)Fabian Keller2017-12-141-2/+2
* make tests green againAndreas Rumpf2017-11-181-0/+1
* Remove expr/stmt (#5857)Arne Döring2017-07-254-5/+5
00 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
package widgets

import (
	"errors"

	"git.sr.ht/~sircmpwn/aerc/lib/ui"

	"github.com/gdamore/tcell"
	"golang.org/x/crypto/openpgp"
	pgperrors "golang.org/x/crypto/openpgp/errors"
)

type PGPInfo struct {
	ui.Invalidatable
	details *openpgp.MessageDetails
}

func NewPGPInfo(details *openpgp.MessageDetails) *PGPInfo {
	return &PGPInfo{details: details}
}

func (p *PGPInfo) DrawSignature(ctx *ui.Context) {
	errorStyle := tcell.StyleDefault.Background(tcell.ColorRed).
		Foreground(tcell.ColorWhite).Bold(true)
	softErrorStyle := tcell.StyleDefault.Foreground(tcell.ColorYellow).Bold(true)
	validStyle := tcell.StyleDefault.Foreground(tcell.ColorGreen).Bold(true)

	// TODO: Nicer prompt for TOFU, fetch from keyserver, etc
	if errors.Is(p.details.SignatureError, pgperrors.ErrUnknownIssuer) ||
		p.details.SignedBy == nil {

		x := ctx.Printf(0, 0, softErrorStyle, "*")
		x += ctx.Printf(x, 0, tcell.StyleDefault,
			" Signed with unknown key (%8X); authenticity unknown",
			p.details.SignedByKeyId)
	} else if p.details.SignatureError != nil {
		x := ctx.Printf(0, 0, errorStyle, "Invalid signature!")
		x += ctx.Printf(x, 0, tcell.StyleDefault.
			Foreground(tcell.ColorRed).Bold(true),
			" This message may have been tampered with! (%s)",
			p.details.SignatureError.Error())
	} else {
		entity := p.details.SignedBy.Entity
		var ident *openpgp.Identity
		// TODO: Pick identity more intelligently
		for _, ident = range entity.Identities {
			break
		}
		x := ctx.Printf(0, 0, validStyle, "✓ Authentic ")
		x += ctx.Printf(x, 0, tcell.StyleDefault,
			"Signature from %s (%8X)",
			ident.Name, p.details.SignedByKeyId)
	}
}

func (p *PGPInfo) DrawEncryption(ctx *ui.Context, y int) {
	validStyle := tcell.StyleDefault.Foreground(tcell.ColorGreen).Bold(true)
	entity := p.details.DecryptedWith.Entity
	var ident *openpgp.Identity
	// TODO: Pick identity more intelligently
	for _, ident = range entity.Identities {
		break
	}

	x := ctx.Printf(0, y, validStyle, "✓ Encrypted ")
	x += ctx.Printf(x, y, tcell.StyleDefault,
		"To %s (%8X) ", ident.Name, p.details.DecryptedWith.PublicKey.KeyId)
}

func (p *PGPInfo) Draw(ctx *ui.Context) {
	ctx.Fill(0, 0, ctx.Width(), ctx.Height(), ' ', tcell.StyleDefault)
	if p.details.IsSigned && p.details.IsEncrypted {
		p.DrawSignature(ctx)
		p.DrawEncryption(ctx, 1)
	} else if p.details.IsSigned {
		p.DrawSignature(ctx)
	} else if p.details.IsEncrypted {
		p.DrawEncryption(ctx, 0)
	}
}

func (p *PGPInfo) Invalidate() {
	p.DoInvalidate(p)
}