@@ -3,11 +3,13 @@ local M = {}
33-- Store table data for manipulation (word wrapping, etc.)
44M .table_data = nil
55
6- local config = require (" sqlflick.config" )
6+ M .MAX_COLUMN_WIDTH = 200 -- Maximum width for any column
7+ M .MIN_COLUMN_WIDTH = 0 -- Minimum width for readability
78
8- -- Configuration
9- local MAX_COLUMN_WIDTH = math.max (config .opts .display .column .max_width , 200 ) -- Maximum width for any column
10- local MIN_COLUMN_WIDTH = math.min (config .opts .display .column .min_width , 0 ) -- Minimum width for readability
9+ function M .setup (opts )
10+ M .MAX_COLUMN_WIDTH = math.min (opts .display .column .max_width , M .MAX_COLUMN_WIDTH )
11+ M .MIN_COLUMN_WIDTH = math.max (opts .display .column .min_width , M .MIN_COLUMN_WIDTH )
12+ end
1113
1214-- Helper function to truncate text and add ellipsis if needed
1315local function truncate_text (text , max_width )
@@ -108,7 +110,7 @@ function M.format_query_results(result)
108110 end
109111
110112 local ideal_width = math.max (header_width , max_data_width )
111- col_widths [i ] = math.max (MIN_COLUMN_WIDTH , math.min (MAX_COLUMN_WIDTH , ideal_width ))
113+ col_widths [i ] = math.max (M . MIN_COLUMN_WIDTH , math.min (M . MAX_COLUMN_WIDTH , ideal_width ))
112114 end
113115
114116 for i , width in ipairs (col_widths ) do
@@ -315,7 +317,7 @@ function M.format_query_results_with_wrapping(result)
315317 end
316318
317319 local ideal_width = math.max (header_width , max_data_width )
318- col_widths [i ] = math.max (MIN_COLUMN_WIDTH , math.min (MAX_COLUMN_WIDTH , ideal_width )) + 2
320+ col_widths [i ] = math.max (M . MIN_COLUMN_WIDTH , math.min (M . MAX_COLUMN_WIDTH , ideal_width )) + 2
319321 end
320322
321323 -- Format header and borders
0 commit comments