more work on porting command parsing to Go

This commit is contained in:
Kovid Goyal
2022-08-30 20:30:25 +05:30
parent 6f4968305a
commit a4b2e2a196
7 changed files with 29 additions and 12 deletions

View File

@@ -9,7 +9,6 @@ import (
"fmt"
"io"
"os"
"strconv"
"strings"
"time"

View File

@@ -8,8 +8,8 @@ import (
"strings"
)
func parse_scroll_amount(amt string) ([2]interface{}, error) {
var ans [2]interface{}
func parse_scroll_amount(amt string) ([]interface{}, error) {
var ans = make([]interface{}, 2)
if amt == "start" || amt == "end" {
ans[0] = amt
ans[1] = nil

View File

@@ -0,0 +1,19 @@
// License: GPLv3 Copyright: 2022, Kovid Goyal, <kovid at kovidgoyal.net>
package at
import "strconv"
func parse_opacity(arg string) (float64, error) {
ans, err := strconv.ParseFloat(arg, 64)
if err != nil {
return 0, nil
}
if ans < 0.1 {
ans = 0.1
}
if ans > 1 {
ans = 1
}
return ans, nil
}