-- lx-bundle:true

-- This file is part of Lx, created by Liqube <www.liqube.com>
-- Copyright Liqube Audio. All rights reserved.
-- Lx Interim License. See LICENSE for details.

local common = require("core.common")

local config = {}

config.plugins = config.plugins or {}

-- Extra friendly reports for people developing Lx, formats, and plugins
config.dev = {
	show_details = false,
}

-- Active application locale; regional keys fall back to their base language
config.locale = "en"

-- Allow any fallback font files beyond the primary UI fonts
config.use_fallback_fonts = true

-- Allow fallback font entries tagged with these explicit tags
-- Platform-specific tags "windows", "linux", "macos" are automatically enabled
config.enabled_fallback_font_tags = {
	"emoji",		-- Monochrome emoji (recommended if you want raw speed)
	"coloremoji",	-- Color emoji (enable if you absolutely must have color emoji)
	"symbols",		-- General symbols
	"music",		-- Music notation symbols
	"cjk",			-- Combines Chinese/Japanese/Korean coverage
--	"japanese",		-- Japanese coverage
--	"korean",		-- Korean coverage
--	"chinese",		-- Simplified Chinese coverage
--	"chinesetr",	-- Traditional Chinese coverage
	"arabic",		-- Arabic-script coverage
	"thai",			-- Thai-script coverage
	"indic",		-- Combines Indic-script coverage
--	"devanagari",	-- Devanagari Indic script
--	"kannada",		-- Kannada Indic script
--	"tamil",		-- Tamil Indic script
--	"telugu",		-- Telugu Indic script
--	"bengali",		-- Bengali Indic script
}

-- Enable font bitmap glyphs such as fixed-strike emoji fonts
config.allow_font_bitmap_glyphs = true

-- Enable font SVG glyphs such as OT-SVG color emoji fonts
config.allow_font_svg_glyphs = true

-- Renderer font quality controls applied before style fonts are loaded
config.font_quality = {
	hinting = "light",
	render_mode = "normal",
	alpha_gamma = 0.9,
	alpha_contrast = 0.2,
	embolden = 0.0,
}

-- Enable syntax highlighter tokenization and colored token rendering in doc views
config.syntax_highlighting = true

-- Draw full-row backgrounds requested by format modules
config.syntax_line_backgrounds = true

-- Default syntax draw mode for TextViewer
config.text_viewer_syntax_highlighting = false

-- Keep TextViewer wrap opt-in until the wrapped path settles
config.text_viewer_word_wrap = true

-- Keep TextEditor wrap opt-in until the wrapped editor path settles
config.text_editor_word_wrap = true

-- Keep wrapped continuation rows aligned with leading indentation
config.text_wrap_preserve_indent = true

-- Keep at least this many monospace columns available after continuation indent
config.text_wrap_min_columns = 8

-- Collect wrapped layout and draw timing counters only when profiling is enabled
config.text_wrap_profile_enabled = false

-- Synthetic wrap benchmark line count used by the wrap profiling command
config.text_wrap_profile_bench_lines = 25000

-- Synthetic wrap benchmark line width used by the wrap profiling command
config.text_wrap_profile_bench_columns = 180

-- Repeat count used for cached wrap benchmark passes
config.text_wrap_profile_bench_repeats = 5

-- Collect syntax and render perf counters for manual debugging snapshots
config.debug_syntax_render_perf = false

-- TextViewer keeps a clean reading layout without a gutter by default
config.text_viewer_gutter = false

-- TextViewer line numbers stay off unless the gutter is explicitly enabled
config.text_viewer_line_numbers = false

-- TextEditor keeps the shared gutter visible for change markers and bookmarks
config.text_editor_gutter = true

-- TextEditor shows line numbers inside the visible gutter by default
config.text_editor_line_numbers = true

-- Keep line-number gutters stable across short documents
config.line_number_min_digits = 3

-- Show the shared horizontal scrollbar when unwrapped text exceeds its viewport
config.hscrollbar_enabled = true

-- Use the active theme scrollbar height unless a fixed size is requested
config.hscrollbar_height = nil

-- Limit one incremental horizontal width scan to this many milliseconds
config.hscrollbar_scan_budget_ms = 1.0

-- Measure small documents completely instead of spreading their width scan across updates
config.hscrollbar_full_scan_max_lines = 1000

-- Estimate width instead of scanning when one line already reaches this character count
config.hscrollbar_estimate_only_min_longest_line_chars = 2000

-- Estimate width instead of scanning when the document reaches this line count
config.hscrollbar_estimate_only_min_lines = 25000

-- Keep this much empty room after the widest known line
config.hscrollbar_end_padding = 32


config.project_scan_rate = 5

-- Background recursive project scan is opt-in and starts only on demand
config.project_scan_enabled = false

-- Hard cap for recursive background project scan entries
config.project_scan_limit_files = 2000

-- Extra folders checked after a file reference is not found beside its source or parents
config.file_reference_search_paths = {}

-- Reveal strict file references as links while Ctrl or Cmd is held
config.file_reference_links = true

-- Control whether unusable file positions recover quietly, report once, or reject the request
config.file_locations = {
	position_mode = "warn",
}

-- Delay in seconds before loading and running the automatic alpha update check
config.update_check_delay = 10

-- Target frame rate, clamped to 1..1000 with 60 used for invalid values
config.fps = 60

-- Synchronize composited rendering with the actual display refresh rate (recommended when using a fast display)
config.vsync = false

config.max_log_items = 500

-- Minimum status-message visibility duration in seconds (clamped to 1..5)
config.message_timeout_min = 1

-- Maximum status-message visibility duration in seconds (clamped to 1..5)
config.message_timeout_max = 5

-- Message length floor for timeout scaling; <= this uses min timeout
config.message_timeout_min_chars = 15

-- Message length cap for timeout scaling; >= this uses max timeout
config.message_timeout_max_chars = 80

-- Delay in seconds before status-item tooltips appear on hover
config.status_tooltip_delay = 0.5

-- Grace period in seconds before a visible tooltip is hidden after hover leaves
config.tooltip_hide_grace = 0.2

-- Legacy pixel-based wheel delta (used when line-based mode is not available)
config.mouse_wheel_scroll = 50 * SCALE

-- Optional line-based wheel delta; when set, uses N * line_height per notch
config.mouse_wheel_scroll_lines = nil

-- Fraction of the full vertical range used by one fast-scroll step
config.fastscroll_step_fraction = 0.05

-- Enable cache for generated zoomed code-font handles
config.zoom_cache_scaled_fonts = true

-- Max number of cached zoomed font entries kept alive at once
config.zoom_cache_scaled_fonts_max = 2

-- Max total cache bytes for zoomed fonts, 0 means unlimited
config.zoom_cache_scaled_fonts_max_bytes = 400 * 1024 * 1024

-- Debounce delay for repeated zoom input in milliseconds
config.zoom_debounce_ms = 40

-- Max visible delay while repeated zoom input is active in milliseconds
config.zoom_debounce_max_wait_ms = 20

-- Absolute content zoom levels in percent used for deterministic stepping
config.zoom_levels = {
	25,
	40,
	60,
	75,
	90,
	100,
	115,
	125,
	150,
	175,
	200,
	250,
	300,
	350,
	400,
	500,
	600,
	700,
	800,
	900,
	1000,
}

--for percent = 25, 1000, 25 do
--	config.zoom_levels[#config.zoom_levels + 1] = percent
--end

table.sort(config.zoom_levels)

-- Status-bar format for the visible document zoom value
config.zoom_status_format = "%.0f%%"

config.file_size_limit = 10
config.ignore_files = "^%."
config.symbol_pattern = "[%a_][%w_]*"

-- Primary word divider set (whitespace is handled separately by navigation)
config.word_dividers = [[~!%^&*()+|{}:"<>?`-=\[];',./]]
config.undo_merge_timeout = 0.3

-- Wrap selected text when its syntax defines the typed character as a surrounding pair
config.auto_surround = false

-- Choose what limited pairs do at maximum repeats: 'stop', 'cycle', or 'unwrap'
config.auto_surround_behavior = "unwrap"

-- Keep built-in text formatting shortcuts opt-in
config.format_shortcuts = false

-- Default debounce (seconds) for project-wide line-change subscribers
config.line_change_hook_delay = 0.15
config.max_undos = 10000
config.highlight_current_line = true

-- Highlight matches of the word under the cursor
config.highlight_word_under_cursor = true

-- Highlight matches of the current selection
config.highlight_selection_matches = false

-- Draw boxes around selection match candidates
config.highlight_selection_boxes = false
config.line_height = 1.05

-- Cursor blink period in seconds for doc views (0: off)
config.cursor_blink_period = 1.0

-- Enable multi-cursor commands, shortcuts, and mouse gestures
config.enable_multi_cursor = true

-- Modifier used with left-click to add or remove cursors: 'alt', 'ctrl', or 'cmd'
config.multi_cursor_modifier = "alt"

-- Indentation width for the shared text grid
config.indent_size = 4

-- Ordered sizes used when cycling the active document's indentation width
config.indent_size_cycle = { 2, 4, 8 }

-- Indentation characters inserted by Tab: 'spaces' or 'tabs'
config.indent_type = "spaces"
config.line_limit = 120

-- Title used for unsaved docs without an explicit filename
config.default_doc_title = "untitled"

-- Default options used by Doc.create and core:new-doc
config.new_doc_default_options = {
	name = nil,
	format = nil,
	indent_size = nil,
	encoding = "utf8",
	codepage = "none",
	newline = "lf",
}

-- Default options used when opening existing files
config.open_doc_default_options = {
	encoding = "auto",
	codepage = "auto",
}

-- Opening bytes supplied to format and automatic codepage detection
config.format_detection_sample_size = 4096

-- General mode defaults used when an open request and its format make no choice
config.default_modes = {
	default = "edit",	-- Final fallback when no better default exists
	text = "edit",		-- Generic text documents remain editable
	binary = "view",		-- Generic binary documents use a read-only handler
	image = "view",		-- Images use a read-only handler
	document = "view",	-- Container-backed documents stay read-only unless their format says otherwise
}

-- User mode choices keyed by detected format name, such as 'md'
config.format_modes = {}

-- User handler choices keyed by detected format name, such as 'als'
config.format_handlers = {}

-- Case-insensitive extension interpretations without a leading dot
config.extension_overrides = {}

-- Case-insensitive exact filename interpretations without a path
config.filename_overrides = {}

-- Used only when automatic codepage detection finds non-binary invalid UTF-8 and no syntax-specific codepage
config.fallback_codepage = "cp1252"

-- Monitor open docs for external on-disk changes
config.doc_monitor_enabled = true

-- Polling interval in seconds for the active document
config.doc_monitor_active_interval = 1.0

-- Polling interval in seconds for passive documents
config.doc_monitor_passive_interval = 2.0

-- Show reload prompt when stale document becomes active
config.doc_monitor_prompt_on_focus = true

-- Show notices for changed passive documents
config.doc_monitor_notify_passive = true

-- Auto-create a new doc when startup would otherwise show only the empty root view
config.new_doc_auto_create_on_startup = false

-- Missing file open behavior: "log" | "message" | "new"
config.missing_file_open_behavior = "message"

-- Vertical rulers (character columns); nil/{} disables ruler drawing
config.rulers = {}

-- Vertical viewport anchor for line jumps (0=top, 0.5=center, 1=bottom)
config.scroll_to_line_vertical_position = 1 / 4

-- Source position used when switching from an editor to a read-only view: "view" or "cursor"
config.toggle_edit_source_position = "view"

-- Animate page scrolling in the text editor, text viewer, and binary viewer
config.animate_page_scroll = true

-- Animate scrolling to top/bottom edges in the text editor, text viewer, and binary viewer
config.animate_vertical_edge_scroll = false

-- Preserve cursor x position across vertical movement until x changes
config.persistent_cursor_col = true

-- Highlight EOL markers: "all" or "trailing"
config.highlight_eol = "trailing"

-- Shared threshold for long-line guards in rendering/plugins
config.long_line_threshold = 5000

-- Separate syntax-tokenization threshold (can be higher than shared threshold)
config.long_line_syntax_line_length = 10000

-- Syntax state checkpoint spacing in lines for faster far-line resume
config.syntax_state_checkpoint_interval = 200

-- Maximum lines to tokenize synchronously from checkpoint during on-demand draw
config.syntax_state_sync_max_lines = 32

-- Background syntax worker per-frame budget in milliseconds
config.syntax_worker_budget_ms = 0.8

-- Hard cap of lines processed by syntax worker per frame
config.syntax_worker_max_lines_per_frame = 60

-- Visible-priority syntax worker per-frame budget in milliseconds
config.syntax_worker_priority_budget_ms = 3.0

-- Hard cap of visible-priority lines processed by syntax worker per frame
config.syntax_worker_priority_max_lines_per_frame = 160

-- Lines to start before visible-priority target when rebasing after jumps
config.syntax_worker_priority_backtrack_lines = 5

-- Canonical syntax replay requested ahead from first invalid line
config.syntax_worker_linear_ahead_lines = 120

-- Horizontal autoscroll left trigger ratio (0..1)
config.hscroll_left_margin_ratio = 0.1

-- Horizontal autoscroll right trigger ratio (0..1)
config.hscroll_right_margin_ratio = 0.9

-- Outline navigation wraps between first/last points when true
config.outline_wrap_around = false

-- Enable transient line flash overlays (shared by outline, plugins, etc.)
config.line_flash = true

-- Shared line flash duration in seconds
config.line_flash_duration = 0.16

-- Shared line flash peak opacity (0..1)
config.line_flash_opacity = 0.35

-- Flash jumped-to line for outline navigation
config.outline_jump_flash = true

-- Legacy alias for line flash duration (used as fallback when line_flash_duration is nil)
config.outline_jump_flash_duration = 0.16

-- Legacy alias for line flash opacity (used as fallback when line_flash_opacity is nil)
config.outline_jump_flash_opacity = 0.35

-- When true, flash only for outline boundary errors (no success flash)
config.outline_jump_flash_only_error = true

-- Animate viewport movement for outline jumps
config.outline_jump_animated_scroll = true

-- When true, Escape clears non-empty Find and Replace text before closing
config.find_escape_clears_text = false

-- When true, closing Find or Replace restores the selection from before it opened
config.find_restore_position_on_exit = false

-- Initial image zoom: 'actual', 'fit', 'fit_width', or 'fit_height'
config.image_viewer_initial_zoom = "fit"

-- Fit scaling direction: 'reduce', 'enlarge', or 'both'
config.image_viewer_fit_resize = "reduce"

-- Optional vector override; nil falls back to 'image_viewer_fit_resize'
config.image_viewer_fit_resize_vector = "both"

-- Mouse zoom follows the 'mouse' position or the viewport 'center'; keyboard zoom stays centered
config.image_viewer_zoom_anchor = "mouse"

-- Return to the initial zoom mode when an open image is reloaded
config.image_viewer_reset_zoom_on_reload = false

-- Transparent areas use 'checkerboard', 'theme', or a color table across previews
config.transparent_background = "checkerboard"

-- Session default mode on first open: 'hex' or 'symbols'
config.binary_viewer_default_mode = "hex"

-- Hex bytes-per-row can be a number or 'auto'
config.binary_viewer_hex_bytes_per_row = "auto"

-- Allowed values used by 'auto' width fitting
config.binary_viewer_hex_bytes_per_row_allowed = {
	4, 8, 16, 24, 32,
	40, 48, 56, 64, 72,
	80, 88, 96, 104, 112,
	120, 128, 136, 144, 152,
	160, 168, 176, 184, 192,
	200, 208, 216, 224, 232,
	240, 248, 256,
}
-- Lower bound for symbol mode row width
config.binary_viewer_symbols_min_bytes_per_row = 48

-- Group size used for visual separators
config.binary_viewer_group_bytes = 8

-- Offset prefix visibility per mode
config.binary_viewer_show_offset_hex = true
config.binary_viewer_show_offset_binary = false

-- Separator visibility controls
config.binary_viewer_hex_separator = true
config.binary_viewer_char_separator = false

-- Symbol shown for 0x00 when rendering binary character cells
config.binary_viewer_nul_symbol = '.'

-- Character mapping mode: 'printable' | 'full'
config.binary_viewer_char_mode = "full"

-- Codepage table name in data/cp/<name>.lua
config.binary_viewer_codepage = "cp437"

-- Number of off-screen rows to prefetch around visible range
config.binary_viewer_prefetch_rows = 80

-- Top ruler visibility
config.binary_viewer_show_ruler = true

-- Smooth lerp scroll toggle
config.binary_viewer_smooth_scroll = true

-- Fraction of the binary file covered by one fast-scroll step
config.binary_viewer_fastscroll_step_fraction = 0.02

-- Dim zero byte text overlay toggle
config.binary_viewer_dim_nul_bytes = true

return config
