From 392e7c7a5fbb5fe33c0e6ecb2130d42fcb601b1e Mon Sep 17 00:00:00 2001 From: akiyosi Date: Wed, 5 Jun 2024 23:55:03 +0900 Subject: [PATCH] Add ability to open files from Finder in macOS --- .gitignore | 2 + cmd/goneovim/darwin/Contents/Info.plist | 2450 ++++++++++++++++++++++- editor/editor.go | 38 +- editor/editor_darwin.go | 27 +- editor/editor_unix.go | 5 + editor/editor_windows.go | 5 + editor/workspace.go | 8 +- generate_objcbridge.go | 73 + goneovim.go | 1 + 9 files changed, 2541 insertions(+), 68 deletions(-) create mode 100644 generate_objcbridge.go diff --git a/.gitignore b/.gitignore index 6088761c..d4e7a539 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,8 @@ debug.log tags* moc* editor/version.txt +editor/objcbridge.h +editor/objcbridge.m cmd/goneovim/goneovim cmd/goneovim/debug cmd/goneovim/deploy/* diff --git a/cmd/goneovim/darwin/Contents/Info.plist b/cmd/goneovim/darwin/Contents/Info.plist index 43c8c200..ade41695 100644 --- a/cmd/goneovim/darwin/Contents/Info.plist +++ b/cmd/goneovim/darwin/Contents/Info.plist @@ -2,46 +2,2414 @@ - NSPrincipalClass - NSApplication - CFBundleIconFile - goneovim.icns - CFBundleName - goneovim - CFBundlePackageType - APPL - CFBundleSignature - ???? - CFBundleExecutable - goneovim - CFBundleDocumentTypes - - - LSItemContentTypes - - public.text - - CFBundleTypeRole - Editor - - - CFBundleTypeExtensions - - go - - CFBundleTypeName - Go source - CFBundleTypeRole - Editor - CFBundleTypeIconFile - goneovim.icns - - - CFBundleIdentifier - com.ident.goneovim - CFBundleGetInfoString - Created by Qt/QMake - NOTE - This file was generated by Qt/QMake. + CFBundleName + goneovim + CFBundleDisplayName + goneovim + CFBundleIdentifier + com.goneovim.goneovim + CFBundleExecutable + goneovim + CFBundleIconFile + goneovim.icns + CFBundlePackageType + APPL + LSApplicationCategoryType + public.app-category.developer-tools + NSHighResolutionCapable + + CFBundleDocumentTypes + + + CFBundleTypeExtensions + + vim + + CFBundleTypeName + Vim Script File + CFBundleTypeRole + Editor + + + CFBundleTypeExtensions + + txt + text + utf8 + + CFBundleTypeMIMETypes + + text/plain + + CFBundleTypeName + Plain Text File + CFBundleTypeRole + Editor + + + CFBundleTypeExtensions + + tex + sty + cls + ltx + ins + dtx + + CFBundleTypeName + TeX File + CFBundleTypeRole + Editor + + + CFBundleTypeExtensions + + h + + CFBundleTypeName + C Header Source File + CFBundleTypeRole + Editor + LSItemContentTypes + + public.c-header + + + + CFBundleTypeExtensions + + pch + + CFBundleTypeName + C Precompiled Header Source File + CFBundleTypeRole + Editor + LSItemContentTypes + + public.precompiled-c-header + + + + CFBundleTypeExtensions + + hh + hp + hpp + hxx + h++ + + CFBundleTypeName + C++ Header Source File + CFBundleTypeRole + Editor + + + CFBundleTypeExtensions + + pch++ + + CFBundleTypeName + C++ Precompiled Header Source File + CFBundleTypeRole + Editor + LSItemContentTypes + + public.precompiled-c-plus-plus-header + + + + CFBundleTypeExtensions + + c + + CFBundleTypeName + C Source File + CFBundleTypeRole + Editor + LSItemContentTypes + + public.c-source + + + + CFBundleTypeExtensions + + m + + CFBundleTypeName + Objective-C Source File + CFBundleTypeRole + Editor + LSItemContentTypes + + public.objective-c-source + + + + CFBundleTypeExtensions + + mm + + CFBundleTypeName + Objective-C++ Source File + CFBundleTypeRole + Editor + LSItemContentTypes + + public.objective-c-plus-plus-source + + + + CFBundleTypeExtensions + + cc + cp + cpp + cxx + c++ + + CFBundleTypeName + C++ Source File + CFBundleTypeRole + Editor + LSItemContentTypes + + public.c-plus-plus-source + + + + CFBundleTypeExtensions + + s + asm + + CFBundleTypeName + Assembly Source File + CFBundleTypeRole + Editor + LSItemContentTypes + + public.assembler-source + + + + CFBundleTypeExtensions + + r + + CFBundleTypeName + Rez Source File + CFBundleTypeRole + Editor + LSItemContentTypes + + public.rez-source + + + + CFBundleTypeExtensions + + java + jav + + CFBundleTypeName + Java Source File + CFBundleTypeRole + Editor + LSItemContentTypes + + com.sun.java-source + + + + CFBundleTypeExtensions + + l + lm + lmm + lpp + lxx + + CFBundleTypeName + Lex Source File + CFBundleTypeRole + Editor + LSItemContentTypes + + public.lex-source + + + + CFBundleTypeExtensions + + y + ym + ymm + ypp + yxx + + CFBundleTypeName + Yacc Source File + CFBundleTypeRole + Editor + LSItemContentTypes + + public.yacc-source + + + + CFBundleTypeExtensions + + defs + + CFBundleTypeName + Mig Definition File + CFBundleTypeRole + Editor + + + CFBundleTypeExtensions + + exp + + CFBundleTypeName + Symbol Export File + CFBundleTypeRole + Editor + LSItemContentTypes + + public.symbol-export + + + + CFBundleTypeExtensions + + f + for + fpp + f77 + f90 + f95 + + CFBundleTypeName + Fortran Source File + CFBundleTypeRole + Editor + LSItemContentTypes + + public.fortran-source + + + + CFBundleTypeExtensions + + pas + + CFBundleTypeName + Pascal Source File + CFBundleTypeRole + Editor + LSItemContentTypes + + public.pascal-source + + + + CFBundleTypeExtensions + + ada + adb + ads + + CFBundleTypeName + Ada Source File + CFBundleTypeRole + Editor + LSItemContentTypes + + public.ada-source + + + + CFBundleTypeExtensions + + html + phtml + shtml + xhtml + htm + pht + sht + xht + phtm + shtm + xhtm + + CFBundleTypeMIMETypes + + text/html + + CFBundleTypeName + HTML Source File + CFBundleTypeRole + Editor + LSItemContentTypes + + public.html + + + + CFBundleTypeExtensions + + xml + rss + tld + pt + cpt + dtml + + CFBundleTypeMIMETypes + + text/xml + + CFBundleTypeName + XML Source File + CFBundleTypeRole + Editor + LSItemContentTypes + + public.xml + + + + CFBundleTypeExtensions + + js + htc + jscript + javascript + + CFBundleTypeMIMETypes + + text/javascript + + CFBundleTypeName + JavaScript Source File + CFBundleTypeRole + Editor + LSItemContentTypes + + com.netscape.javascript-source + + + + CFBundleTypeExtensions + + pl + pm + pod + perl + + CFBundleTypeMIMETypes + + text/x-perl-script + + CFBundleTypeName + Perl Source File + CFBundleTypeRole + Editor + LSItemContentTypes + + public.perl-script + + + + CFBundleTypeExtensions + + py + rpy + cpy + python + + CFBundleTypeMIMETypes + + text/x-python-script + + CFBundleTypeName + Python Source File + CFBundleTypeRole + Editor + LSItemContentTypes + + public.python-script + + + + CFBundleTypeExtensions + + php + php3 + php4 + php5 + ph3 + ph4 + phtml + + CFBundleTypeMIMETypes + + text/php + + CFBundleTypeName + PHP Source File + CFBundleTypeRole + Editor + LSItemContentTypes + + public.php-script + + + + CFBundleTypeExtensions + + rb + rbw + rbx + rjs + rxml + + CFBundleTypeMIMETypes + + text/ruby-script + + CFBundleTypeName + Ruby Source File + CFBundleTypeRole + Editor + LSItemContentTypes + + public.ruby-script + + + + CFBundleTypeExtensions + + sh + csh + command + ss + bashrc + bash_profile + bash_login + profile + bash_logout + + CFBundleTypeName + Shell script + CFBundleTypeRole + Editor + LSItemContentTypes + + public.shell-script + + + + CFBundleTypeExtensions + + class + + CFBundleTypeName + Java Class File + CFBundleTypeRole + Viewer + LSItemContentTypes + + com.sun.java-class + + + + CFBundleTypeExtensions + + patch + diff + + CFBundleTypeName + Patch File + CFBundleTypeRole + Editor + + + CFBundleTypeExtensions + + strings + + CFBundleTypeName + Strings File + CFBundleTypeRole + Editor + LSItemContentTypes + + public.strings-text + + + + CFBundleTypeExtensions + + * + + CFBundleTypeName + Text File + CFBundleTypeOSTypes + + **** + + CFBundleTypeRole + Editor + + + CFBundleTypeExtensions + + applescript + + CFBundleTypeName + AppleScript Source File + CFBundleTypeRole + Editor + LSItemContentTypes + + com.apple.applescript.text + + + + CFBundleTypeExtensions + + as + + CFBundleTypeName + ActionScript Source File + CFBundleTypeRole + Editor + + + CFBundleTypeExtensions + + asp + asa + + CFBundleTypeName + ASP document + CFBundleTypeRole + Editor + + + CFBundleTypeExtensions + + aspx + ascx + asmx + ashx + + CFBundleTypeName + ASP.NET document + CFBundleTypeRole + Editor + + + CFBundleTypeExtensions + + bib + + CFBundleTypeName + BibTeX bibliography + CFBundleTypeRole + Editor + + + CFBundleTypeExtensions + + cs + + CFBundleTypeName + C# Source File + CFBundleTypeRole + Editor + + + CFBundleTypeExtensions + + cfdg + + CFBundleTypeName + Context Free Design Grammar + CFBundleTypeRole + Editor + + + CFBundleTypeExtensions + + csv + + CFBundleTypeName + Comma separated values + CFBundleTypeRole + Editor + + + CFBundleTypeExtensions + + tsv + + CFBundleTypeName + Tab separated values + CFBundleTypeRole + Editor + + + CFBundleTypeExtensions + + cgi + fcgi + + CFBundleTypeName + CGI script + CFBundleTypeRole + Editor + + + CFBundleTypeExtensions + + cfg + conf + config + htaccess + + CFBundleTypeName + Configuration file + CFBundleTypeRole + Editor + + + CFBundleTypeExtensions + + css + + CFBundleTypeName + Cascading style sheet + CFBundleTypeRole + Editor + + + CFBundleTypeExtensions + + dtd + + CFBundleTypeName + Document Type Definition + CFBundleTypeRole + Editor + + + CFBundleTypeExtensions + + dylan + + CFBundleTypeName + Dylan Source File + CFBundleTypeRole + Editor + + + CFBundleTypeExtensions + + erl + hrl + + CFBundleTypeName + Erlang Source File + CFBundleTypeRole + Editor + + + CFBundleTypeExtensions + + fscript + + CFBundleTypeName + F-Script Source File + CFBundleTypeRole + Editor + + + CFBundleTypeExtensions + + hs + lhs + + CFBundleTypeName + Haskell Source File + CFBundleTypeRole + Editor + + + CFBundleTypeExtensions + + inc + + CFBundleTypeName + Include file + CFBundleTypeRole + Editor + + + CFBundleTypeExtensions + + ics + + CFBundleTypeName + iCalendar schedule + CFBundleTypeRole + Editor + + + CFBundleTypeExtensions + + ini + + CFBundleTypeName + MS Windows initialization file + CFBundleTypeRole + Editor + + + CFBundleTypeExtensions + + io + + CFBundleTypeName + Io Source File + CFBundleTypeRole + Editor + + + CFBundleTypeExtensions + + bsh + + CFBundleTypeName + BeanShell script + CFBundleTypeRole + Editor + + + CFBundleTypeExtensions + + properties + + CFBundleTypeName + Java properties file + CFBundleTypeRole + Editor + + + CFBundleTypeExtensions + + jsp + + CFBundleTypeName + Java Server Page + CFBundleTypeRole + Editor + + + CFBundleTypeExtensions + + lisp + cl + l + lsp + mud + el + + CFBundleTypeName + LISP Source File + CFBundleTypeRole + Editor + + + CFBundleTypeExtensions + + log + + CFBundleTypeName + Log file + CFBundleTypeRole + Editor + + + CFBundleTypeExtensions + + wiki + wikipedia + mediawiki + + CFBundleTypeName + Mediawiki document + CFBundleTypeRole + Editor + + + CFBundleTypeExtensions + + ps + eps + + CFBundleTypeName + PostScript Source File + CFBundleTypeRole + Editor + + + CFBundleTypeExtensions + + scm + sch + + CFBundleTypeName + Scheme Source File + CFBundleTypeRole + Editor + + + CFBundleTypeExtensions + + sql + + CFBundleTypeName + SQL Source File + CFBundleTypeRole + Editor + + + CFBundleTypeExtensions + + tcl + + CFBundleTypeName + Tcl Source File + CFBundleTypeRole + Editor + + + CFBundleTypeExtensions + + xsl + xslt + + CFBundleTypeName + XSL stylesheet + CFBundleTypeRole + Editor + + + CFBundleTypeExtensions + + vcf + vcard + + CFBundleTypeName + Electronic business card + CFBundleTypeRole + Editor + + + CFBundleTypeExtensions + + vb + + CFBundleTypeName + Visual Basic Source File + CFBundleTypeRole + Editor + + + CFBundleTypeExtensions + + yaml + yml + + CFBundleTypeName + YAML document + CFBundleTypeRole + Editor + + + CFBundleTypeExtensions + + gtd + gtdlog + + CFBundleTypeName + GTD document + CFBundleTypeRole + Editor + + + CFBundleTypeExtensions + + markdown + markd + mdown + md + + CFBundleTypeName + Markdown document + CFBundleTypeRole + Editor + + + CFBundleTypeExtensions + + rst + + CFBundleTypeName + reStructuredText document + CFBundleTypeRole + Editor + + + CFBundleTypeExtensions + + vba + + CFBundleTypeName + Vimball Archive + CFBundleTypeRole + Editor + + + CFBundleTypeExtensions + + vhd + vhdl + + CFBundleTypeName + VHDL Source File + CFBundleTypeRole + Editor + + + CFBundleTypeExtensions + + lua + + CFBundleTypeMIMETypes + + text/x-lua-script + + CFBundleTypeName + Lua Source File + CFBundleTypeRole + Editor + + + CFBundleTypeExtensions + + v + + CFBundleTypeName + Verilog HDL Source File + CFBundleTypeRole + Editor + + + CFBundleTypeExtensions + + vh + + CFBundleTypeName + Verilog HDL Header Source File + CFBundleTypeRole + Editor + + + UTExportedTypeDeclarations + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + Vim Script File + UTTypeIdentifier + org.vim.vim-script + UTTypeTagSpecification + + public.filename-extension + + vim + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + Plain Text File + UTTypeIdentifier + public.plain-text + UTTypeTagSpecification + + public.filename-extension + + txt + text + utf8 + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + TeX File + UTTypeIdentifier + org.vim.tex-file + UTTypeTagSpecification + + public.filename-extension + + tex + sty + cls + ltx + ins + dtx + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + C Header Source File + UTTypeIdentifier + public.c-header + UTTypeTagSpecification + + public.filename-extension + + h + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + C Precompiled Header Source File + UTTypeIdentifier + org.vim.pch-file + UTTypeTagSpecification + + public.filename-extension + + pch + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + C++ Header Source File + UTTypeIdentifier + public.c-plus-plus-header + UTTypeTagSpecification + + public.filename-extension + + hh + hp + hpp + hxx + h++ + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + C++ Precompiled Header Source File + UTTypeIdentifier + org.vim.pch++-file + UTTypeTagSpecification + + public.filename-extension + + pch++ + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + C Source File + UTTypeIdentifier + public.c-source + UTTypeTagSpecification + + public.filename-extension + + c + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + Objective-C Source File + UTTypeIdentifier + public.objective-c-source + UTTypeTagSpecification + + public.filename-extension + + m + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + Objective-C++ Source File + UTTypeIdentifier + public.objective-c-plus-plus-source + UTTypeTagSpecification + + public.filename-extension + + mm + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + C++ Source File + UTTypeIdentifier + public.c-plus-plus-source + UTTypeTagSpecification + + public.filename-extension + + cc + cp + cpp + cxx + c++ + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + Assembly Source File + UTTypeIdentifier + public.assembly-source + UTTypeTagSpecification + + public.filename-extension + + s + asm + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + Rez Source File + UTTypeIdentifier + com.apple.rez-source + UTTypeTagSpecification + + public.filename-extension + + r + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + Java Source File + UTTypeIdentifier + com.sun.java-source + UTTypeTagSpecification + + public.filename-extension + + java + jav + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + Lex Source File + UTTypeIdentifier + com.apple.xcode.lex-source + UTTypeTagSpecification + + public.filename-extension + + l + lm + lmm + lpp + lxx + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + Yacc Source File + UTTypeIdentifier + com.apple.xcode.yacc-source + UTTypeTagSpecification + + public.filename-extension + + y + ym + ymm + ypp + yxx + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + Mig Definition File + UTTypeIdentifier + public.mig-source + UTTypeTagSpecification + + public.filename-extension + + defs + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + Symbol Export File + UTTypeIdentifier + com.apple.symbol-export + UTTypeTagSpecification + + public.filename-extension + + exp + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + Fortran Source File + UTTypeIdentifier + com.apple.xcode.fortran-source + UTTypeTagSpecification + + public.filename-extension + + f + for + fpp + f77 + f90 + f95 + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + Pascal Source file + UTTypeIdentifier + com.apple.xcode.pascal-source + UTTypeTagSpecification + + public.filename-extension + + pas + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + Ada Source File + UTTypeIdentifier + com.apple.xcode.ada-source + UTTypeTagSpecification + + public.filename-extension + + ada + adb + ads + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + HTML Source File + UTTypeIdentifier + public.html + UTTypeTagSpecification + + public.filename-extension + + html + phtml + shtml + xhtml + htm + pht + sht + xht + phtm + shtm + xhtm + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + XML Source File + UTTypeIdentifier + public.xml + UTTypeTagSpecification + + public.filename-extension + + xml + rss + tld + pt + cpt + dtml + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + JavaScript Source File + UTTypeIdentifier + com.netscape.javascript-source + UTTypeTagSpecification + + public.filename-extension + + js + htc + jscript + javascript + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + Perl Source File + UTTypeIdentifier + public.perl-script + UTTypeTagSpecification + + public.filename-extension + + pl + pm + pod + perl + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + Python Source File + UTTypeIdentifier + public.python-script + UTTypeTagSpecification + + public.filename-extension + + py + rpy + cpy + python + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + PHP Source File + UTTypeIdentifier + public.php-script + UTTypeTagSpecification + + public.filename-extension + + php + php3 + php4 + php5 + ph3 + ph4 + phtml + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + Ruby Source File + UTTypeIdentifier + public.ruby-script + UTTypeTagSpecification + + public.filename-extension + + rb + rbw + rbx + rjs + rxml + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + Shell script + UTTypeIdentifier + public.shell-script + UTTypeTagSpecification + + public.filename-extension + + sh + csh + command + ss + bashrc + bash_profile + bash_login + profile + bash_logout + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + Java Class File + UTTypeIdentifier + com.sun.java-class + UTTypeTagSpecification + + public.filename-extension + + class + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + Patch File + UTTypeIdentifier + org.vim.patch-file + UTTypeTagSpecification + + public.filename-extension + + patch + diff + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + Strings File + UTTypeIdentifier + com.apple.xcode.strings-text + UTTypeTagSpecification + + public.filename-extension + + strings + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + AppleScript Source File + UTTypeIdentifier + com.apple.applescript.text + UTTypeTagSpecification + + public.filename-extension + + applescript + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + ActionScript Source File + UTTypeIdentifier + org.vim.as-file + UTTypeTagSpecification + + public.filename-extension + + as + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + ASP document + UTTypeIdentifier + org.vim.asp-file + UTTypeTagSpecification + + public.filename-extension + + asp + asa + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + ASP.NET document + UTTypeIdentifier + org.vim.aspx-file + UTTypeTagSpecification + + public.filename-extension + + aspx + ascx + asmx + ashx + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + BibTeX bibliography + UTTypeIdentifier + org.vim.bib-file + UTTypeTagSpecification + + public.filename-extension + + bib + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + C# Source File + UTTypeIdentifier + org.vim.cs-file + UTTypeTagSpecification + + public.filename-extension + + cs + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + Context Free Design Grammar + UTTypeIdentifier + org.vim.cfdg-file + UTTypeTagSpecification + + public.filename-extension + + cfdg + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + Comma separated values + UTTypeIdentifier + org.vim.csv-file + UTTypeTagSpecification + + public.filename-extension + + csv + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + Tab separated values + UTTypeIdentifier + org.vim.tsv-file + UTTypeTagSpecification + + public.filename-extension + + tsv + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + CGI script + UTTypeIdentifier + org.vim.cgi-file + UTTypeTagSpecification + + public.filename-extension + + cgi + fcgi + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + Configuration file + UTTypeIdentifier + org.vim.cfg-file + UTTypeTagSpecification + + public.filename-extension + + cfg + conf + config + htaccess + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + Cascading style sheet + UTTypeIdentifier + org.vim.css-file + UTTypeTagSpecification + + public.filename-extension + + css + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + Document Type Definition + UTTypeIdentifier + org.vim.dtd-file + UTTypeTagSpecification + + public.filename-extension + + dtd + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + Dylan Source File + UTTypeIdentifier + org.vim.dylan-file + UTTypeTagSpecification + + public.filename-extension + + dylan + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + Erlang Source File + UTTypeIdentifier + org.vim.erl-file + UTTypeTagSpecification + + public.filename-extension + + erl + hrl + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + F-Script Source File + UTTypeIdentifier + org.vim.fscript-file + UTTypeTagSpecification + + public.filename-extension + + fscript + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + Haskell Source File + UTTypeIdentifier + org.vim.hs-file + UTTypeTagSpecification + + public.filename-extension + + hs + lhs + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + Include file + UTTypeIdentifier + org.vim.inc-file + UTTypeTagSpecification + + public.filename-extension + + inc + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + iCalendar schedule + UTTypeIdentifier + org.vim.ics-file + UTTypeTagSpecification + + public.filename-extension + + ics + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + MS Windows initialization file + UTTypeIdentifier + org.vim.ini-file + UTTypeTagSpecification + + public.filename-extension + + ini + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + Io Source File + UTTypeIdentifier + org.vim.io-file + UTTypeTagSpecification + + public.filename-extension + + io + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + BeanShell script + UTTypeIdentifier + org.vim.bsh-file + UTTypeTagSpecification + + public.filename-extension + + bsh + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + Java properties file + UTTypeIdentifier + org.vim.properties-file + UTTypeTagSpecification + + public.filename-extension + + properties + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + Java Server Page + UTTypeIdentifier + org.vim.jsp-file + UTTypeTagSpecification + + public.filename-extension + + jsp + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + LISP Source File + UTTypeIdentifier + org.vim.lisp-file + UTTypeTagSpecification + + public.filename-extension + + lisp + cl + l + lsp + mud + el + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + Log file + UTTypeIdentifier + org.vim.log-file + UTTypeTagSpecification + + public.filename-extension + + log + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + Mediawiki document + UTTypeIdentifier + org.vim.wiki-file + UTTypeTagSpecification + + public.filename-extension + + wiki + wikipedia + mediawiki + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + PostScript Source File + UTTypeIdentifier + com.adobe.postscript + UTTypeTagSpecification + + public.filename-extension + + ps + eps + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + Scheme Source File + UTTypeIdentifier + org.vim.scm-file + UTTypeTagSpecification + + public.filename-extension + + scm + sch + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + SQL Source File + UTTypeIdentifier + org.vim.sql-file + UTTypeTagSpecification + + public.filename-extension + + sql + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + Tcl Source File + UTTypeIdentifier + org.vim.tcl-file + UTTypeTagSpecification + + public.filename-extension + + tcl + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + XSL stylesheet + UTTypeIdentifier + org.vim.xsl-file + UTTypeTagSpecification + + public.filename-extension + + xsl + xslt + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + Electronic business card + UTTypeIdentifier + public.vcard + UTTypeTagSpecification + + public.filename-extension + + vcf + vcard + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + Visual Basic Source File + UTTypeIdentifier + org.vim.vb-file + UTTypeTagSpecification + + public.filename-extension + + vb + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + YAML document + UTTypeIdentifier + org.vim.yaml-file + UTTypeTagSpecification + + public.filename-extension + + yaml + yml + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + GTD document + UTTypeIdentifier + org.vim.gtd-file + UTTypeTagSpecification + + public.filename-extension + + gtd + gtdlog + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + Markdown document + UTTypeIdentifier + net.daringfireball.markdown + UTTypeTagSpecification + + public.filename-extension + + markdown + markd + mdown + md + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + reStructuredText document + UTTypeIdentifier + org.vim.rst-file + UTTypeTagSpecification + + public.filename-extension + + rst + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + Vimball Archive + UTTypeIdentifier + org.vim.vba-file + UTTypeTagSpecification + + public.filename-extension + + vba + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + VHDL Source File + UTTypeIdentifier + org.vim.vhdl-file + UTTypeTagSpecification + + public.filename-extension + + vhdl + vhd + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + Lua Source File + UTTypeIdentifier + org.lua.lua-source + UTTypeTagSpecification + + public.filename-extension + + lua + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + Verilog HDL Source File + UTTypeIdentifier + org.vim.v-file + UTTypeTagSpecification + + public.filename-extension + + v + + + + + UTTypeConformsTo + + public.plain-text + + UTTypeDescription + Verilog HDL Header Source File + UTTypeIdentifier + org.vim.vh-file + UTTypeTagSpecification + + public.filename-extension + + vh + + + + diff --git a/editor/editor.go b/editor/editor.go index 3f14960c..edc23f5b 100644 --- a/editor/editor.go +++ b/editor/editor.go @@ -112,6 +112,7 @@ type Editor struct { fontCh chan []*Font cbChan chan *string chUiPrepared chan bool + openingFileCh chan string geometryUpdateTimer *time.Timer sysTray *widgets.QSystemTrayIcon side *WorkspaceSide @@ -606,7 +607,33 @@ func (e *Editor) connectAppSignals() { if e.app == nil { return } + if runtime.GOOS == "darwin" { + + e.openingFileCh = make(chan string, 2) + go func() { + for { + openingFile := <-e.openingFileCh + + file, err := os.OpenFile("/Users/akiyosi/debug3.log", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666) + if err != nil { + fmt.Println(err) + + os.Exit(1) + } + log.SetOutput(file) + log.SetFlags(log.LstdFlags | log.Lmicroseconds) + log.Println( + fmt.Sprintf("%07.3f", float64(time.Now().UnixNano()/1000-e.startuptime)/1000), + strings.TrimRight(strings.TrimLeft(fmt.Sprintf("%v", openingFile), "["), "]"), + ) + + e.loadFileInDarwin( + openingFile, + ) + } + }() + e.app.ConnectEvent(func(event *core.QEvent) bool { switch event.Type() { case core.QEvent__FileOpen: @@ -615,8 +642,9 @@ func (e *Editor) connectAppSignals() { return false } fileOpenEvent := gui.NewQFileOpenEventFromPointer(event.Pointer()) - e.macAppArg = fileOpenEvent.File() - e.loadFileInDarwin() + e.loadFileInDarwin( + fileOpenEvent.File(), + ) } return true }) @@ -734,7 +762,7 @@ func (e *Editor) AdjustSizeBasedOnFontmetrics(windowWidth, windowHeight int) { } } -func (e *Editor) loadFileInDarwin() { +func (e *Editor) loadFileInDarwin(file string) { if runtime.GOOS != "darwin" { return } @@ -743,9 +771,9 @@ func (e *Editor) loadFileInDarwin() { isModified := "" isModified, _ = goneovim.CommandOutput("echo &modified") if isModified == "1" { - goneovim.Command(fmt.Sprintf(":tabe %s", e.macAppArg)) + goneovim.Command(fmt.Sprintf(":tabe %s", file)) } else { - goneovim.Command(fmt.Sprintf("%s %s", e.config.Editor.FileOpenCmd, e.macAppArg)) + goneovim.Command(fmt.Sprintf("%s %s", e.config.Editor.FileOpenCmd, file)) } } diff --git a/editor/editor_darwin.go b/editor/editor_darwin.go index d31cbebe..f6a7066b 100644 --- a/editor/editor_darwin.go +++ b/editor/editor_darwin.go @@ -3,28 +3,17 @@ package editor /* #cgo CFLAGS: -x objective-c #cgo LDFLAGS: -framework Cocoa -#import - -@interface MyApplicationDelegate : NSObject -@end - -@implementation MyApplicationDelegate - -- (BOOL)applicationSupportsSecureRestorableState:(NSApplication *)app { - return YES; -} - -@end - -void SetMyApplicationDelegate() { - NSApplication *app = [NSApplication sharedApplication]; - app.delegate = [[MyApplicationDelegate alloc] init]; - [app activateIgnoringOtherApps:YES]; // make application foreground -} - +#include "objcbridge.h" +#include */ import "C" +//export GetOpeningFilepath +func GetOpeningFilepath(str *C.char) { + goStr := C.GoString(str) + editor.openingFileCh <- goStr +} + func setMyApplicationDelegate() { C.SetMyApplicationDelegate() } diff --git a/editor/editor_unix.go b/editor/editor_unix.go index 46933b3c..25635123 100644 --- a/editor/editor_unix.go +++ b/editor/editor_unix.go @@ -3,5 +3,10 @@ package editor +import "C" + +func GetOpeningFilepath(str *C.char) { +} + func setMyApplicationDelegate() { } diff --git a/editor/editor_windows.go b/editor/editor_windows.go index c621366d..e0ac04e4 100644 --- a/editor/editor_windows.go +++ b/editor/editor_windows.go @@ -1,4 +1,9 @@ package editor +import "C" + +func GetOpeningFilepath(str *C.char) { +} + func setMyApplicationDelegate() { } diff --git a/editor/workspace.go b/editor/workspace.go index 0dd2014c..187b57b9 100644 --- a/editor/workspace.go +++ b/editor/workspace.go @@ -1794,10 +1794,12 @@ func (ws *Workspace) scrollMinimap() { func (ws *Workspace) handleGui(updates []interface{}) { event := updates[0].(string) switch event { - case "gonvim_enter": - editor.putLog("vim enter") + case "gonvim_vimenter": + // openingFile := getOpeningFilePath() + // if openingFile != "" { + // go ws.nvim.Command(fmt.Sprintf(":e %s", openingFile)) + // } case "gonvim_uienter": - editor.putLog("ui enter") case "gonvim_resize": width, height := editor.setWindowSize(updates[1].(string)) editor.window.Resize2(width, height) diff --git a/generate_objcbridge.go b/generate_objcbridge.go new file mode 100644 index 00000000..2110cef0 --- /dev/null +++ b/generate_objcbridge.go @@ -0,0 +1,73 @@ +//go:build generate + +package main + +import ( + "fmt" + "os" + "path/filepath" + "runtime" + "text/template" +) + +const objcbridgeH = `void SetMyApplicationDelegate();` + +const objcbridgeM = `#import + +char *cFilename; + +// Forward declaration of the Go function to be called from C +extern void GetOpeningFilepath(char* str); + +@interface MyApplicationDelegate : NSObject +@end + +@implementation MyApplicationDelegate + +- (BOOL)applicationSupportsSecureRestorableState:(NSApplication *)app { + return YES; +} + +- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename { + char *utf8String = [filename UTF8String]; + cFilename = strdup(utf8String); + GetOpeningFilepath(cFilename); + return YES; +} + +@end + +void SetMyApplicationDelegate() { + NSApplication *app = [NSApplication sharedApplication]; + app.delegate = [[MyApplicationDelegate alloc] init]; + [app activateIgnoringOtherApps:YES]; // make application foreground +}` + +func main() { + if runtime.GOOS != "darwin" { + return + } + + generateFile(filepath.Join("editor", "objcbridge.h"), objcbridgeH) + generateFile(filepath.Join("editor", "objcbridge.m"), objcbridgeM) +} + +func generateFile(filename, content string) { + file, err := os.Create(filename) + if err != nil { + fmt.Println("Error creating file:", err) + return + } + defer file.Close() + + tmpl, err := template.New("file").Parse(content) + if err != nil { + fmt.Println("Error parsing template:", err) + return + } + + err = tmpl.Execute(file, nil) + if err != nil { + fmt.Println("Error executing template:", err) + } +} diff --git a/goneovim.go b/goneovim.go index 19e01977..324d66b7 100644 --- a/goneovim.go +++ b/goneovim.go @@ -1,3 +1,4 @@ package goneovim //go:generate sh -c "printf %s $(git describe --tags) > editor/version.txt" +//go:generate go run generate_objcbridge.go