| 1 | // Copyright 2016 The Go Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
| 5 | package presentscip-go gomod golang.org/x/tools . `golang.org/x/tools/present`/ |
| 6 | |
| 7 | import ( |
| 8 | "fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/" |
| 9 | "stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/" |
| 10 | ) |
| 11 | |
| 12 | func initscip-go gomod golang.org/x/tools . `golang.org/x/tools/present`/init().() { |
| 13 | Registerscip-go gomod golang.org/x/tools . `golang.org/x/tools/present`/Register().("video", parseVideoscip-go gomod golang.org/x/tools . `golang.org/x/tools/present`/parseVideo().) |
| 14 | } |
| 15 | |
| 16 | type Videoscip-go gomod golang.org/x/tools . `golang.org/x/tools/present`/Video# struct { |
| 17 | Cmdscip-go gomod golang.org/x/tools . `golang.org/x/tools/present`/Video#Cmd. string // original command from present source |
| 18 | URLscip-go gomod golang.org/x/tools . `golang.org/x/tools/present`/Video#URL. string |
| 19 | SourceTypescip-go gomod golang.org/x/tools . `golang.org/x/tools/present`/Video#SourceType. string |
| 20 | Widthscip-go gomod golang.org/x/tools . `golang.org/x/tools/present`/Video#Width. int |
| 21 | Heightscip-go gomod golang.org/x/tools . `golang.org/x/tools/present`/Video#Height. int |
| 22 | } |
| 23 | |
| 24 | func (v Videoscip-go gomod golang.org/x/tools . `golang.org/x/tools/present`/Video#) PresentCmdscip-go gomod golang.org/x/tools . `golang.org/x/tools/present`/Video#PresentCmd().() string { return v.Cmdscip-go gomod golang.org/x/tools . `golang.org/x/tools/present`/Video#Cmd. } |
| 25 | func (v Videoscip-go gomod golang.org/x/tools . `golang.org/x/tools/present`/Video#) TemplateNamescip-go gomod golang.org/x/tools . `golang.org/x/tools/present`/Video#TemplateName().() string { return "video" } |
| 26 | |
| 27 | func parseVideoscip-go gomod golang.org/x/tools . `golang.org/x/tools/present`/parseVideo().(ctx *Contextscip-go gomod golang.org/x/tools . `golang.org/x/tools/present`/Context#, fileName string, lineno int, text string) (Elemscip-go gomod golang.org/x/tools . `golang.org/x/tools/present`/Elem#, error) { |
| 28 | args := stringsscip-go gomod github.com/golang/go/src go1.25.0 strings/.Fieldsscip-go gomod github.com/golang/go/src go1.25.0 strings/Fields().(text) |
| 29 | if len(args) < 3 { |
| 30 | return nil, fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Errorf().("incorrect video invocation: %q", text) |
| 31 | } |
| 32 | vid := Videoscip-go gomod golang.org/x/tools . `golang.org/x/tools/present`/Video#{Cmdscip-go gomod golang.org/x/tools . `golang.org/x/tools/present`/Video#Cmd.: text, URLscip-go gomod golang.org/x/tools . `golang.org/x/tools/present`/Video#URL.: args[1], SourceTypescip-go gomod golang.org/x/tools . `golang.org/x/tools/present`/Video#SourceType.: args[2]} |
| 33 | a, err := parseArgsscip-go gomod golang.org/x/tools . `golang.org/x/tools/present`/parseArgs().(fileName, lineno, args[3:]) |
| 34 | if err != nil { |
| 35 | return nil, err |
| 36 | } |
| 37 | switch len(a) { |
| 38 | case 0: |
| 39 | // no size parameters |
| 40 | case 2: |
| 41 | // If a parameter is empty (underscore) or invalid |
| 42 | // leave the field set to zero. The "video" action |
| 43 | // template will then omit that vid tag attribute and |
| 44 | // the browser will calculate the value to preserve |
| 45 | // the aspect ratio. |
| 46 | if v, ok := a[0].(int); ok { |
| 47 | vid.Heightscip-go gomod golang.org/x/tools . `golang.org/x/tools/present`/Video#Height. = v |
| 48 | } |
| 49 | if v, ok := a[1].(int); ok { |
| 50 | vid.Widthscip-go gomod golang.org/x/tools . `golang.org/x/tools/present`/Video#Width. = v |
| 51 | } |
| 52 | default: |
| 53 | return nil, fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Errorf().("incorrect video invocation: %q", text) |
| 54 | } |
| 55 | return vid, nil |
| 56 | } |