#!/usr/bin/lua -- Copyright 2007-2022 Mitchell. See LICENSE. -- This script generates the "Info.plist" file for the macOS App bundle. local lang, exts local languages, extensions = {}, {} -- Read languages and extensions. local f = io.open('../modules/textadept/file_types.lua') local types = f:read('*a'):match('M.extensions = (%b{})'):sub(2) f:close() for type in types:gmatch('(.-)[%],}]+') do if type:find('^%-%-') then lang, exts = type:match('([^%[]+)$'), {} if lang then languages[#languages + 1], extensions[lang] = lang, exts end else exts[#exts + 1] = type:match('^%[?\'?([^\'=]+)') end end -- LuaFormatter off -- Generate and write the XML. local xml = {[[ CFBundleDevelopmentRegion English CFBundleDocumentTypes]]} xml[#xml + 1] = [[ CFBundleTypeName Textadept document CFBundleTypeRole Editor LSItemContentTypes com.apple.property-list com.apple.applescript.text com.apple.xcode.commands com.apple.xcode.csh-script com.apple.xcode.ksh-script com.apple.xcode.lex-source com.apple.xcode.make-script com.apple.xcode.mig-source com.apple.xcode.tcsh-script com.apple.xcode.yacc-source com.apple.xcode.zsh-script com.apple.xml-property-list com.netscape.javascript-source com.sun.java-source]] -- LuaFormatter on for i = 1, #languages do lang, exts = languages[i], extensions[languages[i]] if #exts > 0 then xml[#xml + 1] = "\t\t\t\tcom.textadept." .. lang:gsub(' ', '-') .. "-source" end end -- LuaFormatter off xml[#xml + 1] = [[ net.daringfireball.markdown public.c-header public.c-plus-plus-header public.c-plus-plus-source public.c-source public.csh-script public.css public.html public.lex-source public.mig-source public.objective-c-plus-plus-source public.objective-c-source public.perl-script public.php-script public.plain-text public.python-script public.rtf public.ruby-script public.script public.shell-script public.source-code public.text public.utf16-external-plain-text public.utf16-plain-text public.utf8-plain-text public.xml CFBundleTypeName Anything CFBundleTypeRole Viewer LSItemContentTypes public.data public.text UTImportedTypeDeclarations ]] -- LuaFormatter on for i = 1, #languages do lang, exts = languages[i], extensions[languages[i]] if #exts > 0 then xml[#xml + 1] = "\t\t" xml[#xml + 1] = "\t\t\tUTTypeTagSpecification" xml[#xml + 1] = "\t\t\t" xml[#xml + 1] = "\t\t\t\tpublic.filename-extension" xml[#xml + 1] = "\t\t\t\t" for j = 1, #exts do xml[#xml + 1] = "\t\t\t\t\t" .. exts[j] .. "" end xml[#xml + 1] = "\t\t\t\t" xml[#xml + 1] = "\t\t\t" xml[#xml + 1] = "\t\t\tUTTypeDescription" xml[#xml + 1] = "\t\t\t" .. lang .. " source" xml[#xml + 1] = "\t\t\tUTTypeIdentifier" xml[#xml + 1] = "\t\t\tcom.textadept." .. lang:gsub(' ', '-') .. "-source" xml[#xml + 1] = "\t\t\tUTTypeConformsTo" xml[#xml + 1] = "\t\t\t" xml[#xml + 1] = "\t\t\t\tpublic.source-code" xml[#xml + 1] = "\t\t\t" xml[#xml + 1] = "\t\t" end end -- LuaFormatter off xml[#xml + 1] = [[ CFBundleExecutable textadept_osx CFBundleIconFile textadept.icns CFBundleIdentifier com.textadept CFBundleInfoDictionaryVersion 6.0 CFBundleName Textadept CFBundlePackageType APPL CFBundleSignature ???? CFBundleVersion 9.5beta CFBundleShortVersionString 9.5 beta NSHighResolutionCapable ]] -- LuaFormatter on f = io.open('../src/Info.plist', 'w') f:write(table.concat(xml, '\n')) f:close()