Esempio n. 1
0
 public static void AddCmdLineOptions(KCmdLineOptions options, KLocalizedString name)
 {
     staticInterceptor.Invoke("addCmdLineOptions##", "addCmdLineOptions(const KCmdLineOptions&, const KLocalizedString&)", typeof(void), typeof(KCmdLineOptions), options, typeof(KLocalizedString), name);
 }
Esempio n. 2
0
 public static void AddCmdLineOptions(KCmdLineOptions options)
 {
     staticInterceptor.Invoke("addCmdLineOptions#", "addCmdLineOptions(const KCmdLineOptions&)", typeof(void), typeof(KCmdLineOptions), options);
 }
Esempio n. 3
0
 /// <remarks>
 ///  Add options to your application.
 ///  You must make sure that all possible options have been added before
 ///  any class uses the command line arguments.
 ///  The list of options should look like this:
 ///  @code
 ///  KCmdLineOptions options;
 ///  options.add("option1 \<argument>", ki18n("Description 1"), "my_extra_arg");
 ///  options.add("o");
 ///  options.add("option2", ki18n("Description 2"));
 ///  options.add("nooption3", ki18n("Description 3"));
 ///  options.add("+file", ki18n("A required argument 'file'"));
 ///  @endcode
 /// 
 /// <li>
 /// "option1" is an option that requires an additional argument,
 ///      but if one is not provided, it uses "my_extra_arg".
 /// </li>
 /// 
 /// <li>
 /// "option2" is an option that can be turned on. The default is off.
 /// </li>
 /// 
 /// <li>
 /// "option3" is an option that can be turned off. The default is on.
 /// </li>
 /// 
 /// <li>
 /// "o" does not have a description. It is an alias for the option
 ///      that follows. In this case "option2".
 /// </li>
 /// 
 /// <li>
 /// "+file" specifies an argument. The '+' is removed. If your program
 ///      doesn't specify that it can use arguments your program will abort
 ///      when an argument is passed to it. Note that the reverse is not
 ///      true. If required, you must check yourself the number of arguments
 ///      specified by the user:
 ///      @code
 ///        KCmdLineArgs args = KCmdLineArgs.ParsedArgs();
 ///        if (args.Count() == 0) KCmdLineArgs.Usage(i18n("No file specified"));
 ///      @endcode
 /// </li>
 ///  In BNF:
 ///  @code
 ///  cmd = myapp [options] file
 ///  options = (option)
 ///  option = --option1 \<argument> |
 ///           (-o | --option2 | --nooption2) |
 ///           ( --option3 | --nooption3 )
 ///  @endcode
 ///  Instead of "--option3" one may also use "-option3"
 ///  Usage examples:
 /// 
 /// <li>
 /// "myapp --option1 test"
 /// </li>
 /// 
 /// <li>
 /// "myapp" (same as "myapp --option1 my_extra_arg")
 /// </li>
 /// 
 /// <li>
 /// "myapp --option2"
 /// </li>
 /// 
 /// <li>
 /// "myapp --nooption2" (same as "myapp", since it is off by default)
 /// </li>
 /// 
 /// <li>
 /// "myapp -o" (same as "myapp --option2")
 /// </li>
 /// 
 /// <li>
 /// "myapp --nooption3"
 /// </li>
 /// 
 /// <li>
 /// "myapp --option3 (same as "myapp", since it is on by default)
 /// </li>
 /// 
 /// <li>
 /// "myapp --option2 --nooption2" (same as "myapp", because it
 ///      option2 is off by default, and the last usage applies)
 /// </li>
 /// 
 /// <li>
 /// "myapp /tmp/file"
 /// </li>
 /// <param> name="options" A list of options that your code supplies.
 /// </param><param> name="name" the name of the option list, as displayed by
 ///              the help output. Can be empty.
 /// </param><param> name="id" A name with which these options can be identified, can be empty.
 /// </param><param> name="afterId" The options are inserted after this set of options, can be empty.
 ///    </param></remarks>        <short>    Add options to your application.</short>
 public static void AddCmdLineOptions(KCmdLineOptions options, KLocalizedString name, QByteArray id, QByteArray afterId)
 {
     staticInterceptor.Invoke("addCmdLineOptions####", "addCmdLineOptions(const KCmdLineOptions&, const KLocalizedString&, const QByteArray&, const QByteArray&)", typeof(void), typeof(KCmdLineOptions), options, typeof(KLocalizedString), name, typeof(QByteArray), id, typeof(QByteArray), afterId);
 }
Esempio n. 4
0
 /// <remarks>
 ///   Constructor.
 ///    </remarks>        <short>   </short>
 public KCmdLineArgs(KCmdLineOptions _options, KLocalizedString _name, QByteArray _id)
     : this((Type) null)
 {
     CreateProxy();
     interceptor.Invoke("KCmdLineArgs###", "KCmdLineArgs(const KCmdLineOptions&, const KLocalizedString&, const QByteArray&)", typeof(void), typeof(KCmdLineOptions), _options, typeof(KLocalizedString), _name, typeof(QByteArray), _id);
 }
Esempio n. 5
0
 /// <remarks>
 ///  Add all options from another KCmdLineOptions object.
 /// <param> name="options" options to add
 ///      </param></remarks>        <short>    Add all options from another KCmdLineOptions object.</short>
 public KCmdLineOptions Add(KCmdLineOptions options)
 {
     return (KCmdLineOptions) interceptor.Invoke("add#", "add(const KCmdLineOptions&)", typeof(KCmdLineOptions), typeof(KCmdLineOptions), options);
 }
Esempio n. 6
0
 /// <remarks>
 ///  Copy constructor.
 ///      </remarks>        <short>    Copy constructor.</short>
 public KCmdLineOptions(KCmdLineOptions options)
     : this((Type) null)
 {
     CreateProxy();
     interceptor.Invoke("KCmdLineOptions#", "KCmdLineOptions(const KCmdLineOptions&)", typeof(void), typeof(KCmdLineOptions), options);
 }
Esempio n. 7
0
    public static int Main(String[] argv)
    {
        KAboutData aboutData = new KAboutData(  "kwrite-sharp", "Simple Text Editor",
                                                KDE.Ki18n("KWrite"),
                                                "4.1", // KDE.VersionString(),
                                                KDE.Ki18n("KWrite - Text Editor"),
                                                KAboutData.LicenseKey.License_LGPL_V2,
                                                KDE.Ki18n("(c) 2000-2005 The Kate Authors"),
                                                new KLocalizedString(),
                                                "http://www.kate-editor.org" );

        aboutData.AddAuthor(KDE.Ki18n("Christoph Cullmann"), KDE.Ki18n("Maintainer"), "*****@*****.**", "http://www.babylon2k.de");
        aboutData.AddAuthor(KDE.Ki18n("Anders Lund"), KDE.Ki18n("Core Developer"), "*****@*****.**", "http://www.alweb.dk");
        aboutData.AddAuthor(KDE.Ki18n("Joseph Wenninger"), KDE.Ki18n("Core Developer"), "*****@*****.**","http://stud3.tuwien.ac.at/~e9925371");
        aboutData.AddAuthor(KDE.Ki18n("Hamish Rodda"),KDE.Ki18n("Core Developer"), "*****@*****.**");
        aboutData.AddAuthor(KDE.Ki18n("Dominik Haumann"), KDE.Ki18n("Developer & Highlight wizard"), "*****@*****.**");
        aboutData.AddAuthor(KDE.Ki18n("Waldo Bastian"), KDE.Ki18n( "The cool buffersystem" ), "*****@*****.**" );
        aboutData.AddAuthor(KDE.Ki18n("Charles Samuels"), KDE.Ki18n("The Editing Commands"), "*****@*****.**");
        aboutData.AddAuthor(KDE.Ki18n("Matt Newell"), KDE.Ki18n("Testing, ..."), "*****@*****.**");
        aboutData.AddAuthor(KDE.Ki18n("Michael Bartl"), KDE.Ki18n("Former Core Developer"), "*****@*****.**");
        aboutData.AddAuthor(KDE.Ki18n("Michael McCallum"), KDE.Ki18n("Core Developer"), "*****@*****.**");
        aboutData.AddAuthor(KDE.Ki18n("Jochen Wilhemly"), KDE.Ki18n( "KWrite Author" ), "*****@*****.**" );
        aboutData.AddAuthor(KDE.Ki18n("Michael Koch"),KDE.Ki18n("KWrite port to KParts"), "*****@*****.**");
        aboutData.AddAuthor(KDE.Ki18n("Christian Gebauer"), new KLocalizedString(), "*****@*****.**" );
        aboutData.AddAuthor(KDE.Ki18n("Simon Hausmann"), new KLocalizedString(), "*****@*****.**" );
        aboutData.AddAuthor(KDE.Ki18n("Glen Parker"),KDE.Ki18n("KWrite Undo History, Kspell integration"), "*****@*****.**");
        aboutData.AddAuthor(KDE.Ki18n("Scott Manson"),KDE.Ki18n("KWrite XML Syntax highlighting support"), "*****@*****.**");
        aboutData.AddAuthor(KDE.Ki18n("John Firebaugh"),KDE.Ki18n("Patches and more"), "*****@*****.**");

        aboutData.AddCredit(KDE.Ki18n("Matteo Merli"),KDE.Ki18n("Highlighting for RPM Spec-Files, Perl, Diff and more"), "*****@*****.**");
        aboutData.AddCredit(KDE.Ki18n("Rocky Scaletta"),KDE.Ki18n("Highlighting for VHDL"), "*****@*****.**");
        aboutData.AddCredit(KDE.Ki18n("Yury Lebedev"),KDE.Ki18n("Highlighting for SQL"));
        aboutData.AddCredit(KDE.Ki18n("Chris Ross"),KDE.Ki18n("Highlighting for Ferite"));
        aboutData.AddCredit(KDE.Ki18n("Nick Roux"),KDE.Ki18n("Highlighting for ILERPG"));
        aboutData.AddCredit(KDE.Ki18n("Carsten Niehaus"), KDE.Ki18n("Highlighting for LaTeX"));
        aboutData.AddCredit(KDE.Ki18n("Per Wigren"), KDE.Ki18n("Highlighting for Makefiles, Python"));
        aboutData.AddCredit(KDE.Ki18n("Jan Fritz"), KDE.Ki18n("Highlighting for Python"));
        aboutData.AddCredit(KDE.Ki18n("Daniel Naber"));
        aboutData.AddCredit(KDE.Ki18n("Roland Pabel"),KDE.Ki18n("Highlighting for Scheme"));
        aboutData.AddCredit(KDE.Ki18n("Cristi Dumitrescu"),KDE.Ki18n("PHP Keyword/Datatype list"));
        aboutData.AddCredit(KDE.Ki18n("Carsten Pfeiffer"), KDE.Ki18n("Very nice help"));
        aboutData.AddCredit(KDE.Ki18n("Richard Dale"), KDE.Ki18n("C# port"));
        aboutData.AddCredit(KDE.Ki18n("All people who have contributed and I have forgotten to mention"));
        aboutData.SetProgramIconName("accessories-text-editor");

        KCmdLineArgs.Init(argv, aboutData);

        KCmdLineOptions options = new KCmdLineOptions();
        options.Add("stdin", KDE.Ki18n("Read the contents of stdin"));
        options.Add("encoding <argument>", KDE.Ki18n("Set encoding for the file to open"));
        options.Add("line <argument>", KDE.Ki18n("Navigate to this line"));
        options.Add("column <argument>", KDE.Ki18n("Navigate to this column"));
        options.Add("+[URL]", KDE.Ki18n("Document to open"));
        KCmdLineArgs.AddCmdLineOptions(options);

        KApplication kapp = new KApplication();

        KGlobal.Locale().InsertCatalog("katepart4");
        KCmdLineArgs args = KCmdLineArgs.ParsedArgs();

        if (kapp.IsSessionRestored()) {
            KWrite.Restore();
        } else {
            bool nav = false;
            int line = 0, column = 0;

            QTextCodec codec = args.IsSet("encoding") ? QTextCodec.CodecForName(args.GetOption("encoding")) : null;

            if (args.IsSet("line")) {
                line = System.Convert.ToInt32(args.GetOption("line")) - 1;
                nav = true;
            }

            if (args.IsSet("column")) {
                column = System.Convert.ToInt32(args.GetOption("column")) - 1;
                nav = true;
            }

            if (args.Count() == 0) {
                KWrite t = new KWrite((KTextEditor.Document) null);

                if (args.IsSet("stdin")) {
                    QTextStream input = new QTextStream(Console.OpenStandardInput());

                    // set chosen codec
                    if (codec != null)
                        input.SetCodec(codec);

                    string inputLine;
                    string text = "";

                    do {
                        inputLine = input.ReadLine();
                        text += (inputLine + "\n");
                    } while (inputLine != null);

                    KTextEditor.Document doc = t.View().Document();
                    if (doc != null)
                        doc.SetText(text);
                }

                if (nav && t.View() != null)
                    t.View().SetCursorPosition(new KTextEditor.Cursor(line, column));
            } else {
                int docs_opened = 0;
                for ( int z = 0; z < args.Count(); z++ ) {
                    // this file is no local dir, open it, else warn
                    bool noDir = !args.Url(z).IsLocalFile()  || !(new QDir(args.Url(z).Path())).Exists();
                    if (noDir) {
                        ++docs_opened;
                        KWrite t = new KWrite();
                        //if (codec != null)
                        //    t.View().Document().SetEncoding(codec.Name());
                        t.LoadURL(args.Url(z));
                        if (nav)
                            t.View().SetCursorPosition(new KTextEditor.Cursor(line, column));
                    } else {
                        KMessageBox.Sorry(null, KDE.I18n("The file " + args.Url(z).Url() + " could not be opened: it is not a normal file, it is a folder."));
                    }
                }
                if (docs_opened == 0) return 1; // see http://bugs.kde.org/show_bug.cgi?id=124708
            }
        }

        // no window there, uh, ohh, for example borked session config !!!
        // create at least one !!
        if (KWrite.NoWindows())
            new KWrite();
        return KApplication.Exec();
    }