comparison src/luan_editor/window.luan @ 52:3f4c3722b78b

.luan_editor dir
author Franklin Schmidt <fschmidt@gmail.com>
date Sat, 24 May 2025 16:25:55 -0600
parents c17c5312e8de
children d5681da8ece8
comparison
equal deleted inserted replaced
51:32631fdbbdf1 52:3f4c3722b78b
1 local Luan = require "luan:Luan.luan" 1 local Luan = require "luan:Luan.luan"
2 local error = Luan.error 2 local error = Luan.error
3 local stringify = Luan.stringify or error() 3 local stringify = Luan.stringify or error()
4 local Parsers = require "luan:Parsers.luan"
5 local json_string = Parsers.json_string or error()
6 local json_parse = Parsers.json_parse or error()
4 local Math = require "luan:Math.luan" 7 local Math = require "luan:Math.luan"
5 local min = Math.min or error() 8 local min = Math.min or error()
6 local String = require "luan:String.luan" 9 local String = require "luan:String.luan"
7 local sub_string = String.sub or error() 10 local sub_string = String.sub or error()
8 local replace = String.replace or error() 11 local replace = String.replace or error()
42 else 45 else
43 return default 46 return default
44 end 47 end
45 end 48 end
46 49
47 local config_file = Io.uri("file:"..Swing.home_dir.."/.luan_editor") 50 local config_file = Io.uri("file:"..Swing.home_dir.."/.luan_editor/config.json")
48 local config = {} 51 local config = {}
49 if config_file.exists() then 52 if config_file.exists() then
50 try 53 try
51 config = Luan.parse(config_file.read_text()) 54 config = json_parse(config_file.read_text())
52 catch e 55 catch e
53 logger.error(e) 56 logger.error(e)
54 end 57 end
55 end 58 end
56 config.size = config.size or { width=700, height=700 } 59 config.size = config.size or { width=700, height=700 }
59 config.tab_size = config.tab_size or 4 62 config.tab_size = config.tab_size or 4
60 config.list_window = config.list_window or {} 63 config.list_window = config.list_window or {}
61 config.list_window.size = config.list_window.size or { width=200, height=400 } 64 config.list_window.size = config.list_window.size or { width=200, height=400 }
62 65
63 local function save_config() 66 local function save_config()
64 config_file.write_text( stringify(config).."\n" ) 67 config_file.write_text( json_string(config).."\n" )
65 end 68 end
66 69
67 local list_view = new_list{ 70 local list_view = new_list{
68 --layout = new_mig_layout("insets 0,wrap,fill") 71 --layout = new_mig_layout("insets 0,wrap,fill")
69 --layout = new_mig_layout("wrap","[grow]") 72 --layout = new_mig_layout("wrap","[grow]")