public OptionContext(SocketCommandContext commandContext, MenuService service, ref object editable, int Index, ref List <EditorOption> option) { CommandContext = commandContext; MenuService = service; EditableObject = editable; CurrentIndex = Index; CurrentOption = option[Index]; }
/// <summary> /// エディタにオプション情報をセットする /// </summary> /// <param name="editor">オプション情報をセットするエディタ</param> public void SetOption(TextEditorEx editor) { EditorOption option = GetEditorOption(editor.FileName); if (option == null) { util.Msgbox.Error("エディタ設定の読み込みができませんでした"); return; } editor.Encoding = option.Encoding; editor.Font = option.Font; editor.UseCodeCompletion = option.UseCodeCompletion; editor.ParseActionSaveFile = option.ParseActionFileSave; editor.Document.TextEditorProperties.AllowCaretBeyondEOL = option.AllowCaretBeyondEOL; editor.Document.TextEditorProperties.TabIndent = option.TabIndent; editor.Document.TextEditorProperties.IndentationSize = option.IndentationSize; editor.Document.TextEditorProperties.IndentStyle = option.IndentStyle; editor.Document.TextEditorProperties.DocumentSelectionMode = option.DocumentSelectionMode; editor.Document.TextEditorProperties.BracketMatchingStyle = option.BracketMatchingStyle; editor.Document.TextEditorProperties.ShowMatchingBracket = option.ShowMatchingBracket; editor.Document.TextEditorProperties.ShowLineNumbers = option.ShowLineNumbers; editor.Document.TextEditorProperties.ShowSpaces = option.ShowSpaces; editor.Document.TextEditorProperties.ShowWideSpaces = option.ShowWideSpaces; editor.Document.TextEditorProperties.ShowTabs = option.ShowTabs; editor.Document.TextEditorProperties.ShowEOLMarker = option.ShowEOLMarker; editor.Document.TextEditorProperties.ShowInvalidLines = option.ShowInvalidLines; editor.Document.TextEditorProperties.IsIconBarVisible = option.IsIconBarVisible; editor.Document.TextEditorProperties.EnableFolding = option.EnableFolding; editor.Document.TextEditorProperties.ShowHorizontalRuler = option.ShowHorizontalRuler; editor.Document.TextEditorProperties.ShowVerticalRuler = option.ShowVerticalRuler; editor.Document.TextEditorProperties.ConvertTabsToSpaces = option.ConvertTabsToSpaces; editor.Document.TextEditorProperties.UseAntiAliasedFont = option.UseAntiAliasedFont; editor.Document.TextEditorProperties.CreateBackupCopy = option.CreateBackupCopy; editor.Document.TextEditorProperties.MouseWheelScrollDown = option.MouseWheelScrollDown; editor.Document.TextEditorProperties.MouseWheelTextZoom = option.MouseWheelTextZoom; editor.Document.TextEditorProperties.HideMouseCursor = option.HideMouseCursor; editor.Document.TextEditorProperties.CutCopyWholeLine = option.CutCopyWholeLine; editor.Document.TextEditorProperties.VerticalRulerRow = option.VerticalRulerRow; editor.Document.TextEditorProperties.LineViewerStyle = option.LineViewerStyle; editor.Document.TextEditorProperties.LineTerminator = option.LineTerminator; editor.Document.TextEditorProperties.AutoInsertCurlyBracket = option.AutoInsertCurlyBracket; editor.Document.TextEditorProperties.UseCustomLine = option.UseCustomLine; GlobalStatus.FormManager.MainForm.UpdateStatusBar(editor); editor.OptionsChanged(); }
/// <summary> /// エディタオプションを取得する /// </summary> /// <param name="type">取得するファイルタイプ</param> /// <returns>エディタオプション</returns> public EditorOption GetEditorOption(FileType.KrkrType type) { if (type != FileType.KrkrType.Kag && type != FileType.KrkrType.Tjs) { //KAGとTJS以外はその他のファイルとして扱う type = FileType.KrkrType.Unknown; } if (GlobalStatus.EditorOption.ContainsKey(type) == false) { string filePath = GetEditorOptionFilePath(type); GlobalStatus.EditorOption.Add(type, EditorOption.LoadFile(filePath)); } return(GlobalStatus.EditorOption[type]); }
/// <summary> /// 項目選択決定時にエディタへのアクション /// </summary> /// <param name="textArea">操作するエディタ</param> /// <param name="ch">入力された文字</param> /// <returns>成功したときtrue</returns> public bool InsertAction(ICSharpCode.TextEditor.TextArea textArea, char ch) { string text = ""; EditorOption option = GlobalStatus.EditorManager.GetEditorOption(FileType.KrkrType.Kag); if ((m_kind == Kind.AttrValue) && option.KagCompOption.UseAttrValueDqRegion) { text = "\"" + m_text + "\""; } else { text = m_text; } textArea.InsertString(text); return(false); }
/// <summary> /// ファイルを読み込んで文字コードを返す /// </summary> /// <param name="fileName">ファイル名</param> /// <returns>文字コード</returns> private System.Text.Encoding GetEncoding(string fileName) { System.Text.Encoding enc = GlobalStatus.TextEnc.GetFileEncoding(fileName); if (enc != System.Text.Encoding.Unicode && enc != System.Text.Encoding.GetEncoding("shift_jis")) //吉里吉里で扱える文字コードか? { EditorOption option = this.GetEditorOption(fileName); //変換するべきエンコードを取得する if (MessageBox.Show(String.Format("今開こうとしたファイルは {0} で保存されています。" + "\n吉里吉里で読み込めるように {1} に変換しますか?" , enc.EncodingName, option.Encoding.EncodingName) , "情報", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { //設定されたエンコード(ShiftJIS又はUnicode)に変換し保存する GlobalStatus.TextEnc.SaveToFile(fileName, option.Encoding.WebName); enc = GlobalStatus.TextEnc.GetFileEncoding(fileName); } } return(enc); }
/// <summary> /// KAG属性値入力補完データリストを取得する /// </summary> /// <param name="attr">属性情報</param> /// <param name="compInfo">入力補完情報</param> /// <returns>入力補完データリスト</returns> public static KagCompletionData[] GetCompletionDataList(KagMacroAttr attr, KagTagKindInfo compInfo) { if (attr == null) { return(null); //何も返せない } //設定取得 EditorOption option = GlobalStatus.EditorManager.GetEditorOption(FileType.KrkrType.Kag); if (option == null) { return(null); //何も返せない } string[] valueTypeList = splitAttrValue(attr.ValueType); if (valueTypeList == null) { return(null); } List <KagCompletionData> dataList = new List <KagCompletionData>(); foreach (string valueType in valueTypeList) { //属性値リスト取得 string[] valueList = getAttrValueList(valueType, option.KagCompOption, compInfo); if (valueList == null) { continue; } //取得した属性値を追加 foreach (string value in valueList) { dataList.Add(new KagCompletionData(value, attr.Comment, KagCompletionData.Kind.AttrValue)); } } return(dataList.ToArray()); }
/// <summary> /// エディタウィンドウを初期化する /// </summary> public void SetEditorOption() { EditorOption option = EditorOption.LoadFile(ConstEnvOption.DefOptionFilePath); resultEditor.Encoding = option.Encoding; resultEditor.Font = option.Font; resultEditor.Document.TextEditorProperties.AllowCaretBeyondEOL = option.AllowCaretBeyondEOL; resultEditor.Document.TextEditorProperties.TabIndent = option.TabIndent; resultEditor.Document.TextEditorProperties.IndentationSize = option.IndentationSize; resultEditor.Document.TextEditorProperties.IndentStyle = option.IndentStyle; resultEditor.Document.TextEditorProperties.DocumentSelectionMode = option.DocumentSelectionMode; resultEditor.Document.TextEditorProperties.BracketMatchingStyle = option.BracketMatchingStyle; resultEditor.Document.TextEditorProperties.ShowMatchingBracket = option.ShowMatchingBracket; resultEditor.Document.TextEditorProperties.ShowLineNumbers = option.ShowLineNumbers; resultEditor.Document.TextEditorProperties.ShowSpaces = option.ShowSpaces; resultEditor.Document.TextEditorProperties.ShowWideSpaces = option.ShowWideSpaces; resultEditor.Document.TextEditorProperties.ShowTabs = option.ShowTabs; resultEditor.Document.TextEditorProperties.ShowEOLMarker = option.ShowEOLMarker; resultEditor.Document.TextEditorProperties.ShowInvalidLines = option.ShowInvalidLines; resultEditor.Document.TextEditorProperties.IsIconBarVisible = option.IsIconBarVisible; resultEditor.Document.TextEditorProperties.EnableFolding = option.EnableFolding; resultEditor.Document.TextEditorProperties.ShowHorizontalRuler = false; resultEditor.Document.TextEditorProperties.ShowVerticalRuler = false; resultEditor.Document.TextEditorProperties.ConvertTabsToSpaces = option.ConvertTabsToSpaces; resultEditor.Document.TextEditorProperties.UseAntiAliasedFont = option.UseAntiAliasedFont; resultEditor.Document.TextEditorProperties.CreateBackupCopy = option.CreateBackupCopy; resultEditor.Document.TextEditorProperties.MouseWheelScrollDown = option.MouseWheelScrollDown; resultEditor.Document.TextEditorProperties.MouseWheelTextZoom = option.MouseWheelTextZoom; resultEditor.Document.TextEditorProperties.HideMouseCursor = option.HideMouseCursor; resultEditor.Document.TextEditorProperties.CutCopyWholeLine = option.CutCopyWholeLine; resultEditor.Document.TextEditorProperties.VerticalRulerRow = option.VerticalRulerRow; resultEditor.Document.TextEditorProperties.LineViewerStyle = option.LineViewerStyle; resultEditor.Document.TextEditorProperties.LineTerminator = option.LineTerminator; resultEditor.Document.TextEditorProperties.AutoInsertCurlyBracket = option.AutoInsertCurlyBracket; resultEditor.Document.TextEditorProperties.UseCustomLine = option.UseCustomLine; resultEditor.OptionsChanged(); }