예제 #1
0
        public object Deserialize(StructuredText storage)
        {
            RenderProfile prof = new RenderProfile();
            prof.FontName = storage.Get("font-name", "Courier New");
            prof.CJKFontName = storage.Get("cjk-font-name",
                               storage.Get("japanese-font-name",
                               storage.Get("chinese-font-name", "Courier New")));
            prof.FontSize = ParseUtil.ParseFloat(storage.Get("font-size"), 10.0f);
            prof.LineSpacing = ParseUtil.ParseInt(storage.Get("line-spacing"), 0);
            prof.UseClearType = ParseUtil.ParseBool(storage.Get("clear-type"), false);
            prof.EnableBoldStyle = ParseUtil.ParseBool(storage.Get("enable-bold-style"), true);
            prof.ForceBoldStyle = ParseUtil.ParseBool(storage.Get("force-bold-style"), false);
            prof.ForeColor = ParseUtil.ParseColor(storage.Get("text-color"), Color.FromKnownColor(KnownColor.WindowText));
            prof.BackColor = ParseUtil.ParseColor(storage.Get("back-color"), Color.FromKnownColor(KnownColor.Window));
            prof.ImageStyle = ParseUtil.ParseEnum<ImageStyle>(storage.Get("back-style"), ImageStyle.Center);
            prof.BackgroundImageFileName = storage.Get("back-image", "");

            prof.ESColorSet = new EscapesequenceColorSet();
            string escolor = storage.Get("escape-sequence-color");
            if (escolor != null)
                prof.ESColorSet.Load(escolor);
            prof.DarkenEsColorForBackground = ParseUtil.ParseBool(storage.Get("darken-escolor-for-background"), true);

            return prof;
        }
예제 #2
0
        public void Test1()
        {
            RenderProfile prof1 = new RenderProfile();

            prof1.FontName                = "console";
            prof1.JapaneseFontName        = "MS ゴシック";
            prof1.UseClearType            = true;
            prof1.FontSize                = 12;
            prof1.BackColor               = Color.FromKnownColor(KnownColor.Yellow);
            prof1.ForeColor               = Color.FromKnownColor(KnownColor.White);
            prof1.BackgroundImageFileName = "image-file";
            prof1.ImageStyle              = ImageStyle.Scaled;
            prof1.ESColorSet              = new EscapesequenceColorSet();
            prof1.ESColorSet[1]           = Color.Pink;

            StructuredText storage = _renderProfileSerializer.Serialize(prof1);
            //確認
            StringWriter wr = new StringWriter();

            new TextStructuredTextWriter(wr).Write(storage);
            wr.Close();
            Debug.WriteLine(wr.ToString());

            RenderProfile prof2 = (RenderProfile)_renderProfileSerializer.Deserialize(storage);

            Assert.AreEqual(prof1.FontName, prof2.FontName);
            Assert.AreEqual(prof1.JapaneseFontName, prof2.JapaneseFontName);
            Assert.AreEqual(prof1.UseClearType, prof2.UseClearType);
            Assert.AreEqual(prof1.FontSize, prof2.FontSize);
            Assert.AreEqual(prof1.BackColor.Name, prof2.BackColor.Name);
            Assert.AreEqual(prof1.ForeColor.Name, prof2.ForeColor.Name);
            Assert.AreEqual(prof1.BackgroundImageFileName, prof2.BackgroundImageFileName);
            Assert.AreEqual(prof1.ImageStyle, prof2.ImageStyle);
            Assert.AreEqual(prof1.ESColorSet.Format(), prof2.ESColorSet.Format());
        }
예제 #3
0
        private void DrawLines(Graphics g, RenderParameter param, Color baseBackColor)
        {
            RenderProfile prof  = GetRenderProfile();
            Caret         caret = _caret;

            //Rendering Core
            if (param.LineFrom <= _document.LastLineNumber)
            {
                IntPtr hdc = g.GetHdc();
                try {
                    float y = (prof.Pitch.Height + prof.LineSpacing) * param.LineFrom + BORDER;
                    for (int i = 0; i < _transientLines.Count; i++)
                    {
                        GLine line = _transientLines[i];
                        line.Render(hdc, prof, caret, baseBackColor, BORDER, (int)y);
                        if (line.IsPeriodicRedrawRequired())
                        {
                            _requiresPeriodicRedraw = true;
                        }
                        y += prof.Pitch.Height + prof.LineSpacing;
                    }
                }
                finally {
                    g.ReleaseHdc(hdc);
                }
            }
        }
예제 #4
0
        public StructuredText Serialize(object obj)
        {
            StructuredText storage = new StructuredText(typeof(RenderProfile).FullName);
            RenderProfile  prof    = (RenderProfile)obj;

            storage.Set("font-name", prof.FontName);
            storage.Set("cjk-font-name", prof.CJKFontName);
            storage.Set("font-size", prof.FontSize.ToString());
            storage.Set("line-spacing", prof.LineSpacing.ToString());
            if (prof.UseClearType)
            {
                storage.Set("clear-type", "true");
            }
            if (!prof.EnableBoldStyle)
            {
                storage.Set("enable-bold-style", "false");
            }
            if (prof.ForceBoldStyle)
            {
                storage.Set("force-bold-style", "true");
            }
            storage.Set("text-color", prof.ForeColor.Name);
            storage.Set("back-color", prof.BackColor.Name);
            if (prof.BackgroundImageFileName.Length > 0)
            {
                storage.Set("back-image", prof.BackgroundImageFileName);
                storage.Set("back-style", prof.ImageStyle.ToString());
            }
            if (!prof.ESColorSet.IsDefault)
            {
                storage.Set("escape-sequence-color", prof.ESColorSet.Format());
            }
            storage.Set("darken-escolor-for-background", prof.DarkenEsColorForBackground.ToString());
            return(storage);
        }
예제 #5
0
        public object Deserialize(StructuredText storage)
        {
            RenderProfile prof = new RenderProfile();

            prof.FontName    = storage.Get("font-name", "Courier New");
            prof.CJKFontName = storage.Get("cjk-font-name",
                                           storage.Get("japanese-font-name",
                                                       storage.Get("chinese-font-name", "Courier New")));
            prof.FontSize                = ParseUtil.ParseFloat(storage.Get("font-size"), 10.0f);
            prof.LineSpacing             = ParseUtil.ParseInt(storage.Get("line-spacing"), 0);
            prof.UseClearType            = ParseUtil.ParseBool(storage.Get("clear-type"), false);
            prof.EnableBoldStyle         = ParseUtil.ParseBool(storage.Get("enable-bold-style"), true);
            prof.ForceBoldStyle          = ParseUtil.ParseBool(storage.Get("force-bold-style"), false);
            prof.ForeColor               = ParseUtil.ParseColor(storage.Get("text-color"), Color.FromKnownColor(KnownColor.WindowText));
            prof.BackColor               = ParseUtil.ParseColor(storage.Get("back-color"), Color.FromKnownColor(KnownColor.Window));
            prof.ImageStyle              = ParseUtil.ParseEnum <ImageStyle>(storage.Get("back-style"), ImageStyle.Center);
            prof.BackgroundImageFileName = storage.Get("back-image", "");

            prof.ESColorSet = new EscapesequenceColorSet();
            string escolor = storage.Get("escape-sequence-color");

            if (escolor != null)
            {
                prof.ESColorSet.Load(escolor);
            }
            prof.DarkenEsColorForBackground = ParseUtil.ParseBool(storage.Get("darken-escolor-for-background"), true);

            return(prof);
        }
        private void DrawLines(Graphics g, RenderParameter param)
        {
            RenderProfile prof = GetRenderProfile();

            //Rendering Core
            if (param.LineFrom <= _document.LastLineNumber)
            {
                IntPtr hdc          = g.GetHdc();
                IntPtr gdipgraphics = IntPtr.Zero;
                try {
                    if (prof.UseClearType)
                    {
                        Win32.GdipCreateFromHDC(hdc, ref gdipgraphics);
                        Win32.GdipSetTextRenderingHint(gdipgraphics, 5); //5はTextRenderingHintClearTypeGridFit
                    }

                    float y = (prof.Pitch.Height + prof.LineSpacing) * param.LineFrom + BORDER;
                    for (int i = 0; i < _transientLines.Count; i++)
                    {
                        GLine line = _transientLines[i];
                        line.Render(hdc, prof, BORDER, (int)y);
                        y += prof.Pitch.Height + prof.LineSpacing;
                    }
                }
                finally {
                    if (gdipgraphics != IntPtr.Zero)
                    {
                        Win32.GdipDeleteGraphics(gdipgraphics);
                    }
                    g.ReleaseHdc(hdc);
                }
            }
        }
        private void DrawBoldUnderlineCaret(Graphics g, RenderParameter param, int x, int y)
        {
            RenderProfile profile = GetRenderProfile();
            float         xchar   = BORDER + profile.Pitch.Width * x;
            float         ychar   = BORDER + (profile.Pitch.Height + profile.LineSpacing) * y;

            this.DrawCaret_Box(g, xchar, ychar + profile.Pitch.Height - 3, profile.Pitch.Width, 3.0f);
        }
예제 #8
0
 internal Brush ToBrush(RenderProfile p)
 {
     if (_brush != null)
     {
         _brush = new SolidBrush(_color == Color.Empty?p.ForeColor:_color);
     }
     return(_brush);
 }
예제 #9
0
 //Pen
 internal Pen ToPen(RenderProfile p)
 {
     if (_pen == null)
     {
         _pen = new Pen(_color == Color.Empty ? p.ForeColor : _color);
     }
     return(_pen);
 }
예제 #10
0
        //行数で表示可能な高さを返す
        protected virtual int GetHeightInLines()
        {
            RenderProfile prof   = GetRenderProfile();
            float         ch     = prof.Pitch.Height + prof.LineSpacing;
            int           height = (int)Math.Floor((this.ClientSize.Height - BORDER * 2 + prof.LineSpacing) / ch);

            return((height > 0) ? height : 0);
        }
        private void DrawBarCaret(Graphics g, RenderParameter param, int x, int y)
        {
            RenderProfile profile = GetRenderProfile();
            float         xchar   = BORDER + profile.Pitch.Width * x;
            float         ychar   = BORDER + (profile.Pitch.Height + profile.LineSpacing) * y;

            //this.DrawCaret_Box(g,xchar,ychar+2,2.0f,profile.Pitch.Height-1);
            this.DrawCaret_Box(g, xchar, ychar + 1, 2.0f, profile.Pitch.Height - 1);
        }
        //_documentの更新状況を見て適切な領域のControl.Invalidate()を呼ぶ。
        //また、コントロールを所有していないスレッドから呼んでもOKなようになっている。
        protected void InvalidateEx()
        {
            if (this.IsDisposed)
            {
                return;
            }
            bool      full_invalidate = true;
            Rectangle r = new Rectangle();

            if (_document != null)
            {
                if (_document.InvalidatedRegion.IsEmpty)
                {
                    return;
                }
                InvalidatedRegion rgn = _document.InvalidatedRegion.GetCopyAndReset();
                if (rgn.IsEmpty)
                {
                    return;
                }
                if (!rgn.InvalidatedAll)
                {
                    full_invalidate = false;
                    r.X             = 0;
                    r.Width         = this.ClientSize.Width;
                    int           topLine = GetTopLine().ID;
                    int           y1      = rgn.LineIDStart - topLine;
                    int           y2      = rgn.LineIDEnd + 1 - topLine;
                    RenderProfile prof    = GetRenderProfile();
                    r.Y      = BORDER + (int)(y1 * (prof.Pitch.Height + prof.LineSpacing));
                    r.Height = (int)((y2 - y1) * (prof.Pitch.Height + prof.LineSpacing)) + 1;
                }
            }

            if (this.InvokeRequired)
            {
                if (full_invalidate)
                {
                    this.BeginInvoke((MethodInvoker) delegate(){ Invalidate(); });
                }
                else
                {
                    this.BeginInvoke((MethodInvoker) delegate(){ Invalidate(r); });
                }
            }
            else
            {
                if (full_invalidate)
                {
                    Invalidate();
                }
                else
                {
                    Invalidate(r);
                }
            }
        }
        /// <summary>
        /// <ja>指定した点が、何行目・何列目の文字境界に対応するかを計算します。</ja>
        /// </summary>
        /// <param name="clientPoint"><ja>コントロールのクライアント座標で点を指定します。</ja></param>
        /// <returns><ja>指定した点が、何行何列目の文字境界に最も近いかを返します。
        /// 最も左上の境界が (0,0) に対応します。</ja></returns>
        protected Gdi::Point ClientPointToCharBorder(Gdi::Point clientPoint)
        {
            RenderProfile prof  = this.GetRenderProfile();
            SizeF         pitch = prof.Pitch;
            float         x     = (clientPoint.X - BORDER) / pitch.Width;
            float         y     = (clientPoint.Y - BORDER) / (pitch.Height + prof.LineSpacing);

            return(new Gdi::Point(
                       ((int)(x + 0.5f)).Clamp(0, Int32.MaxValue),
                       ((int)y).Clamp(0, Int32.MaxValue)));
        }
예제 #14
0
        private void DrawUnderLineCaret(Graphics g, RenderParameter param, int x, int y)
        {
            RenderProfile profile = GetRenderProfile();
            PointF        pt1     = new PointF(profile.Pitch.Width * x + BORDER + 2, (profile.Pitch.Height + profile.LineSpacing) * y + BORDER + profile.Pitch.Height);
            PointF        pt2     = new PointF(pt1.X + profile.Pitch.Width - 2, pt1.Y);
            Pen           p       = _caret.ToPen(profile);

            g.DrawLine(p, pt1, pt2);
            pt1.Y += 1;
            pt2.Y += 1;
            g.DrawLine(p, pt1, pt2);
        }
        /// <summary>
        /// 表示プロファイルの編集画面を呼び出します。
        /// </summary>
        /// <param name="profile"></param>
        /// <returns></returns>
        public static RenderProfile CallEditRenderProfile(RenderProfile profile)
        {
            EditRenderProfile profileDialog = new EditRenderProfile(profile);

            if (profileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                //
                // [OK]ボタンが押された場合は編集された表示プロファイルを返します。
                //
                return profileDialog.Result;
            }
            else
            {
                //
                // キャンセルされた場合はnullを返します。
                //
                return null;
            }
        }
        protected override void Dispose(bool disposing)
        {
            if (_privateRenderProfile != null)
            {
                _privateRenderProfile.Dispose();
                _privateRenderProfile = null;
            }

            base.Dispose(disposing);
            if (disposing)
            {
                _caret.Dispose();
                if (_timer != null)
                {
                    _timer.Close();
                }
                _splitMark.Pen.Dispose();
            }

            bgdrawer.Dispose();
        }
예제 #17
0
        /// <summary>
        /// <ja>コピーして作成します。</ja>
        /// <en>Initializes with another instance.</en>
        /// </summary>
        public RenderProfile(RenderProfile src)
        {
            _fontName        = src._fontName;
            _cjkFontName     = src._cjkFontName;
            _fontSize        = src._fontSize;
            _lineSpacing     = src._lineSpacing;
            _useClearType    = src._useClearType;
            _enableBoldStyle = src._enableBoldStyle;
            _forceBoldStyle  = src._forceBoldStyle;
            _cjkFont         = _font = null;

            _forecolor = src._forecolor;
            _bgcolor   = src._bgcolor;
#if !MACRODOC
            _esColorSet = (EscapesequenceColorSet)src._esColorSet.Clone();
#endif
            _bgbrush = _brush = null;

            _backgroundImageFileName = src._backgroundImageFileName;
            _imageLoadIsAttempted    = false;
            _imageStyle = src.ImageStyle;
        }
예제 #18
0
        //派生型であることを強制することなどのためにoverrideすることを許す
        public virtual void SetContent(CharacterDocument doc)
        {
            RenderProfile prof = GetRenderProfile();

            this.BackColor = prof.BackColor;
            _document      = doc;
            this.EnabledEx = doc != null;

            if (_timer != null)
            {
                _timer.Close();
            }
            if (this.EnabledEx)
            {
                _timer     = WindowManagerPlugin.Instance.CreateTimer(TIMER_INTERVAL, new TimerDelegate(OnWindowManagerTimer));
                _tickCount = 0;
            }

            if (_enableAutoScrollBarAdjustment)
            {
                AdjustScrollBar();
            }
        }
예제 #19
0
        public EditRenderProfile(RenderProfile prof) {
            //
            // Windows フォーム デザイナ サポートに必要です。
            //
            InitializeComponent();
            StringResource sr = TerminalUIPlugin.Instance.Strings;
            _imageStyleBox.Items.AddRange(EnumListItem<ImageStyle>.GetListItems());
            this._bgColorLabel.Text = sr.GetString("Form.EditRenderProfile._bgColorLabel");
            this._textColorLabel.Text = sr.GetString("Form.EditRenderProfile._textColorLabel");
            this._fontSelectButton.Text = sr.GetString("Form.EditRenderProfile._fontSelectButton");
            this._fontLabel.Text = sr.GetString("Form.EditRenderProfile._fontLabel");
            this._backgroundImageLabel.Text = sr.GetString("Form.EditRenderProfile._backgroungImageLabel");
            this._imageStyleLabel.Text = sr.GetString("Form.EditRenderProfile._imageStyleLabel");
            this._cancelButton.Text = sr.GetString("Common.Cancel");
            this._okButton.Text = sr.GetString("Common.OK");
            this._setToDefaultButton.Text = sr.GetString("Form.EditRenderProfile._setToDefaultButton");
            this._fontSample.Text = sr.GetString("Common.FontSample");
            this._editColorEscapeSequence.Text = sr.GetString("Form.EditRenderProfile._editEscapeSequenceColorBox");
            this.Text = sr.GetString("Form.EditRenderProfile.Text");

            _profile = prof == null ? TerminalUIPlugin.Instance.TerminalEmulatorPlugin.TerminalEmulatorOptions.CreateRenderProfile() : (RenderProfile)prof.Clone();
            InitUI();
        }
예제 #20
0
        //自己サイズからScrollBarを適切にいじる
        public void AdjustScrollBar()
        {
            if (_document == null)
            {
                return;
            }
            RenderProfile prof        = GetRenderProfile();
            float         ch          = prof.Pitch.Height + prof.LineSpacing;
            int           largechange = (int)Math.Floor((this.ClientSize.Height - BORDER * 2 + prof.LineSpacing) / ch); //きちんと表示できる行数をLargeChangeにセット
            int           current     = GetTopLine().ID - _document.FirstLineNumber;
            int           size        = Math.Max(_document.Size, current + largechange);

            if (size <= largechange)
            {
                _VScrollBar.Enabled = false;
            }
            else
            {
                _VScrollBar.Enabled     = true;
                _VScrollBar.LargeChange = largechange;
                _VScrollBar.Maximum     = size - 1; //この-1が必要なのが妙な仕様だ
            }
        }
예제 #21
0
        /// <summary>
        /// <ja>コピーして作成します。</ja>
        /// <en>Initializes with another instance.</en>
        /// </summary>
        public RenderProfile(RenderProfile src) {
            _fontName = src._fontName;
            _cjkFontName = src._cjkFontName;
            _fontSize = src._fontSize;
            _lineSpacing = src._lineSpacing;
            _useClearType = src._useClearType;
            _enableBoldStyle = src._enableBoldStyle;
            _forceBoldStyle = src._forceBoldStyle;
            _cjkFont = _font = null;

            _forecolor = src._forecolor;
            _bgcolor = src._bgcolor;
#if !MACRODOC
            _esColorSet = (EscapesequenceColorSet)src._esColorSet.Clone();
#endif
            _bgbrush = _brush = null;

            _backgroundImageFileName = src._backgroundImageFileName;
            _imageLoadIsAttempted = false;
            _imageStyle = src.ImageStyle;
        }
예제 #22
0
        public void Test1()
        {
            RenderProfile prof1 = new RenderProfile();
            prof1.FontName = "console";
            prof1.JapaneseFontName = "MS ゴシック";
            prof1.UseClearType = true;
            prof1.FontSize = 12;
            prof1.BackColor = Color.FromKnownColor(KnownColor.Yellow);
            prof1.ForeColor = Color.FromKnownColor(KnownColor.White);
            prof1.BackgroundImageFileName = "image-file";
            prof1.ImageStyle = ImageStyle.Scaled;
            prof1.ESColorSet = new EscapesequenceColorSet();
            prof1.ESColorSet[1] = Color.Pink;

            StructuredText storage = _renderProfileSerializer.Serialize(prof1);
            //確認
            StringWriter wr = new StringWriter();
            new TextStructuredTextWriter(wr).Write(storage);
            wr.Close();
            Debug.WriteLine(wr.ToString());

            RenderProfile prof2 = (RenderProfile)_renderProfileSerializer.Deserialize(storage);

            Assert.AreEqual(prof1.FontName, prof2.FontName);
            Assert.AreEqual(prof1.JapaneseFontName, prof2.JapaneseFontName);
            Assert.AreEqual(prof1.UseClearType, prof2.UseClearType);
            Assert.AreEqual(prof1.FontSize, prof2.FontSize);
            Assert.AreEqual(prof1.BackColor.Name, prof2.BackColor.Name);
            Assert.AreEqual(prof1.ForeColor.Name, prof2.ForeColor.Name);
            Assert.AreEqual(prof1.BackgroundImageFileName, prof2.BackgroundImageFileName);
            Assert.AreEqual(prof1.ImageStyle, prof2.ImageStyle);
            Assert.AreEqual(prof1.ESColorSet.Format(), prof2.ESColorSet.Format());
        }
예제 #23
0
        internal void Render(IntPtr hdc, RenderProfile prof, Color baseBackColor, int x, int y) {
            if (_text.Length == 0 || _text[0] == '\0')
                return; //何も描かなくてよい。これはよくあるケース

            float fx0 = (float)x;
            float fx1 = fx0;
            int y1 = y;
            int y2 = y1 + (int)prof.Pitch.Height;

            float pitch = prof.Pitch.Width;
            int defaultBackColorArgb = baseBackColor.ToArgb();

            Win32.SetBkMode(hdc, Win32.TRANSPARENT);

            GWord word = _firstWord;
            while (word != null) {
                TextDecoration dec = word.Decoration;

                IntPtr hFont = prof.CalcHFONT_NoUnderline(dec, word.CharGroup);
                Win32.SelectObject(hdc, hFont);

                uint foreColorRef = DrawUtil.ToCOLORREF(prof.CalcTextColor(dec));
                Win32.SetTextColor(hdc, foreColorRef);

                Color bkColor = prof.CalcBackColor(dec);
                bool isOpaque = (bkColor.ToArgb() != defaultBackColorArgb);
                if (isOpaque) {
                    uint bkColorRef = DrawUtil.ToCOLORREF(bkColor);
                    Win32.SetBkColor(hdc, bkColorRef);
                }

                int nextOffset = GetNextOffset(word);

                float fx2 = fx0 + pitch * nextOffset;

                if (prof.CalcBold(dec) || CharGroupUtil.IsCJK(word.CharGroup)) {
                    // It is not always true that width of a character in the CJK font is twice of a character in the ASCII font.
                    // Characters are drawn one by one to adjust pitch.

                    int step = CharGroupUtil.GetColumnsPerCharacter(word.CharGroup);
                    float charPitch = pitch * step;
                    int offset = word.Offset;
                    float fx = fx1;
                    if (isOpaque) {
                        // If background fill is required, we call ExtTextOut() with ETO_OPAQUE to draw the first character.
                        if (offset < nextOffset) {
                            Win32.RECT rect = new Win32.RECT((int)fx1, y1, (int)fx2, y2);
                            char ch = _text[offset];
                            Debug.Assert(ch != GLine.WIDECHAR_PAD);
                            unsafe {
                                Win32.ExtTextOut(hdc, rect.left, rect.top, Win32.ETO_OPAQUE, &rect, &ch, 1, null);
                            }
                        }
                        offset += step;
                        fx += charPitch;
                    }

                    for (; offset < nextOffset; offset += step) {
                        char ch = _text[offset];
                        Debug.Assert(ch != GLine.WIDECHAR_PAD);
                        unsafe {
                            Win32.ExtTextOut(hdc, (int)fx, y1, 0, null, &ch, 1, null);
                        }
                        fx += charPitch;
                    }
                }
                else {
                    int offset = word.Offset;
                    int displayLength = nextOffset - offset;
                    if (isOpaque) {
                        Win32.RECT rect = new Win32.RECT((int)fx1, y1, (int)fx2, y2);
                        unsafe {
                            fixed (char* p = &_text[offset]) {
                                Win32.ExtTextOut(hdc, rect.left, rect.top, Win32.ETO_OPAQUE, &rect, p, displayLength, null);
                            }
                        }
                    }
                    else {
                        unsafe {
                            fixed (char* p = &_text[offset]) {
                                Win32.ExtTextOut(hdc, (int)fx1, y1, 0, null, p, displayLength, null);
                            }
                        }
                    }
                }

                if (dec.Underline)
                    DrawUnderline(hdc, foreColorRef, (int)fx1, y2 - 1, (int)fx2 - (int)fx1);

                fx1 = fx2;
                word = word.Next;
            }

        }
 /// <summary>
 /// 表示プロファイル編集画面を呼び出します。
 /// </summary>
 /// <param name="profile"></param>
 /// <returns>キャンセルされた場合はnull</returns>
 public static RenderProfile CallEditRenderProfile(RenderProfile profile)
 {
     Initialize();
     return DirtyAccessUtility.CallEditRenderProfile(profile);
 }
예제 #25
0
 private void OnSetToDefault(object sender, EventArgs args) {
     _profile = TerminalUIPlugin.Instance.TerminalEmulatorPlugin.TerminalEmulatorOptions.CreateRenderProfile();
     InitUI();
 }
예제 #26
0
 public virtual void Import(ConfigNode data)
 {
     _encoding = ParseEncoding(data["encoding"]);
     _terminalType = (TerminalType)EnumDescAttribute.For(typeof(TerminalType)).FromName(data["terminal-type"], TerminalType.VT100);
     _transmitnl = (NewLine)EnumDescAttribute.For(typeof(NewLine)).FromName(data["transmit-nl"], NewLine.CR);
     _localecho = GUtil.ParseBool(data["localecho"], false);
     //_lineFeedByCR = GUtil.ParseBool((string)data["linefeed-by-cr"], false);
     _lineFeedRule = (LineFeedRule)EnumDescAttribute.For(typeof(LineFeedRule)).FromName(data["linefeed"], LineFeedRule.Normal);
     _caption = data["caption"];
     if (data.Contains("font-name")) //項目がなければ空のまま
         _renderProfile = new RenderProfile(data);
 }
예제 #27
0
 internal TerminalParam()
 {
     _encoding = EncodingType.EUC_JP;
     _logtype = LogType.None;
     _terminalType = TerminalType.XTerm;
     _localecho = false;
     _lineFeedRule = LineFeedRule.Normal;
     _transmitnl = NewLine.CR;
     _renderProfile = null;
 }
예제 #28
0
 private static RenderProfile CreateLogRenderProfile()
 {
     RenderProfile rp = new RenderProfile();
     rp.FontName = "Courier New";
     rp.FontSize = 9;
     rp.BackColor = SystemColors.Window;
     rp.ForeColor = SystemColors.WindowText;
     return rp;
 }
예제 #29
0
        private void BuildTransientDocument(PaintEventArgs e, RenderParameter param)
        {
            Rectangle     clip    = e.ClipRectangle;
            RenderProfile profile = GetRenderProfile();

            _transientLines.Clear();

            //Win32.SystemMetrics sm = GEnv.SystemMetrics;
            //param.TargetRect = new Rectangle(sm.ControlBorderWidth+1, sm.ControlBorderHeight,
            //	this.Width - _VScrollBar.Width - sm.ControlBorderWidth + 8, //この8がない値が正当だが、.NETの文字サイズ丸め問題のため行の最終文字が表示されないことがある。これを回避するためにちょっと増やす
            //	this.Height - sm.ControlBorderHeight);
            param.TargetRect = this.ClientRectangle;

            int offset1 = (int)Math.Floor((clip.Top - BORDER) / (profile.Pitch.Height + profile.LineSpacing));

            if (offset1 < 0)
            {
                offset1 = 0;
            }
            param.LineFrom = offset1;
            int offset2 = (int)Math.Floor((clip.Bottom - BORDER) / (profile.Pitch.Height + profile.LineSpacing));

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

            param.LineCount = offset2 - offset1 + 1;
            //Debug.WriteLine(String.Format("{0} {1} ", param.LineFrom, param.LineCount));

            int   topline_id = GetTopLine().ID;
            GLine l          = _document.FindLineOrNull(topline_id + param.LineFrom);

            if (l != null)
            {
                for (int i = param.LineFrom; i < param.LineFrom + param.LineCount; i++)
                {
                    _transientLines.Add(l.Clone()); //TODO クローンはきついよなあ だが描画の方が時間かかるので、その間ロックをしないためには仕方ない点もある
                    l = l.NextLine;
                    if (l == null)
                    {
                        break;
                    }
                }
            }

            //以下、_transientLinesにはparam.LineFromから示される値が入っていることに注意

            //選択領域の描画
            if (!_textSelection.IsEmpty)
            {
                TextSelection.TextPoint from = _textSelection.HeadPoint;
                TextSelection.TextPoint to   = _textSelection.TailPoint;
                l = _document.FindLineOrNull(from.Line);
                GLine t = _document.FindLineOrNull(to.Line);
                if (l != null && t != null)   //本当はlがnullではいけないはずだが、それを示唆するバグレポートがあったので念のため
                {
                    t = t.NextLine;
                    int pos = from.Column; //たとえば左端を越えてドラッグしたときの選択範囲は前行末になるので pos==TerminalWidthとなるケースがある。
                    do
                    {
                        int index = l.ID - (topline_id + param.LineFrom);
                        if (pos >= 0 && pos < l.DisplayLength && index >= 0 && index < _transientLines.Count)
                        {
                            GLine r = null;
                            if (l.ID == to.Line)
                            {
                                if (pos != to.Column)
                                {
                                    r = _transientLines[index].CreateInvertedClone(pos, to.Column);
                                }
                            }
                            else
                            {
                                r = _transientLines[index].CreateInvertedClone(pos, l.DisplayLength);
                            }

                            if (r != null)
                            {
                                _transientLines[index] = r;
                            }
                        }
                        pos = 0; //2行目からの選択は行頭から
                        l   = l.NextLine;
                    } while (l != t);
                }
            }

            AdjustCaret(_caret);
            _caret.Enabled = _caret.Enabled && (param.LineFrom <= _caret.Y && _caret.Y < param.LineFrom + param.LineCount);

            //Caret画面外にあるなら処理はしなくてよい。2番目の条件は、Attach-ResizeTerminalの流れの中でこのOnPaintを実行した場合にTerminalHeight>lines.Countになるケースがあるのを防止するため
            if (_caret.Enabled)
            {
                //ヒクヒク問題のため、キャレットを表示しないときでもこの操作は省けない
                if (_caret.Style == CaretType.Box)
                {
                    int y = _caret.Y - param.LineFrom;
                    if (y >= 0 && y < _transientLines.Count)
                    {
                        _transientLines[y].InvertCharacter(_caret.X, _caret.IsActiveTick, _caret.Color);
                    }
                }
            }
        }
예제 #30
0
 public void SetPrivateRenderProfile(RenderProfile prof)
 {
     _privateRenderProfile = prof;
 }
예제 #31
0
 internal void Import(TerminalParam r)
 {
     _encoding = r._encoding;
     _logtype = r._logtype;
     _logpath = r._logpath;
     _localecho = r._localecho;
     _transmitnl = r._transmitnl;
     _lineFeedRule = r._lineFeedRule;
     _terminalType = r._terminalType;
     _renderProfile = r._renderProfile == null ? null : new RenderProfile(r._renderProfile);
     _caption = r._caption;
 }
예제 #32
0
        //描画の本体
        protected override sealed void OnPaint(PaintEventArgs e)
        {
#if ONPAINT_TIME_MEASUREMENT
            Stopwatch onPaintSw = (_onPaintTimeObserver != null) ? Stopwatch.StartNew() : null;
#endif

            base.OnPaint(e);

            try {
                if (_document != null)
                {
                    ShowVScrollBar();
                }
                else
                {
                    HideVScrollBar();
                }

                if (_enabled && !this.DesignMode)
                {
                    Rectangle     clip       = e.ClipRectangle;
                    Graphics      g          = e.Graphics;
                    RenderProfile profile    = GetRenderProfile();
                    int           paneheight = GetHeightInLines();

                    // determine background color of the view
                    Color backColor;
                    if (_document.IsApplicationMode)
                    {
                        backColor = _document.ApplicationModeBackColor;
                        if (backColor.IsEmpty)
                        {
                            backColor = profile.BackColor;
                        }
                    }
                    else
                    {
                        backColor = profile.BackColor;
                    }

                    if (this.BackColor != backColor)
                    {
                        this.BackColor = backColor; // set background color of the view
                    }
                    // draw background image if it is required.
                    if (!_document.IsApplicationMode)
                    {
                        Image img = profile.GetImage();
                        if (img != null)
                        {
                            DrawBackgroundImage(g, img, profile.ImageStyle, clip);
                        }
                    }

                    //描画用にテンポラリのGLineを作り、描画中にdocumentをロックしないようにする
                    //!!ここは実行頻度が高いのでnewを毎回するのは避けたいところだ
                    RenderParameter param = new RenderParameter();
                    _caret.Enabled = _caret.Enabled && this.Focused; //TODO さらにIME起動中はキャレットを表示しないように. TerminalControlだったらAdjustCaretでIMEをみてるので問題はない
                    lock (_document) {
                        CommitTransientScrollBar();
                        BuildTransientDocument(e, param);
                    }

                    DrawLines(g, param, backColor);

                    if (_caret.Enabled && (!_caret.Blink || _caret.IsActiveTick))   //点滅しなければEnabledによってのみ決まる
                    {
                        if (_caret.Style == CaretType.Line)
                        {
                            DrawBarCaret(g, param, _caret.X, _caret.Y);
                        }
                        else if (_caret.Style == CaretType.Underline)
                        {
                            DrawUnderLineCaret(g, param, _caret.X, _caret.Y);
                        }
                    }
                }
                //マークの描画
                _splitMark.OnPaint(e);
            }
            catch (Exception ex) {
                if (!_errorRaisedInDrawing)   //この中で一度例外が発生すると繰り返し起こってしまうことがままある。なので初回のみ表示してとりあえず切り抜ける
                {
                    _errorRaisedInDrawing = true;
                    RuntimeUtil.ReportException(ex);
                }
            }

#if ONPAINT_TIME_MEASUREMENT
            if (onPaintSw != null)
            {
                onPaintSw.Stop();
                if (_onPaintTimeObserver != null)
                {
                    _onPaintTimeObserver(onPaintSw);
                }
            }
#endif
        }
        //描画の本体
        protected override sealed void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            try {
                if (_document != null)
                {
                    ShowVScrollBar();
                }
                else
                {
                    HideVScrollBar();
                }

                if (_enabled && !this.DesignMode)
                {
                    Rectangle     clip       = e.ClipRectangle;
                    Graphics      g          = e.Graphics;
                    RenderProfile profile    = GetRenderProfile();
                    int           paneheight = GetHeightInLines();

                    if (_document.BackColor != profile.BackColor)
                    {
                        if (_document.IsApplicationMode)
                        {
                            if (this.BackColor != _document.BackColor)
                            {
                                this.BackColor = _document.BackColor;
                                _drawbgImage   = false;
                            }
                        }
                        else
                        {
                            this.BackColor      = profile.BackColor;
                            _document.BackColor = profile.BackColor;
                            _drawbgImage        = true;
                        }
                    }
                    if (_drawbgImage)
                    {
                        Image img = profile.GetImage();
                        if (img != null)
                        {
                            DrawBackgroundImage(g, img, profile.ImageStyle, clip);
                        }
                    }

                    //描画用にテンポラリのGLineを作り、描画中にdocumentをロックしないようにする
                    //!!ここは実行頻度が高いのでnewを毎回するのは避けたいところだ
                    RenderParameter param = new RenderParameter();
                    _caret.Enabled = _caret.Enabled && this.Focused; //TODO さらにIME起動中はキャレットを表示しないように. TerminalControlだったらAdjustCaretでIMEをみてるので問題はない
                    lock (_document) {
                        CommitTransientScrollBar();
                        BuildTransientDocument(e, param);
                    }

                    DrawLines(g, param);

                    if (_caret.Enabled && (!_caret.Blink || _caret.IsActiveTick)) //点滅しなければEnabledによってのみ決まる
                    {
                        if (_caret.Style == CaretType.Line)
                        {
                            DrawBarCaret(g, param, _caret.X, _caret.Y);
                        }
                        else if (_caret.Style == CaretType.Underline)
                        {
                            DrawUnderLineCaret(g, param, _caret.X, _caret.Y);
                        }
                        else if (_caret.Style == CaretType.BoldUnderline)
                        {
                            DrawBoldUnderlineCaret(g, param, _caret.X, _caret.Y);
                        }
                    }
                }
                //マークの描画
                _splitMark.OnPaint(e);
            }
            catch (Exception ex) {
                if (!_errorRaisedInDrawing) //この中で一度例外が発生すると繰り返し起こってしまうことがままある。なので初回のみ表示してとりあえず切り抜ける
                {
                    _errorRaisedInDrawing = true;
                    RuntimeUtil.ReportException(ex);
                }
            }
        }
예제 #34
0
 public void SetPrivateRenderProfile(RenderProfile prof) {
     _privateRenderProfile = prof;
 }
예제 #35
0
파일: Caret.cs 프로젝트: FNKGino/poderosa
 //Pen
 internal Pen ToPen(RenderProfile p)
 {
     if (_pen == null) {
         _pen = new Pen(_color == Color.Empty ? p.ForeColor : _color);
     }
     return _pen;
 }