(conf *Config)
| 566 | } |
| 567 | |
| 568 | func initialModel(conf *Config) model { |
| 569 | var inputs []textinput.Model |
| 570 | var checkboxes []Checkbox |
| 571 | var fileInputs []FileInput |
| 572 | |
| 573 | req := newReqest() |
| 574 | |
| 575 | // update styles according to theme colors |
| 576 | timeout = conf.Timeout |
| 577 | maxRedirects = conf.MaxRedirects |
| 578 | chromaStyle = conf.Chroma |
| 579 | baseStyle := lipgloss.NewStyle().Width(screenWidth) |
| 580 | promptStyle = lipgloss.NewStyle().Foreground(conf.Color("textinputPrompt")).Bold(true) |
| 581 | promptActiveStyle = lipgloss.NewStyle().Foreground(conf.Color("textinputPromptActive")).Bold(true) |
| 582 | placeholderStyle = lipgloss.NewStyle().Foreground(conf.Color("textinputPlaceholder")) |
| 583 | placeholderActiveStyle = lipgloss.NewStyle().Foreground(conf.Color("textinputPlaceholderActive")) |
| 584 | textValueStyle = lipgloss.NewStyle().Foreground(conf.Color("textinputText")) |
| 585 | |
| 586 | bodyStyle = lipgloss.NewStyle().Inherit(baseStyle).Foreground(conf.Color("requestBody")) |
| 587 | |
| 588 | pressedKeyPromptStyle = lipgloss.NewStyle().Foreground(conf.Color("pressedKeyPrompt")) |
| 589 | pressedKeyTextStyle = lipgloss.NewStyle().Foreground(conf.Color("pressedKeyText")).Bold(true) |
| 590 | |
| 591 | textAreaTextStyle = lipgloss.NewStyle().Foreground(conf.Color("textareaText")) |
| 592 | textAreaPlaceholder = lipgloss.NewStyle().Foreground(conf.Color("textareaPlaceholder")) |
| 593 | textAreaCursorLineStyle = lipgloss.NewStyle().Foreground(conf.Color("textareaCursorLine")) |
| 594 | |
| 595 | checkboxOnStyle = lipgloss.NewStyle().Foreground(conf.Color("checkboxOn")).Bold(true).PaddingRight(21) |
| 596 | checkboxOffStyle = lipgloss.NewStyle().Foreground(conf.Color("checkboxOff")).PaddingRight(21) |
| 597 | |
| 598 | headerNameStyle = lipgloss.NewStyle().Foreground(conf.Color("headerName")) |
| 599 | headerValueStyle = lipgloss.NewStyle().Foreground(conf.Color("headerValue")) |
| 600 | |
| 601 | urlStyle = lipgloss.NewStyle().Inherit(baseStyle). |
| 602 | Foreground(conf.Color("url")). |
| 603 | Bold(true).Padding(0, 1) |
| 604 | |
| 605 | sbar = NewStatusBar(conf) |
| 606 | |
| 607 | w, h, err := term.GetSize(int(os.Stdout.Fd())) |
| 608 | if err != nil { |
| 609 | panic(err) |
| 610 | } |
| 611 | screenWidth = w |
| 612 | screenHeight = h |
| 613 | |
| 614 | for i := 0; i < fieldsCount; i++ { |
| 615 | inputs = append(inputs, NewKeyValInputs(i)) |
| 616 | } |
| 617 | |
| 618 | c1 := NewCheckbox(https, "https ", "⟨on⟩ ", "⟨off⟩", promptStyle, checkboxOnStyle, checkboxOffStyle) |
| 619 | if conf.Checkboxes["https"] { |
| 620 | req.URL.Scheme = "https" |
| 621 | c1.SetOn() |
| 622 | } |
| 623 | c2 := NewCheckbox(autoformat, "Auto format JSON ", "⟨on⟩ ", "⟨off⟩", promptStyle, checkboxOnStyle, checkboxOffStyle) |
| 624 | if conf.Checkboxes["autoformat"] { |
| 625 | c2.SetOn() |
no test coverage detected