Beispiel #1
0
 public void ParametersFromTemp(Dictionary <string, SValue> settingsData)
 {
     for (int i = 0; i < properties.Count; i++)
     {
         Properties.Property property = properties[i];
         if (property.AllowTemp && !property.initedByConfig)
         {
             SValue value = settingsData.ContainsKey(property.name) ? settingsData[property.name] : SValue.None;
             property.SetTemp(value);
         }
     }
 }
 override public void SetTemp(SValue sValue)
 {
     if (sValue.IsString)
     {
         string       error;
         EncodingPair newValue = EncodingPair.ParseEncoding(sValue.String, out error);
         if (!newValue.IsNull)
         {
             value = newValue;
         }
     }
 }
Beispiel #3
0
        public void RenameValue(int index, string newName, CTextureRef newTexture = null)
        {
            if (index < 0 && index >= _Values.Count)
            {
                return;
            }

            SValue value = _Values[index];

            value.Text     = newName;
            value.Texture  = newTexture;
            _Values[index] = value;
        }
Beispiel #4
0
    public SValue GetExpandedTemp()
    {
        SValue value = SValue.NewList();

        foreach (Node nodeI in nodes)
        {
            if (nodeI.expanded)
            {
                value.Add(SValue.NewInt(nodeI.hash));
            }
        }
        return(value);
    }
Beispiel #5
0
    public SValue Serialize()
    {
        SValue value = SValue.NewList();

        foreach (string text in list)
        {
            if (!string.IsNullOrEmpty(text))
            {
                value.Add(SValue.NewString(text));
            }
        }
        return(value);
    }
Beispiel #6
0
        public void Values()
        {
            SValue value;

            value = SValue.NewString("text");
            Assert.AreEqual("text", value.String);
            Assert.AreEqual(true, value.IsString);
            Assert.AreEqual(false, value.IsNone);
            Assert.AreEqual(false, value.IsInt);
            Assert.AreEqual(0, value.Int);
            Assert.AreEqual(0, value.Double);
            Assert.AreEqual(false, value.Bool);
            Assert.AreEqual(false, value.IsFloat);
            Assert.AreEqual(false, value.IsLong);

            value = SValue.NewInt(10);
            Assert.AreEqual(10, value.Int);
            Assert.AreEqual(true, value.IsInt);
            Assert.AreEqual(false, value.IsString);
            Assert.AreEqual(false, value.IsNone);

            value = SValue.NewDouble(10.2);
            Assert.AreEqual(10.2, value.Double);
            Assert.AreEqual(0, value.Int);
            Assert.AreEqual(true, value.IsDouble);
            Assert.AreEqual(false, value.IsInt);
            Assert.AreEqual(false, value.IsString);
            Assert.AreEqual(false, value.IsNone);

            value = SValue.NewBool(true);
            Assert.AreEqual(true, value.Bool);
            Assert.AreEqual(0, value.Int);
            Assert.AreEqual(true, value.IsBool);
            Assert.AreEqual(false, value.IsInt);
            Assert.AreEqual(false, value.IsString);
            Assert.AreEqual(false, value.IsNone);

            value = SValue.NewBool(false);
            Assert.AreEqual(false, value.Bool);
            Assert.AreEqual(true, value.IsBool);

            value = SValue.NewFloat(10.5f);
            Assert.AreEqual(10.5f, value.Float);
            Assert.AreEqual(true, value.IsFloat);

            value = SValue.NewLong(10000L);
            Assert.AreEqual(10000L, value.Long);
            Assert.AreEqual(true, value.IsLong);
        }
Beispiel #7
0
 public void SerializeAndDeserialize_Simple()
 {
     Assert.AreEqual("'some text'", SValue.Unserialize(SValue.Serialize(SValue.NewString("some text"))).ToString());
     Assert.AreEqual("''", SValue.Unserialize(SValue.Serialize(SValue.NewString(""))).ToString());
     Assert.AreEqual("''", SValue.Unserialize(SValue.Serialize(SValue.NewString(null))).ToString());
     Assert.AreEqual("10", SValue.Unserialize(SValue.Serialize(SValue.NewInt(10))).ToString());
     Assert.AreEqual("-150", SValue.Unserialize(SValue.Serialize(SValue.NewInt(-150))).ToString());
     Assert.AreEqual("10.1d", SValue.Unserialize(SValue.Serialize(SValue.NewDouble(10.1))).ToString());
     Assert.AreEqual("-0.1d", SValue.Unserialize(SValue.Serialize(SValue.NewDouble(-0.1))).ToString());
     Assert.AreEqual("True", SValue.Unserialize(SValue.Serialize(SValue.NewBool(true))).ToString());
     Assert.AreEqual("False", SValue.Unserialize(SValue.Serialize(SValue.NewBool(false))).ToString());
     Assert.AreEqual("1.5f", SValue.Unserialize(SValue.Serialize(SValue.NewFloat(1.5f))).ToString());
     Assert.AreEqual("2000L", SValue.Unserialize(SValue.Serialize(SValue.NewLong(2000L))).ToString());
     Assert.AreEqual("None", SValue.Unserialize(SValue.Serialize(SValue.None)).ToString());
 }
Beispiel #8
0
        public void SerializeAndDeserialize_List()
        {
            SValue hash = SValue.NewHash();

            hash["field0"] = SValue.NewString("value");
            hash["field1"] = SValue.NewInt(10);

            SValue list = SValue.NewList();

            list.Add(SValue.NewInt(1));
            list.Add(SValue.NewString("value2"));
            list.Add(hash);

            Assert.AreEqual("[1, 'value2', {'field0': 'value', 'field1': 10}]", SValue.Unserialize(SValue.Serialize(list)).ToString());
        }
Beispiel #9
0
        /// <summary>
        ///     Adds an entry to the slide.
        /// </summary>
        /// <param name="text">Label to show</param>
        /// <param name="translationId">Translation id to use for the text</param>
        /// <param name="texture">Texture to show</param>
        /// <param name="tag">User value (e.g. id of entry)</param>
        public void AddValue(string text, int translationId, CTextureRef texture = null, int tag = 0)
        {
            SValue value = new SValue {
                Text = text, TranslationId = translationId, Tag = tag, Texture = texture
            };

            _Values.Add(value);

            if (Selection < 0)
            {
                Selection = 0;
            }

            _Invalidate();
        }
    private void SerializeSettings(ref SValue state)
    {
        SValue hash = state.SetNewHash("settings");

        foreach (KeyValuePair <string, SValue> pair in settingsData)
        {
            if (pair.Key == Scheme)
            {
                continue;
            }
            hash[pair.Key] = pair.Value;
        }
        string scheme = settingsData.ContainsKey(Scheme) ? settingsData[Scheme].String : null;

        state[Scheme] = !string.IsNullOrEmpty(scheme) ? SValue.NewString(scheme) : SValue.None;
    }
    public EncodingPair GetEncoding(string fullPath, EncodingPair defaultPair)
    {
        SValue value       = storage.Get(fullPath);
        string rawEncoding = value["encoding"].String;

        if (!string.IsNullOrEmpty(rawEncoding))
        {
            string       error;
            EncodingPair pair = EncodingPair.ParseEncoding(rawEncoding, out error);
            if (string.IsNullOrEmpty(error))
            {
                return(pair);
            }
        }
        return(defaultPair);
    }
Beispiel #12
0
        public void StringCantBeNull()
        {
            SValue value;

            value = SValue.NewString("abcd");
            Assert.AreEqual("abcd", value.String);

            value = SValue.NewString("");
            Assert.AreEqual("", value.String);

            value = SValue.NewString(null);
            Assert.AreEqual("", value.String);

            value = SValue.NewBool(true);
            Assert.AreEqual("", value.String);
        }
Beispiel #13
0
    public void SetExpandedTemp(SValue value)
    {
        if (node == null)
        {
            expandedTemp = value;
            return;
        }
        Dictionary <int, bool> expanded = new Dictionary <int, bool>();

        foreach (SValue valueI in value.List)
        {
            expanded[valueI.Int] = true;
        }
        ExpandCollection(node, expanded);
        Rebuild();
    }
    private SValue EncodeGlobalBookmakrs()
    {
        SValue data = SValue.NewList();

        if (MulticaretTextBox.initMacrosExecutor != null)
        {
            for (char c = 'A'; c <= 'Z'; ++c)
            {
                string path;
                int    position;
                MulticaretTextBox.initMacrosExecutor.GetBookmark(c, out path, out position);
                data.Add(SValue.NewString(path));
                data.Add(SValue.NewInt(position));
            }
        }
        return(data);
    }
Beispiel #15
0
        public void SerializeAndDeserialize_EqualTextsCovering()
        {
            SValue list = SValue.NewList();
            SValue hash;

            hash           = SValue.NewHash();
            hash["field0"] = SValue.NewString("value1");
            hash["field1"] = SValue.NewInt(10);
            list.Add(hash);

            hash           = SValue.NewHash();
            hash["field3"] = SValue.NewString("value2");
            hash["field1"] = SValue.NewInt(100);
            list.Add(hash);

            Assert.AreEqual("[{'field0': 'value1', 'field1': 10}, {'field3': 'value2', 'field1': 100}]", SValue.Unserialize(SValue.Serialize(list)).ToString());
        }
Beispiel #16
0
 public void AsDictionary()
 {
     byte[] bytes;
     {
         SValue value = SValue.NewHash();
         value["x"] = SValue.NewInt(10);
         Assert.NotNull(value.AsDictionary, "before serialize");
         Assert.AreEqual(1, value.AsDictionary.Count, "before serialize");
         Assert.AreEqual(10, value.AsDictionary["x"].Int, "before serialize");
         bytes = SValue.Serialize(value);
     }
     {
         SValue value = SValue.Unserialize(bytes);
         Assert.NotNull(value.AsDictionary, "after serialize");
         Assert.AreEqual(1, value.AsDictionary.Count, "after serialize");
         Assert.AreEqual(10, value.AsDictionary["x"].Int, "after serialize");
     }
 }
    public void ApplyQualities(Buffer buffer, int lineNumber)
    {
        int caret = storage.Get(buffer.FullPath)["cursor"].Int;

        if (lineNumber == 0)
        {
            buffer.Controller.PutCursor(buffer.Controller.SoftNormalizedPlaceOf(caret), false);
            buffer.Controller.NeedScrollToCaret();
        }
        else
        {
            Place  place = new Place(0, lineNumber - 1);
            SValue value = storage.Get(buffer.FullPath);
            value["cursor"] = SValue.NewInt(buffer.Controller.Lines.IndexOf(place));
            buffer.Controller.PutCursor(place, false);
            buffer.Controller.NeedScrollToCaret();
        }
    }
    private void ValuesUnserialize(SValue state)
    {
        SValue sList = state["values"];

        foreach (SValue hash in sList.List)
        {
            string          id = hash["id"].String;
            TempSettingsInt settingsInt;
            settingsInts.TryGetValue(id, out settingsInt);
            if (settingsInt == null)
            {
                settingsInt      = new TempSettingsInt(id);
                settingsInts[id] = settingsInt;
            }
            settingsInt.priority = hash["priority"].Int;
            settingsInt.value    = hash["value"].Int;
            settingsInts[id]     = settingsInt;
        }
    }
    private void UnserializeSettings(ref SValue state)
    {
        settingsData.Clear();
        Dictionary <string, SValue> dict = state["settings"].AsDictionary;

        if (dict != null)
        {
            foreach (KeyValuePair <string, SValue> pair in dict)
            {
                if (pair.Key == Scheme)
                {
                    continue;
                }
                settingsData[pair.Key] = pair.Value;
            }
        }
        string scheme = state[Scheme].String;

        settingsData[Scheme] = SValue.NewString(!string.IsNullOrEmpty(scheme) ? scheme : Settings.DefaultScheme);
    }
 private void DecodeGlobalBookmarks(SValue data)
 {
     if (MulticaretTextBox.initMacrosExecutor != null)
     {
         IRList <SValue> list = data.List;
         if (list != null)
         {
             int count = ('Z' - 'A' + 1) * 2;
             for (int i = 0; i + 1 < list.Count && i < count; i += 2)
             {
                 string path     = list[i].String;
                 int    position = list[i + 1].Int;
                 if (!string.IsNullOrEmpty(path))
                 {
                     MulticaretTextBox.initMacrosExecutor.SetBookmark((char)(i / 2 + 'A'), path, position);
                 }
             }
         }
     }
 }
    public void ApplyQualitiesBeforeLoading(Buffer buffer)
    {
        if (buffer.isQualitiesApplied)
        {
            return;
        }
        buffer.isQualitiesApplied = true;
        SValue value       = storage.Get(buffer.FullPath);
        string rawEncoding = value["encoding"].String;

        if (!string.IsNullOrEmpty(rawEncoding))
        {
            string error;
            buffer.settedEncodingPair = EncodingPair.ParseEncoding(rawEncoding, out error);
        }
        buffer.customSyntax = value["syntax"].String;
        byte[] bookmarks = value["bm"].Bytes;
        if (bookmarks != null)
        {
            DecodeBookmarks(buffer.Controller, bookmarks);
        }
    }
Beispiel #22
0
        public void ToStringTest()
        {
            SValue value;

            value = SValue.NewBool(false);
            Assert.AreEqual("False", value.ToString());

            value          = SValue.NewHash();
            value["field"] = SValue.NewString("value");
            Assert.AreEqual("{'field': 'value'}", value.ToString());

            value           = SValue.NewHash();
            value["field1"] = SValue.NewString("value1");
            value["field2"] = SValue.NewString("value2");
            Assert.AreEqual("{'field1': 'value1', 'field2': 'value2'}", value.ToString());

            value    = SValue.NewList();
            value[0] = SValue.NewDouble(1.5);
            value[2] = SValue.NewString("value");
            Assert.AreEqual(3, value.ListCount);
            Assert.AreEqual("[1.5d, None, 'value']", value.ToString());
        }
Beispiel #23
0
        public void List()
        {
            SValue value;

            value    = SValue.NewList();
            value[0] = SValue.NewString("text");
            Assert.AreEqual("text", value[0].String);
            Assert.AreEqual("", value[1].String);

            value    = SValue.NewList();
            value[0] = SValue.NewDouble(1.5);
            value[1] = SValue.None;
            Assert.AreEqual(2, value.ListCount);
            Assert.AreEqual("[1.5d, None]", value.ToString());

            value    = SValue.NewList();
            value[0] = SValue.NewInt(0);
            value[1] = SValue.NewInt(1);
            value[2] = SValue.NewInt(2);
            value[3] = SValue.NewInt(3);
            Assert.AreEqual("[0, 1, 2, 3]", value.ToString());

            value.ListCount = 4;
            Assert.AreEqual("[0, 1, 2, 3]", value.ToString());
            value.ListCount = 3;
            Assert.AreEqual("[0, 1, 2]", value.ToString());
            value.ListCount = 5;
            Assert.AreEqual("[0, 1, 2, None, None]", value.ToString());
            value.ListCount = 3;
            Assert.AreEqual("[0, 1, 2]", value.ToString());
            value.ListCount = 0;
            Assert.AreEqual("[]", value.ToString());

            value.Add(SValue.NewInt(1));
            value.Add(SValue.NewInt(3));
            value.Add(SValue.NewInt(5));
            CollectionAssert.AreEqual(new SValue[] { SValue.NewInt(1), SValue.NewInt(3), SValue.NewInt(5) }, value.List);
        }
Beispiel #24
0
        public void SerializeAndDeserialize_CircleLinks()
        {
            SValue hash = SValue.NewHash();

            hash["field0"] = SValue.NewString("value");
            hash["field1"] = SValue.NewInt(10);
            hash["field2"] = hash;

            SValue list = SValue.NewList();

            list.Add(SValue.NewInt(1));
            list.Add(SValue.NewString("value2"));
            list.Add(hash);

            hash["field3"] = list;

            SValue unserialized = SValue.Unserialize(SValue.Serialize(list));

            Assert.AreEqual("[1, 'value2', {'field0': 'value', 'field1': 10, 'field2': …, 'field3': …}]", unserialized.ToString());
            Assert.AreEqual(unserialized[2], unserialized[2]["field2"]);
            Assert.AreEqual(unserialized, unserialized[2]["field3"]);
            Assert.AreNotEqual(unserialized, unserialized[2]["field2"]);
        }
Beispiel #25
0
    public void Rescan()
    {
        string tempFile = Path.Combine(Path.GetTempPath(), "typewriter-syntax.bin");
        SValue temp     = File.Exists(tempFile) ? SValue.Unserialize(File.ReadAllBytes(tempFile)) : SValue.None;
        Dictionary <string, bool> scanned = new Dictionary <string, bool>();
        List <string>             files   = new List <string>();

        foreach (string dir in dirs)
        {
            if (!Directory.Exists(dir))
            {
                continue;
            }
            foreach (string fileI in Directory.GetFiles(dir, "*.xml"))
            {
                string fileName = Path.GetFileName(fileI);
                if (!scanned.ContainsKey(fileName))
                {
                    scanned[fileName] = true;
                    files.Add(fileI);
                }
            }
        }
        scanned.Clear();

        SValue newTemp = SValue.NewHash();

        infos.Clear();
        syntaxFileByName.Clear();
        bool changed = false;

        foreach (string fileI in files)
        {
            SValue tempI    = temp[fileI];
            long   newTicks = File.GetLastWriteTime(fileI).Ticks;
            long   ticks    = tempI["ticks"].Long;
            if (newTicks == ticks)
            {
                LanguageInfo info = new LanguageInfo();
                info.syntax   = tempI["syntax"].String;
                info.patterns = ParsePatterns(tempI["patterns"].String);
                info.priority = tempI["priority"].Int;
                syntaxFileByName[info.syntax] = fileI;
                infos.Add(info);

                newTemp[fileI] = tempI;
            }
            else
            {
                changed = true;
                XmlReaderSettings settings = new XmlReaderSettings();
                settings.ProhibitDtd = false;
                settings.XmlResolver = null;
                using (XmlReader reader = XmlReader.Create(fileI, settings))
                {
                    while (reader.Read())
                    {
                        if (reader.NodeType == XmlNodeType.Element && reader.Name == "language")
                        {
                            string syntax   = "";
                            string patterns = "";
                            int    priority = 0;
                            for (int i = 0; i < reader.AttributeCount; i++)
                            {
                                reader.MoveToAttribute(i);
                                if (reader.Name == "name")
                                {
                                    syntax = reader.Value.ToLowerInvariant();
                                }
                                else if (reader.Name == "extensions")
                                {
                                    patterns = reader.Value;
                                }
                                else if (reader.Name == "priority")
                                {
                                    int.TryParse(reader.Value, out priority);
                                }
                            }
                            if (!string.IsNullOrEmpty(syntax))
                            {
                                LanguageInfo info = new LanguageInfo();
                                info.syntax   = syntax;
                                info.patterns = ParsePatterns(patterns);
                                info.priority = priority;
                                syntaxFileByName[info.syntax] = fileI;
                                infos.Add(info);

                                SValue newTempI = SValue.NewHash();
                                newTempI["syntax"]   = SValue.NewString(info.syntax);
                                newTempI["patterns"] = SValue.NewString(patterns);
                                newTempI["priority"] = SValue.NewInt(priority);
                                newTempI["ticks"]    = SValue.NewLong(newTicks);
                                newTemp[fileI]       = newTempI;
                            }
                            break;
                        }
                    }
                }
            }
        }
        if (changed)
        {
            File.WriteAllBytes(tempFile, SValue.Serialize(newTemp));
        }
    }
Beispiel #26
0
        public void Open(string filename = null)
        {
            try
            {
                if (filename == null)
                {
                    openDialog.InitialDirectory = GetDefaultFileDialogPath();
                    DialogResult result = openDialog.ShowDialog();
                    if (result == DialogResult.OK)
                    {
                        filename = openDialog.FileName;
                        // If the user has no file open; or, if the user has a file open, they actually decided to close it (rather than cancel)
                        if (!TryCloseFile())
                        {
                            return;
                        }
                    }
                    else
                    {
                        return;
                    }
                }

                currentFile             = filename;
                textBoxCurrentFile.Text = Path.GetFileName(currentFile);

                //load file to mainbuffer
                string ext = Path.GetExtension(currentFile);
                if (ext == ".xml")
                {
                    using (StreamReader SR = new StreamReader(File.Open(currentFile, FileMode.Open)))
                    {
                        MAINBUFFER = SValue.FromXMLFile(SR);
                    }
                }
                else if (ext == ".hws")
                {
                    using (BinaryReader BR = new BinaryReader(File.Open(currentFile, FileMode.Open)))
                    {
                        MAINBUFFER = SValue.LoadStream(BR);
                    }
                }

                //load values into form
                if (MAINBUFFERtoFormData())
                {
                    buttonSave.Enabled              = true;
                    buttonClose.Enabled             = true;
                    saveToolStripMenuItem.Enabled   = true;
                    saveAsToolStripMenuItem.Enabled = true;
                    closeToolStripMenuItem.Enabled  = true;
                    tabGeneral.Enabled              = true;
                    tabModifiers.Enabled            = true;
                    tabPlayers.Enabled              = true;
                    //tabPageSelector.SelectedIndex = 0;

                    ValidifyModifiersCheckBoxes();

                    toolStripStatusLabel.Text        = "Successfully loaded data.";
                    toolStripStatusLabel.ToolTipText = "Successfully loaded data from: \"" + currentFile + "\"";
                }
            }
            catch (Exception e)
            {
                ResetForm();
                MessageBox.Show("An error occurred while trying to open the file:\n" + e.Message + "\n" + e.StackTrace, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                toolStripStatusLabel.Text        = "Error encountered while loading.";
                toolStripStatusLabel.ToolTipText = "An error occurred while trying to load the data for the save.";
            }
        }
Beispiel #27
0
    private void Rescan()
    {
        infos.Clear();
        snippetFiles.Clear();

        string tempFile = Path.Combine(Path.GetTempPath(), "typewriter-snippet.bin");
        SValue temp     = File.Exists(tempFile) ? SValue.Unserialize(File.ReadAllBytes(tempFile)) : SValue.None;
        Dictionary <string, bool> scanned = new Dictionary <string, bool>();
        List <string>             files   = new List <string>();

        foreach (string dir in dirs)
        {
            if (!Directory.Exists(dir))
            {
                continue;
            }
            foreach (string fileI in Directory.GetFiles(dir, "*.snippets"))
            {
                string fileName = Path.GetFileName(fileI);
                if (!scanned.ContainsKey(fileName))
                {
                    scanned[fileName] = true;
                    files.Add(Path.Combine(dir, fileI));
                }
            }
        }
        files.Sort();
        scanned.Clear();

        SValue newTemp = SValue.NewHash();

        infos.Clear();
        foreach (string pathI in files)
        {
            string fileName = Path.GetFileName(pathI);
            SValue tempI    = temp[fileName];
            long   newTicks = File.GetLastWriteTime(pathI).Ticks;
            long   ticks    = tempI["ticks"].Long;
            if (newTicks == ticks)
            {
                SnippetInfo info = new SnippetInfo();
                info.path     = pathI;
                info.patterns = ParseExtenstions(tempI["patterns"].String);
                infos.Add(info);

                newTemp[fileName] = tempI;
            }
            else
            {
                string line = null;
                using (StreamReader reader = new StreamReader(pathI))
                {
                    line = reader.ReadLine();
                }
                string patterns;
                if (line != null && line.StartsWith("extensions:"))
                {
                    patterns = line.Substring("extensions:".Length).Trim();
                }
                else
                {
                    patterns = "";
                }

                SValue newTempI = SValue.NewHash();
                newTempI["patterns"] = SValue.NewString(patterns);
                newTempI["ticks"]    = SValue.NewLong(newTicks);
                newTemp[fileName]    = newTempI;

                SnippetInfo info = new SnippetInfo();
                info.path     = pathI;
                info.patterns = ParseExtenstions(patterns);
                infos.Add(info);
            }
        }
        File.WriteAllBytes(tempFile, SValue.Serialize(newTemp));
    }
    public void ResetQualitiesEncoding(Buffer buffer)
    {
        SValue value = storage.Get(buffer.FullPath);

        value["encoding"] = SValue.None;
    }
    public void Save(string postfix, bool rememberOpenedFiles)
    {
        SValue state = SValue.NewHash();

        if (mainForm.WindowState == FormWindowState.Maximized)
        {
            state["width"]  = SValue.NewInt(mainForm.RestoreBounds.Width);
            state["height"] = SValue.NewInt(mainForm.RestoreBounds.Height);
            state["x"]      = SValue.NewInt(mainForm.RestoreBounds.X);
            state["y"]      = SValue.NewInt(mainForm.RestoreBounds.Y);
        }
        else
        {
            state["width"]  = SValue.NewInt(mainForm.Width);
            state["height"] = SValue.NewInt(mainForm.Height);
            state["x"]      = SValue.NewInt(mainForm.Location.X);
            state["y"]      = SValue.NewInt(mainForm.Location.Y);
        }
        state["maximized"] = SValue.NewBool(mainForm.WindowState == FormWindowState.Maximized);
        if (rememberOpenedFiles)
        {
            {
                SValue openedTabs = state.SetNewList("openedTabs");
                foreach (Buffer buffer in mainForm.MainNest.buffers.list)
                {
                    SValue valueI = SValue.NewHash().With("fullPath", SValue.NewString(buffer.FullPath));
                    openedTabs.Add(valueI);
                    if (buffer == mainForm.MainNest.buffers.list.Selected)
                    {
                        state["selectedTab"] = valueI;
                    }
                }
            }
            if (mainForm.MainNest2 != null)
            {
                SValue openedTabs = state.SetNewList("openedTabs2");
                foreach (Buffer buffer in mainForm.MainNest2.buffers.list)
                {
                    SValue valueI = SValue.NewHash().With("fullPath", SValue.NewString(buffer.FullPath));
                    openedTabs.Add(valueI);
                    if (buffer == mainForm.MainNest2.buffers.list.Selected)
                    {
                        state["selectedTab2"] = valueI;
                    }
                }
            }
        }
        state["storage"]      = storage.Serialize();
        state["recently"]     = recently.Serialize();
        state["recentlyDirs"] = recentlyDirs.Serialize();
        state["bm"]           = EncodeGlobalBookmakrs();
        ValuesSerialize(state);
        state["commandHistory"]               = commandHistory.Serialize();
        state["findHistory"]                  = findHistory.Serialize();
        state["findInFilesHistory"]           = findInFilesHistory.Serialize();
        state["findInFilesTempFilter"]        = findInFilesTempFilter.Serialize();
        state["findInFilesTempCurrentFilter"] = SValue.NewString(findInFilesTempCurrentFilter.value);
        state["moveHistory"]                  = moveHistory.Serialize();
        state["replacePatternHistory"]        = replacePatternHistory.Serialize();
        state["replaceHistory"]               = replaceHistory.Serialize();
        state["goToLineHistory"]              = goToLineHistory.Serialize();
        state["findParams"] = findParams.Serialize();
        if (!string.IsNullOrEmpty(NullableCurrentDir))
        {
            state["currentDir"] = SValue.NewString(NullableCurrentDir);
        }
        state["showFileTree"]     = SValue.NewBool(mainForm.FileTreeOpened);
        state["fileTreeExpanded"] = mainForm.FileTree.GetExpandedTemp();
        state["helpPosition"]     = SValue.NewInt(helpPosition);
        state["viHelpPosition"]   = SValue.NewInt(viHelpPosition);
        SerializeSettings(ref state);
        File.WriteAllBytes(GetTempSettingsPath(postfix, AppPath.StartupDir), SValue.Serialize(state));
    }
    public void Load(string postfix, bool rememberOpenedFiles)
    {
        SValue state = SValue.None;
        string file  = GetTempSettingsPath(postfix, AppPath.StartupDir);

        if (File.Exists(file))
        {
            state = SValue.Unserialize(File.ReadAllBytes(file));
        }

        NullableCurrentDir = state["currentDir"].String;
        int width  = Math.Max(50, state["width"].GetInt(700));
        int height = Math.Max(30, state["height"].GetInt(480));
        int x      = state["x"].Int;
        int y      = state["y"].Int;

        mainForm.Size        = new Size(width, height);
        mainForm.Location    = new Point(x, y);
        mainForm.WindowState = state["maximized"].GetBool(false) ? FormWindowState.Maximized : FormWindowState.Normal;
        storage.Unserialize(state["storage"]);
        recently.Unserialize(state["recently"]);
        recentlyDirs.Unserialize(state["recentlyDirs"]);
        DecodeGlobalBookmarks(state["bm"]);
        if (rememberOpenedFiles)
        {
            {
                foreach (SValue valueI in state["openedTabs"].List)
                {
                    string fullPath = valueI["fullPath"].String;
                    if (fullPath != "" && File.Exists(fullPath))
                    {
                        mainForm.LoadFile(fullPath);
                    }
                }
                Buffer selectedTab = mainForm.MainNest.buffers.GetByFullPath(BufferTag.File, state["selectedTab"]["fullPath"].String);
                if (selectedTab != null)
                {
                    mainForm.MainNest.buffers.list.Selected = selectedTab;
                }
            }
            {
                foreach (SValue valueI in state["openedTabs2"].List)
                {
                    string fullPath = valueI["fullPath"].String;
                    if (fullPath != "" && File.Exists(fullPath))
                    {
                        mainForm.LoadFile(fullPath, null, mainForm.MainNest2);
                    }
                }
                if (mainForm.MainNest2 != null)
                {
                    Buffer selectedTab = mainForm.MainNest.buffers.GetByFullPath(BufferTag.File, state["selectedTab2"]["fullPath"].String);
                    if (selectedTab != null)
                    {
                        mainForm.MainNest.buffers.list.Selected = selectedTab;
                    }
                }
            }
        }
        ValuesUnserialize(state);
        commandHistory.Unserialize(state["commandHistory"]);
        findHistory.Unserialize(state["findHistory"]);
        findInFilesHistory.Unserialize(state["findInFilesHistory"]);
        findInFilesTempFilter.Unserialize(state["findInFilesTempFilter"]);
        findInFilesTempCurrentFilter.value = state["findInFilesTempCurrentFilter"].String;
        moveHistory.Unserialize(state["moveHistory"]);
        replacePatternHistory.Unserialize(state["replacePatternHistory"]);
        replaceHistory.Unserialize(state["replaceHistory"]);
        goToLineHistory.Unserialize(state["goToLineHistory"]);
        findParams.Unserialize(state["findParams"]);
        mainForm.FileTree.SetExpandedTemp(state["fileTreeExpanded"]);
        if (state["showFileTree"].Bool)
        {
            mainForm.OpenFileTree();
            if (mainForm.MainNest.Frame != null)
            {
                mainForm.MainNest.Frame.Focus();
            }
        }
        helpPosition   = state["helpPosition"].Int;
        viHelpPosition = state["viHelpPosition"].Int;
        UnserializeSettings(ref state);
    }