Skip to content

Commit

Permalink
docs: add ya.raw_err()
Browse files Browse the repository at this point in the history
  • Loading branch information
sxyazi committed Jul 5, 2024
1 parent 7f6c04e commit 002de8b
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 29 deletions.
57 changes: 28 additions & 29 deletions docs/plugins/layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,12 @@ Applies a minimum size constraint to the element
The element size is set to at least the specified amount.

```lua
-- `{ Percentage(100), Min(20) }`
-- { Percentage(100), Min(20) }
-- ┌────────────────────────────┐┌──────────────────┐
-- │ 30 px ││ 20 px │
-- └────────────────────────────┘└──────────────────┘
--
-- `{ Percentage(100), Min(10) }`

-- { Percentage(100), Min(10) }
-- ┌──────────────────────────────────────┐┌────────┐
-- │ 40 px ││ 10 px │
-- └──────────────────────────────────────┘└────────┘
Expand All @@ -120,12 +120,12 @@ Applies a maximum size constraint to the element
The element size is set to at most the specified amount.

```lua
-- `{ Percentage(0), Max(20) }`
-- { Percentage(0), Max(20) }
-- ┌────────────────────────────┐┌──────────────────┐
-- │ 30 px ││ 20 px │
-- └────────────────────────────┘└──────────────────┘
--
-- `{ Percentage(0), Max(10) }`

-- { Percentage(0), Max(10) }
-- ┌──────────────────────────────────────┐┌────────┐
-- │ 40 px ││ 10 px │
-- └──────────────────────────────────────┘└────────┘
Expand All @@ -139,12 +139,12 @@ Applies a length constraint to the element
The element size is set to the specified amount.

```lua
-- `{ Length(20), Length(20) }`
-- { Length(20), Length(20) }
-- ┌──────────────────┐┌──────────────────┐
-- │ 20 px ││ 20 px │
-- └──────────────────┘└──────────────────┘
--
-- `{ Length(20), Length(30) }`

-- { Length(20), Length(30) }
-- ┌──────────────────┐┌────────────────────────────┐
-- │ 20 px ││ 30 px │
-- └──────────────────┘└────────────────────────────┘
Expand All @@ -158,12 +158,12 @@ Converts the given percentage to a floating-point value and multiplies that with
This value is rounded back to a integer as part of the layout split calculation.

```lua
-- `{ Percentage(75), Fill(1) }`
-- { Percentage(75), Fill(1) }
-- ┌────────────────────────────────────┐┌──────────┐
-- │ 38 px ││ 12 px │
-- └────────────────────────────────────┘└──────────┘
--
-- `{ Percentage(50), Fill(1) }`

-- { Percentage(50), Fill(1) }
-- ┌───────────────────────┐┌───────────────────────┐
-- │ 25 px ││ 25 px │
-- └───────────────────────┘└───────────────────────┘
Expand All @@ -177,12 +177,12 @@ Converts the given ratio to a floating-point value and multiplies that with area
This value is rounded back to a integer as part of the layout split calculation.

```lua
-- `{ Ratio(1, 2), Ratio(1, 2) }`
-- { Ratio(1, 2), Ratio(1, 2) }
-- ┌───────────────────────┐┌───────────────────────┐
-- │ 25 px ││ 25 px │
-- └───────────────────────┘└───────────────────────┘
--
-- `{ Ratio(1, 4), Ratio(1, 4), Ratio(1, 4), Ratio(1, 4) }`

-- { Ratio(1, 4), Ratio(1, 4), Ratio(1, 4), Ratio(1, 4) }
-- ┌───────────┐┌──────────┐┌───────────┐┌──────────┐
-- │ 13 px ││ 12 px ││ 13 px ││ 12 px │
-- └───────────┘└──────────┘└───────────┘└──────────┘
Expand All @@ -197,12 +197,12 @@ The element will only expand or fill into excess available space, proportionally
other `Fill` elements while satisfying all other constraints.

```lua
-- `{ Fill(1), Fill(2), Fill(3) }`
-- { Fill(1), Fill(2), Fill(3) }
-- ┌──────┐┌───────────────┐┌───────────────────────┐
-- │ 8 px ││ 17 px ││ 25 px │
-- └──────┘└───────────────┘└───────────────────────┘
--
-- `{ Fill(1), Percentage(50), Fill(1) }`

-- { Fill(1), Percentage(50), Fill(1) }
-- ┌───────────┐┌───────────────────────┐┌──────────┐
-- │ 13 px ││ 25 px ││ 12 px │
-- └───────────┘└───────────────────────┘└──────────┘
Expand Down Expand Up @@ -302,6 +302,13 @@ All parameters for padding are integers:
ui.Padding(left, right, top, bottom)
```

Properties:

- `left` - left padding
- `right` - right padding
- `top` - top padding
- `bottom` - bottom padding

If you want to specify only one of them, you can:

- `ui.Padding.left(left)` equal to `ui.Padding(left, 0, 0, 0)`
Expand All @@ -315,13 +322,6 @@ Or specify a particular direction for them:
- `ui.Padding.y(y)` equal to `ui.Padding(0, 0, y, y)`
- `ui.Padding.xy(x, y)` equal to `ui.Padding(x, x, y, y)`

Properties:

- `left` - left padding
- `right` - right padding
- `top` - top padding
- `bottom` - bottom padding

## Paragraph {#paragraph}

Create a paragraph:
Expand Down Expand Up @@ -362,10 +362,6 @@ ui.Rect {
ui.Rect.default -- Equal to `ui.Rect { x = 0, y = 0, w = 0, h = 0 }`
```

You can obtain a pre-computed `Rect` through [Yazi's layout system](#layout).

Note that if you intend to create it yourself, ensure these values are calculated accurately; otherwise, it may cause Yazi to crash!

Properties:

- `x` - x position
Expand All @@ -381,6 +377,9 @@ Methods (all methods return `self`):

- `padding(padding)` - Set padding. It accepts a [Padding](#padding)

You can obtain a pre-computed `Rect` through [`ui.Layout()`](#layout).
Note that if you intend to create a `Rect` yourself, ensure these values are calculated accurately; otherwise, it may cause Yazi to crash!

## Span {#span}

Create a span:
Expand Down
12 changes: 12 additions & 0 deletions docs/plugins/utils.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,18 @@ ya.err("Hello", "World!") -- Multiple arguments are suppor
ya.err({ foo = "bar", baz = 123, qux = true }) -- Any type of data is supported
```

### `raw_err(msg)` {#ya.raw_err}

Append a message to [the log file](/docs/plugins/overview#logging) at the error level, and keep the message as it is:

- `msg` - Required, the message to be logged, which is a string.

```lua
ya.raw_err("Hello, World!")
```

The nightly version of Yazi is required at the moment.

### `sync(fn)` {#ya.sync}

See [Async context](/docs/plugins/overview#async-context).
Expand Down

0 comments on commit 002de8b

Please sign in to comment.