//[c]The bootstrap //[c] //[of]:license //[c]Code Browser - a folding text editor for programmers //[c]Copyright (C) 2003-07 Marc Kerbiquet //[c] //[c]This program is free software; you can redistribute it and/or modify //[c]it under the terms of the GNU General Public License as published by //[c]the Free Software Foundation; either version 2 of the License, or //[c](at your option) any later version. //[c] //[c]This program is distributed in the hope that it will be useful, //[c]but WITHOUT ANY WARRANTY; without even the implied warranty of //[c]MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //[c]GNU General Public License for more details. //[c] //[c]You should have received a copy of the GNU General Public License //[c]along with this program; if not, write to the Free Software //[c]Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //[cf] //[of]:imports import "base/types" import "text/string" import "text/string-buffer" import "text/vector-of-strings" import "swift" import "utilities/text-utils" //[c] import "application/code-browser-application" import "code-browser-frame" //[cf] //[c] //[of]:run //[c]Initializes all components and open the main window //[c] public func run (argc:int, argv: [] string) // Parse command line def preferences = empty string def filenames := vector of strings (8) def force new instance = false def i = 1 while i < argc def arg = argv [i++] if is equal (arg, "-c") if i < argc preferences = argv [i++] end // a specific config requires to open a new window // (can't use an existing instance) force new instance = true elsif is equal (arg, "-i") force new instance = true else add (filenames, arg) end end // Create the application object def app := code browser application (preferences) // Test if there is already another instance of the // application running (if the single instance option // is selected). def single instance = ~ (force new instance || allow multiple instances (settings (app))) if single instance && can send message (app name) // The filenames must be converted to fullname before sending // them since the other instance may not run in the same // working directory. def message := temp string buffer def full name := temp string buffer each (filenames) ? filename remove all (full name) full name (filename, full name) if not empty (message) message << field separator end serialize (message, as string (full name)) end release (full name) send message (app name, as string (message)) release (message) else // Open the main frame on it def frame = new code browser frame box (app) // Open a window for each filename each (filenames) ? filename open window (frame, filename, true) end activate (frame) set manager (frame, app name) code browser message loop (frame) // terminating ... delete (frame) end release (app) release (filenames) return 0 end //[cf]