Пример #1
0
        ssEvent pEvent(ssScanner scnr, ssForm f)
        {
            ssEvent e = new ssEvent();

            try {
                scnr.GetStrSpDelim(); e.k = (Keys)keyconv.ConvertFromString(scnr.S);
                scnr.GetStrSpDelim(); e.t = pType(scnr.S);
                if (e.t == ssEventType.press)
                {
                    scnr.GetStrSpDelim(); e.c = pChar(scnr.S);
                }
                if (scnr.C != '|' && scnr.C != '+' && scnr.C != ';')
                {
                    scnr.GetStrSpDelim(); e.a = pAction(scnr.S);
                }
                if (scnr.C != '|' && scnr.C != '+' && scnr.C != ';')
                {
                    scnr.GetStrSpDelim(); e.cont = bool.Parse(scnr.S);
                }
            }
            catch (Exception ee) {
                throw new ssException("error parsing event in events file" + "\r\n?" + ee.Message);
            }
            return(e);
        }
Пример #2
0
        ssEvent pEvent(ssScanner scnr, ssForm f)
        {
            ssEvent e;

            try {
                scnr.GetStrSpDelim();
                eSet es = FindEventSet(subsets, scnr.S);
                if (es != null)
                {
                    e = es.e.nxt.copy();
                    if (!AtEventBoundry(scnr))
                    {
                        scnr.GetChar();
                    }
                }
                else
                {
                    e   = new ssEvent();
                    e.k = (Keys)keyconv.ConvertFromString(scnr.S);
                    scnr.GetStrSpDelim(); e.t = pType(scnr.S);
                    if (e.t == ssEventType.press)
                    {
                        scnr.GetStrSpDelim(); e.c = pChar(scnr.S);
                    }
                    if (!AtEventBoundry(scnr))
                    {
                        scnr.GetStrSpDelim(); e.a = pAction(scnr.S, ref e.cmdopt);
                    }
                    if (!AtEventBoundry(scnr))
                    {
                        scnr.GetStrSpDelim(); e.cont = bool.Parse(scnr.S);
                    }
                    if (e.cmdopt != ssEventCmdOption.none)
                    {
                        scnr.SetDelim("\n");
                        scnr.AllowComment    = false;
                        scnr.GetStr(); e.cmd = scnr.S;
                        scnr.AllowComment    = true;
                        scnr.SetDelim("");
                        if (!AtEventBoundry(scnr))
                        {
                            scnr.GetChar();
                        }
                    }
                }
            }
            catch (Exception ee) {
                scnr.SetDelim("");
                scnr.AllowComment = true;
                throw new ssException("error parsing event in events file" + "\r\n?" + ee.Message);
            }
            return(e);
        }
Пример #3
0
        eSet pSet(ssScanner scnr, ssForm f)
        {
            eSet es = null;
            eSet ss = null;

            for (;;)
            {
                switch (scnr.C)
                {
                case '=':
                case '<':
                    char c = scnr.C;
                    scnr.GetChar();
                    scnr.GetStrSpDelim();
                    eSet s = new eSet(null);
                    s.nm    = scnr.S;
                    s.e     = new ssEvent();
                    s.e.nxt = pEventTree(scnr, f);
                    if (c == '=')
                    {
                        s.nxt = es;
                        es    = s;
                    }
                    else
                    {
                        s.nxt   = subsets;
                        subsets = s;
                    }
                    break;

                case '\0':
                    return(es);

                default:
                    if (char.IsWhiteSpace(scnr.C))
                    {
                        scnr.GetChar();
                    }
                    else
                    {
                        throw new ssException("error parsing event set in events file");
                    }
                    break;
                }
            }
        }
Пример #4
0
        private ssEvent LoadEvents(ssForm f, string fnm)
        {
            ssEvent es = new ssEvent();

            fnm = System.IO.Path.GetDirectoryName(Application.ExecutablePath) +
                  System.IO.Path.DirectorySeparatorChar + fnm;

            int       cnt  = 0;
            ssScanner scnr = null;

            while (cnt < 2 && scnr == null)
            {
                try {
                    cnt++;
                    scnr = new ssScanner(File.ReadAllText(fnm), true);
                    scnr.GetChar();
                }
                catch {
                    try {
                        if (cnt < 2)
                        {
                            f.Ed.MsgLn("creating default events file");
                            File.WriteAllText(fnm, defEvents);
                        }
                        else
                        {
                            throw new ssException("no events file");
                        }
                    }
                    catch (Exception ee) {
                        f.Ed.Err("error writing default events file" + "\r\n" + ee.Message);
                    }
                }
            }

            try {
                es.nxt = pEventTree(scnr, f);
            }
            catch (Exception e) {
                if (f == f.Ed.Log.Frm)
                {
                    f.Ed.Err(e.Message + ": " + scnr.S);                    // Guard this so you don't get messages for every form created.
                }
            }
            return(es);
        }
Пример #5
0
 public ssEd(string[] ars, int sw)
 {
     args      = ars;
     startWith = sw;
     defs      = new ssDefaults();
     txts      = null;
     txt       = null;
     prvtxt    = null;
     //tlog = new ssTransLog();
     curTransId = 0;
     scn        = new ssScanner(null, false);
     grouping   = 0;
     lastPat    = "";
     newfile    = 0;
     root       = new CTree(null, '\0');
     //win remove for non-windowed version
     log = null;
     // remove for non-windowed version */
 }
Пример #6
0
        ssEvent pEventTree(ssScanner scnr, ssForm f)
        {
            ssEvent rt = pEvent(scnr, f);
            ssEvent e  = LastAlt(rt);

            for (;;)
            {
                switch (scnr.C)
                {
                case '|':
                    scnr.GetChar();
                    e.alt = pEvent(scnr, f);
                    e     = LastAlt(e);
                    break;

                case '+':
                    scnr.GetChar();
                    e.nxt = pEventTree(scnr, f);
                    break;

                case ';':
                    scnr.GetChar();
                    return(rt);

                case '\0':
                    return(rt);

                default:
                    if (char.IsWhiteSpace(scnr.C))
                    {
                        scnr.GetChar();
                    }
                    else
                    {
                        throw new ssException("error parsing event tree in events file");
                    }
                    break;
                }
            }
        }
Пример #7
0
        private eSet LoadEvents(ssForm f, string fnm)
        {
            eSet es = null;
            //ssEvent es = new ssEvent();

            int       cnt  = 0;
            ssScanner scnr = null;

            while (cnt < 2 && scnr == null)
            {
                try {
                    cnt++;
                    try {
                        scnr = new ssScanner(File.ReadAllText(fnm), true); // try local
                    }
                    catch {
                        fnm = System.IO.Path.GetDirectoryName(Application.ExecutablePath) +
                              System.IO.Path.DirectorySeparatorChar + fnm;
                        scnr = new ssScanner(File.ReadAllText(fnm), true); // try exe one
                    }
                    scnr.GetChar();
                }
                catch {
                    try {
                        if (cnt < 2)
                        {
                            f.Ed.MsgLn("creating default events file");
                            StreamWriter sw = new StreamWriter(fnm);
                            sw.WriteLine(defEvents);
                            sw.WriteLine("# Available commands:");
                            foreach (MethodInfo m in methods)
                            {
                                if (m.Name.Length > 2 && m.Name.Substring(0, 3) == "Cmd")
                                {
                                    sw.WriteLine(string.Format("#   {0}", m.Name));
                                }
                            }
                            sw.Close();
                        }
                        else
                        {
                            throw new ssException("no events file");
                        }
                    }
                    catch (Exception ee) {
                        f.Ed.Err("error writing default events file" + "\r\n" + ee.Message);
                    }
                }
            }

            try {
                es = pSet(scnr, f);
            }
            catch (Exception e) {
                if (f == f.Ed.Log.Frm)
                {
                    f.Ed.Err(e.Message + ": " + scnr.S);                    // Guard this so you don't get messages for every form created.
                }
            }
            return(es);
        }
Пример #8
0
 bool AtEventBoundry(ssScanner scnr)
 {
     return(scnr.C == '|' || scnr.C == '+' || scnr.C == ';');
 }