- Paragraph => CustomParagraph
- List => CustomList
- Table => CustomTable

Also update init.lua
pull/589/head
Arijit Basu 1 year ago
parent e63c17527a
commit bf28f53892

@ -175,11 +175,11 @@ The list of child layouts to fit into the parent layout.
Custom panel can be one of the following:
- [Paragraph][29]
- [List][30]
- [Table][31]
- [CustomParagraph][29]
- [CustomList][30]
- [CustomTable][31]
### Paragraph
### CustomParagraph
A paragraph to render. It contains the following fields:
@ -191,7 +191,7 @@ A paragraph to render. It contains the following fields:
```lua
xplr.config.layouts.builtin.default = {
Static = {
Paragraph = {
CustomParagraph = {
ui = { title = { format = " custom title " } },
body = "custom body",
},
@ -206,7 +206,7 @@ xplr.config.layouts.builtin.default = { Dynamic = "custom.render_layout" }
xplr.fn.custom.render_layout = function(ctx)
return {
Paragraph = {
CustomParagraph = {
ui = { title = { format = ctx.app.pwd } },
body = xplr.util.to_yaml(ctx.app.focused_node),
},
@ -214,7 +214,7 @@ xplr.fn.custom.render_layout = function(ctx)
end
```
### List
### CustomList
A list to render. It contains the following fields:
@ -226,7 +226,7 @@ A list to render. It contains the following fields:
```lua
xplr.config.layouts.builtin.default = {
Static = {
List = {
CustomList = {
ui = { title = { format = " custom title " } },
body = { "1", "2", "3" },
},
@ -241,7 +241,7 @@ xplr.config.layouts.builtin.default = { Dynamic = "custom.render_layout" }
xplr.fn.custom.render_layout = function(ctx)
return {
List = {
CustomList = {
ui = { title = { format = ctx.app.pwd } },
body = {
(ctx.app.focused_node or {}).relative_path or "",
@ -253,7 +253,7 @@ xplr.fn.custom.render_layout = function(ctx)
end
```
## Table
## CustomTable
A custom table to render. It contains the following fields:
@ -267,7 +267,7 @@ A custom table to render. It contains the following fields:
```lua
xplr.config.layouts.builtin.default = {
Static = {
Table = {
CustomTable = {
ui = { title = { format = " custom title " } },
widths = {
{ Percentage = 50 },
@ -289,7 +289,7 @@ xplr.config.layouts.builtin.default = {Dynamic = "custom.render_layout" }
xplr.fn.custom.render_layout = function(ctx)
return {
Table = {
CustomTable = {
ui = { title = { format = ctx.app.pwd } },
widths = {
{ Percentage = 50 },
@ -396,9 +396,9 @@ Hence, only the following fields are avilable.
[26]: #dynamic
[27]: #custom-panel
[28]: configuration.md#function
[29]: #paragraph
[30]: #list
[31]: #table
[29]: #custom-paragraph
[30]: #custom-list
[31]: #custom-table
[32]: #panel-ui-config
[33]: style.md#style
[34]: borders.md#border

@ -1317,11 +1317,10 @@ xplr.config.modes.builtin.debug_error = {
},
splits = {
{
CustomContent = {
title = "debug error",
body = {
StaticParagraph = {
render = [[
Static = {
CustomParagraph = {
ui = { title = { format = "debug error" } },
body = [[
Some errors occurred during startup.
If you think this is a bug, please report it at:
@ -1333,8 +1332,7 @@ xplr.config.modes.builtin.debug_error = {
To disable this mode, set `xplr.config.general.disable_debug_error_mode`
to `true` in your config file.
]],
},
]],
},
},
},
@ -1373,11 +1371,10 @@ xplr.config.modes.builtin.debug_error = {
xplr.config.modes.builtin.recover = {
name = "recover",
layout = {
CustomContent = {
title = " recover ",
body = {
StaticParagraph = {
render = [[
Static = {
CustomParagraph = {
ui = { title = { format = "recover" } },
body = [[
You pressed an invalid key and went into "recover" mode.
This mode saves you from performing unwanted actions.
@ -1386,8 +1383,7 @@ xplr.config.modes.builtin.recover = {
To disable this mode, set `xplr.config.general.enable_recover_mode`
to `false` in your config file.
]],
},
]],
},
},
},

@ -79,17 +79,17 @@ impl LayoutOptions {
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(deny_unknown_fields)]
pub enum CustomPanel {
Paragraph {
CustomParagraph {
#[serde(default)]
ui: PanelUiConfig,
body: String,
},
List {
CustomList {
#[serde(default)]
ui: PanelUiConfig,
body: Vec<String>,
},
Table {
CustomTable {
#[serde(default)]
ui: PanelUiConfig,
widths: Vec<Constraint>,
@ -1221,7 +1221,7 @@ pub fn draw_dynamic<B: Backend>(
let panel: CustomPanel = lua::serialize(lua, &ctx)
.and_then(|arg| lua::call(lua, func, arg))
.unwrap_or_else(|e| CustomPanel::Paragraph {
.unwrap_or_else(|e| CustomPanel::CustomParagraph {
ui: app.config.general.panel_ui.default.clone(),
body: format!("{e:?}"),
});
@ -1239,14 +1239,14 @@ pub fn draw_static<B: Backend>(
) {
let defaultui = app.config.general.panel_ui.default.clone();
match panel {
CustomPanel::Paragraph { ui, body } => {
CustomPanel::CustomParagraph { ui, body } => {
let config = defaultui.extend(&ui);
let body = string_to_text(body);
let content = Paragraph::new(body).block(block(config, "".into()));
f.render_widget(content, layout_size);
}
CustomPanel::List { ui, body } => {
CustomPanel::CustomList { ui, body } => {
let config = defaultui.extend(&ui);
let items = body
@ -1259,7 +1259,7 @@ pub fn draw_static<B: Backend>(
f.render_widget(content, layout_size);
}
CustomPanel::Table {
CustomPanel::CustomTable {
ui,
widths,
col_spacing,

Loading…
Cancel
Save