Esempio n. 1
0
        protected TextDecoration SelectForeColor(TextDecoration dec, int index)
        {
            RenderProfile prof = GetRenderProfile();
            ESColor       c    = prof.ESColorSet[index];

            return(dec.GetCopyWithTextColor(c.Color));
        }
Esempio n. 2
0
        public EditRenderProfile(RenderProfile prof)
        {
            //
            // Windows �t�H�[�� �f�U�C�i �T�|�[�g�ɕK�v�ł��B
            //
            InitializeComponent();
            _imageStyleBox.Items.AddRange(EnumDescAttributeT.For(typeof(ImageStyle)).DescriptionCollection());
            this._bgColorLabel.Text = GApp.Strings.GetString("Form.EditRenderProfile._bgColorLabel");
            this._textColorLabel.Text = GApp.Strings.GetString("Form.EditRenderProfile._textColorLabel");
            this._fontSelectButton.Text = GApp.Strings.GetString("Form.EditRenderProfile._fontSelectButton");
            this._fontLabel.Text = GApp.Strings.GetString("Form.EditRenderProfile._fontLabel");
            this._backgroundImageLabel.Text = GApp.Strings.GetString("Form.EditRenderProfile._backgroungImageLabel");
            this._imageStyleLabel.Text = GApp.Strings.GetString("Form.EditRenderProfile._imageStyleLabel");
            this._cancelButton.Text = GApp.Strings.GetString("Common.Cancel");
            this._okButton.Text = GApp.Strings.GetString("Common.OK");
            this._fontSample.Text = GApp.Strings.GetString("Common.FontSample");
            this._editColorEscapeSequence.Text = GApp.Strings.GetString("Form.EditRenderProfile._editEscapeSequenceColorBox");
            this.Text = GApp.Strings.GetString("Form.EditRenderProfile.Text");

            //
            // TODO: InitializeComponent �Ăяo���̌�ɁA�R���X�g���N�^ �R�[�h��lj����Ă��������B
            //
            _profile = new RenderProfile(prof==null? GEnv.DefaultRenderProfile : prof);
            InitUI();
        }
Esempio n. 3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="prof">
 /// <ja>[mwg] 描画設定を保持する RenderProfile インスタンスを指定します。
 /// このインスタンスはこのメソッド呼び出し直後に破壊される可能性があります。
 /// </ja>
 /// </param>
 /// <remarks>
 /// <ja>[mwg] ApplyRenderProfile の実装に際して。
 /// 引数に渡される RenderProfile インスタンスは独自の寿命を持ちます。
 /// RenderProfile インスタンスを保持したい場合には、
 /// Clone メソッドでインスタンスをコピーして保持する様にして下さい。
 /// </ja>
 /// </remarks>
 public void ApplyRenderProfile(RenderProfile prof)
 {
     if (this.EnabledEx)
     {
         this.BackColor = prof.BackColor;
         Size ts = CalcTerminalSize(prof);
         if (!IsConnectionClosed() && (ts.Width != GetDocument().TerminalWidth || ts.Height != GetDocument().TerminalHeight))
         {
             ResizeTerminal(ts.Width, ts.Height);
         }
         Invalidate();
     }
 }
Esempio n. 4
0
 public void ApplyTerminalOptions(ITerminalEmulatorOptions opt)
 {
     if (this.EnabledEx)
     {
         if (GetTerminalSettings().UsingDefaultRenderProfile)
         {
             using (RenderProfile profile = opt.CreateRenderProfile())
                 ApplyRenderProfile(profile);
         }
         _caret.Style = opt.CaretType;
         _caret.Blink = opt.CaretBlink;
         _caret.Color = opt.CaretColor;
         _caret.Reset();
     }
 }
Esempio n. 5
0
        protected TextDecoration SelectBackgroundColor(TextDecoration dec, int index)
        {
            RenderProfile prof = GetRenderProfile();
            ESColor       c    = prof.ESColorSet[index];

            Color color;

            if (prof.DarkenEsColorForBackground && !c.IsExactColor)
            {
                color = DrawUtil.DarkColor(c.Color);
            }
            else
            {
                color = c.Color;
            }

            return(dec.GetCopyWithBackColor(color));
        }
Esempio n. 6
0
        public Size CalcTerminalSize(RenderProfile prof)
        {
            SizeF charPitch = prof.Pitch;

            Win32.SystemMetrics sm = GEnv.SystemMetrics;
            int width  = (int)Math.Floor((float)(this.ClientSize.Width - sm.ScrollBarWidth - CharacterDocumentViewer.BORDER * 2) / charPitch.Width);
            int height = (int)Math.Floor((float)(this.ClientSize.Height - CharacterDocumentViewer.BORDER * 2 + prof.LineSpacing) / (charPitch.Height + prof.LineSpacing));

            if (width <= 0)
            {
                width = 1;                         //極端なリサイズをすると負の値になることがある
            }
            if (height <= 0)
            {
                height = 1;
            }
            return(new Size(width, height));
        }
Esempio n. 7
0
        /// <summary>
        /// <ja>コピーして作成します。</ja>
        /// <en>Initializes with another instance.</en>
        /// </summary>
        public RenderProfile(RenderProfile src)
        {
#if !MACRODOC
            _fontName         = src._fontName;
            _japaneseFontName = src._japaneseFontName;
            _fontSize         = src._fontSize;
            _useClearType     = src._useClearType;
            _japaneseFont     = _font = null;

            _forecolor  = src._forecolor;
            _bgcolor    = src._bgcolor;
            _esColorSet = (EscapesequenceColorSet)src._esColorSet.Clone();
            _bgbrush    = _brush = null;

            _backgroundImageFileName = src._backgroundImageFileName;
            _imageLoadIsAttempted    = false;
            _imageStyle = src.ImageStyle;
#endif
        }
        private void AdjustListBox()
        {
            this.SuspendLayout();
            _listBox.Size = new Size(0, 0); //こうしておくと余白が生じてしまうことはなくなる
            RenderProfile rp    = _context.RenderProfile;
            SizeF         pitch = rp.Pitch;

            _listBox.Font        = rp.DefaultFont;
            _listBox.BackColor   = rp.BackColor;
            _listBox.ForeColor   = rp.ForeColor;
            _listBox.MaximumSize = new Size((int)(pitch.Width * 80), (int)(pitch.Height * 10)); //何文字分かはPreference化してもいい
            _listBox.Items.Clear();
            foreach (IntelliSenseItem item in _context.Candidates)
            {
                _listBox.Items.Add(item.Format(_context.CurrentScheme.DefaultDelimiter));
            }
            _listBox.SelectedIndexEx = _context.InitialSelectedIndex;
            this.ResumeLayout(true);
        }
        public TerminalSettings()
        {
            //IPoderosaCulture culture = TerminalEmulatorPlugin.Instance.PoderosaWorld.Culture;
            //if (culture.IsJapaneseOS || culture.IsSimplifiedChineseOS || culture.IsTraditionalChineseOS || culture.IsKoreanOS)
            //  _encoding = EncodingType.UTF8;
            //else
            //  _encoding = EncodingType.ISO8859_1;
            _encoding = Poderosa.Protocols.CygwinUtil.CygwinDefaultEncoding;

            _terminalType    = TerminalType.Cygwin;
            _localecho       = false;
            _lineFeedRule    = LineFeedRule.Normal;
            _transmitnl      = NewLine.CR;
            _renderProfile   = null;
            _shellSchemeName = ShellSchemeCollection.DEFAULT_SCHEME_NAME;
            _enabledCharTriggerIntelliSense = false;
            _multiLogSettings = new MultiLogSettings();

            _listeners = new ListenerList <ITerminalSettingsChangeListener>();
        }
Esempio n. 10
0
        //Listener以外を持ってくる
        public virtual void Import(ITerminalSettings src)
        {
            _encoding     = src.Encoding;
            _terminalType = src.TerminalType;
            _localecho    = src.LocalEcho;
            _lineFeedRule = src.LineFeedRule;
            _transmitnl   = src.TransmitNL;
            _caption      = src.Caption;
            _icon         = src.Icon;
            TerminalSettings src_r = (TerminalSettings)src;

            _shellSchemeName = src_r._shellSchemeName; //ちょっとインチキ
            if (src_r._shellScheme != null)
            {
                _shellScheme = src_r._shellScheme;
                TerminalEmulatorPlugin.Instance.ShellSchemeCollection.AddDynamicChangeListener(this);
            }
            _enabledCharTriggerIntelliSense = src.EnabledCharTriggerIntelliSense;
            _renderProfile    = src.RenderProfile == null ? null : (RenderProfile)src.RenderProfile.Clone();
            _multiLogSettings = src.LogSettings == null ? null : (IMultiLogSettings)_multiLogSettings.Clone();
        }
Esempio n. 11
0
        public RenderProfile CreateRenderProfile()
        {
            //起動の高速化のため、フォントの作成は遅延評価
            RenderProfile p = new RenderProfile();

            p.FontName        = _fontName.Value;
            p.CJKFontName     = _cjkFontName.Value;
            p.FontSize        = GetFontSizeAsFloat();
            p.UseClearType    = _useClearType.Value;
            p.EnableBoldStyle = _enableBoldStyle.Value;
            p.ForceBoldStyle  = _forceBoldStyle.Value;
            p.LineSpacing     = _lineSpacing.Value;
            p.ESColorSet      = (EscapesequenceColorSet)this.EscapeSequenceColorSet.Clone();

            p.ForeColor = _textColor.Value;
            p.BackColor = _bgColor.Value;
            p.BackgroundImageFileName = _backgroundImageFileName.Value;
            p.ImageStyle = _imageStyle.Value;

            return(p);
        }
Esempio n. 12
0
        //IMEの位置合わせなど。日本語入力開始時、現在のキャレット位置からIMEをスタートさせる。
        private void AdjustIMEComposition()
        {
            TerminalDocument document = GetDocument();
            IntPtr           hIMC     = Win32.ImmGetContext(this.Handle);
            RenderProfile    prof     = GetRenderProfile();

            //フォントのセットは1回やればよいのか?
            Win32.LOGFONT lf = new Win32.LOGFONT();
            prof.CalcFont(null, CharGroup.Zenkaku).ToLogFont(lf);
            Win32.ImmSetCompositionFont(hIMC, lf);

            Win32.COMPOSITIONFORM form = new Win32.COMPOSITIONFORM();
            form.dwStyle = Win32.CFS_POINT;
            Win32.SystemMetrics sm = GEnv.SystemMetrics;
            //Debug.WriteLine(String.Format("{0} {1} {2}", document.CaretColumn, charwidth, document.CurrentLine.CharPosToDisplayPos(document.CaretColumn)));
            form.ptCurrentPos.x = sm.ControlBorderWidth + (int)(prof.Pitch.Width * (document.CaretColumn));
            form.ptCurrentPos.y = sm.ControlBorderHeight + (int)((prof.Pitch.Height + prof.LineSpacing) * (document.CurrentLineNumber - document.TopLineNumber));
            bool r = Win32.ImmSetCompositionWindow(hIMC, ref form);

            Debug.Assert(r);
            Win32.ImmReleaseContext(this.Handle, hIMC);
        }
Esempio n. 13
0
        private static void SessionEntryPoint(AbstractTerminal terminal, CommandResultDocument document)
        {
            try {
                TerminalControl tc = terminal.TerminalHost.TerminalControl;
                Debug.Assert(tc != null);
                RenderProfile          rp          = (RenderProfile)tc.GetRenderProfile().Clone();
                CommandResultSession   session     = new CommandResultSession(document, rp); //現在のRenderProfileを使ってセッションを作る
                TerminalDocument       terminaldoc = terminal.GetDocument();
                PopupViewCreationParam cp          = new PopupViewCreationParam(_viewFactory);
                //結果のサイズに合わせる。ただし高さは20行を上限とする
                cp.InitialSize = new Size(tc.ClientSize.Width, (int)(RuntimeUtil.AdjustIntRange(document.Size, 0, 20) * rp.Pitch.Height) + 2);
                cp.OwnedByCommandTargetWindow = GEnv.Options.CommandPopupAlwaysOnTop;
                cp.ShowInTaskBar = GEnv.Options.CommandPopupInTaskBar;

                IWindowManager       wm     = TerminalEmulatorPlugin.Instance.GetWindowManager();
                ISessionManager      sm     = TerminalEmulatorPlugin.Instance.GetSessionManager();
                IPoderosaPopupWindow window = wm.CreatePopupView(cp);
                sm.StartNewSession(session, window.InternalView);
                sm.ActivateDocument(session.Document, ActivateReason.InternalAction);
            }
            catch (Exception ex) {
                RuntimeUtil.ReportException(ex);
            }
        }
Esempio n. 14
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);
 }
Esempio n. 15
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;
 }
Esempio n. 16
0
 internal TerminalParam()
 {
     _encoding = EncodingType.EUC_JP;
     _logtype = LogType.None;
     _terminalType = TerminalType.XTerm;
     _localecho = false;
     _lineFeedRule = LineFeedRule.Normal;
     _transmitnl = NewLine.CR;
     _renderProfile = null;
 }
Esempio n. 17
0
        /// <summary>
        /// <ja>�R�s�[���č쐬���܂��B</ja>
        /// <en>Initializes with another instance.</en>
        /// </summary>
        public RenderProfile(RenderProfile src)
        {
            #if !MACRODOC
            _fontName = src._fontName;
            _japaneseFontName = src._japaneseFontName;
            _fontSize = src._fontSize;
            _useClearType = src._useClearType;
            _japaneseFont = _font = null;

            _forecolor = src._forecolor;
            _bgcolor = src._bgcolor;
            _esColorSet = (EscapesequenceColorSet)src._esColorSet.Clone();
            _bgbrush = _brush = null;

            _backgroundImageFileName = src._backgroundImageFileName;
            _imageLoadIsAttempted = false;
            _imageStyle = src.ImageStyle;
            #endif
        }
Esempio n. 18
0
 public void ApplyRenderProfile(RenderProfile prof)
 {
     if(_fakeVisible) {
         this.BackColor = prof.BackColor;
         SizeF charPitch = prof.Pitch;
         Size ts = CalcTerminalSize(charPitch);
         if(!GetConnection().IsClosed && (ts.Width!=GetConnection().TerminalWidth || ts.Height!=GetConnection().TerminalHeight)) {
             ResizeTerminal(ts.Width, ts.Height);
         }
         Invalidate();
     }
 }
 public CommandResult ResetAllRenderProfiles(RenderProfile prof)
 {
     GEnv.DefaultRenderProfile = prof;
     foreach(ConnectionTag ct in GEnv.Connections) {
         ct.RenderProfile = null;
         if(ct.AttachedPane!=null) ct.AttachedPane.ApplyRenderProfile(prof);
     }
     return CommandResult.Success;
 }
Esempio n. 20
0
 private void DrawStringByOneChar2(IntPtr hdc, GWord word, int display_length, IntPtr bkbrush, float fx, int y, RenderProfile prof)
 {
     float pitch = prof.Pitch.Width;
     int nextoffset = WordNextOffset(word);
     if(bkbrush!=IntPtr.Zero) { //���ꂪ�Ȃ��Ɠ��{�ꕶ���s�b�`���������Ƃ��I����̂����܂��ł���ꍇ������
         Win32.RECT rect = new Win32.RECT();
         rect.left = (int)fx;
         rect.top  = y;
         rect.right = (int)(fx + pitch*display_length);
         rect.bottom = y + (int)prof.Pitch.Height;
         Win32.FillRect(hdc, ref rect, bkbrush);
     }
     for(int i=word.Offset; i<nextoffset; i++) {
         char ch = _text[i];
         if(ch=='\0') break;
         if(ch==GLine.WIDECHAR_PAD) continue;
         unsafe {
             Win32.TextOut(hdc, (int)fx, y, &ch, 1);
         }
         fx += pitch * CalcDisplayLength(ch);
     }
 }
Esempio n. 21
0
        public ConnectionTag(TerminalConnection c)
        {
            _connection = c;
            _pane = null;
            _invalidateParam = new InvalidateParam();
            _tabButton = null;
            _document = new TerminalDocument(_connection);
            _receiver = new TerminalDataReceiver(this);
            _terminated = false;
            _timer = null;
            _windowTitle = "";

            //null�̂Ƃ��̓f�t�H���g�v���t�@�C����g��
            _renderProfile = c.Param.RenderProfile;

            //VT100�w��ł�xterm�V�[�P���X�𑗂��Ă���A�v���P�[�V�������������Ȃ��̂�
            //_terminal = new XTerm(this, new JapaneseCharDecoder(_connection));

            if(c.Param.TerminalType==TerminalType.XTerm || c.Param.TerminalType==TerminalType.KTerm)
                _terminal = new XTerm(this, new JapaneseCharDecoder(_connection));
            else
                _terminal = new VT100Terminal(this, new JapaneseCharDecoder(_connection));

            GEnv.Connections.KeepAlive.SetTimerToConnectionTag(this);
        }
Esempio n. 22
0
        public void ImportProperties(ConnectionTag src)
        {
            _renderProfile = src.RenderProfile;
            _positionIndex = src.PositionIndex;
            _preservedPositionIndex = src.PreservedPositionIndex;

            if(src.Button!=null)
                src.Button.Tag = this;
            _tabButton = src.Button;
        }
Esempio n. 23
0
 public CommandResultSession(CommandResultDocument doc, RenderProfile prof)
 {
     _document      = doc;
     _renderProfile = prof;
 }
Esempio n. 24
0
        public static void UpdateOptions(ContainerOptions opt)
        {
            GEnv.Options = opt;
            _frame.ApplyOptions(_options, opt);
            _history.LimitCount(opt.MRUSize);
            _frame.AdjustMRUMenu();

            if(_options.Language!=opt.Language) { //����̃����[�h���K�v�ȂƂ�
                System.Threading.Thread.CurrentThread.CurrentUICulture = opt.Language==Language.Japanese? new CultureInfo("ja") : CultureInfo.InvariantCulture;
                GApp.ReloadStringResource();
                Granados.SSHC.Strings.Reload();
                GApp.MacroManager.ReloadLanguage();
                _frame.ReloadLanguage(opt.Language);
            }

            //�f�t�H���g�̂܂܂ł������ꍇ�ɂ͍X�V�������
            RenderProfile newprof = new RenderProfile(opt);
            foreach(ConnectionTag ct in GEnv.Connections) {
                if(ct.RenderProfile==null && ct.AttachedPane!=null) ct.AttachedPane.ApplyRenderProfile(newprof);
            }
            GEnv.DefaultRenderProfile = newprof;
            _options = opt;
        }
Esempio n. 25
0
        internal void Render(IntPtr hdc, RenderParameter param, RenderProfile prof, int y)
        {
            if(_text[0]=='\0') return; //����`���Ȃ��Ă悢
            float fx = (float)param.TargetRect.Left;

            RectangleF rect = new RectangleF();
            rect.Y = param.TargetRect.Top+y;
            rect.Height = prof.Pitch.Height;

            GWord word = _firstWord;
            while(word != null) {

                rect.X = fx /*- prof.CharGap*/; //Native�ȕ`��ł͕s�v�H
                rect.Width = param.TargetRect.Right - rect.X;
                int ix = (int)rect.X;
                int iy = (int)rect.Y;

                TextDecoration dec = word.Decoration;

                //Brush brush = prof.CalcTextBrush(dec);
                uint forecolorref = DrawUtil.ToCOLORREF(prof.CalcTextColor(dec));
                Color bkcolor = prof.CalcBackColor(dec);
                uint bkcolorref   = DrawUtil.ToCOLORREF(bkcolor);
                IntPtr hfont = prof.CalcHFONT_NoUnderline(dec, word.CharGroup);
                Win32.SelectObject(hdc, hfont);
                Win32.SetTextColor(hdc, forecolorref);
                Win32.SetBkColor(hdc, bkcolorref);
                Win32.SetBkMode(hdc, bkcolor==prof.BackColor? 1 : 2); //��{�w�i�F�ƈꏏ�Ȃ�TRANSPARENT, �قȂ��OPAQUE
                IntPtr bkbrush = bkcolor==prof.BackColor? IntPtr.Zero : Win32.CreateSolidBrush(bkcolorref);

                int display_length = WordDisplayLength(word);
                if(word.Decoration==null) { //�����Ȃ�
                    //g.DrawString(WordText(word), font, brush, rect);
                    DrawWord(hdc, ix, iy, word);
                }
                else {
                    //if(dec.Bold || (!prof.UsingIdenticalFont && word.CharGroup==CharGroup.TwoBytes))
                    if(dec.Bold || word.CharGroup==CharGroup.TwoBytes) //�����t�H���g�w��ł���{�ꂪ���p�̂Q�{�łȂ��ꍇ����B�p�t�H�[�}���X���̓N���A����‚‚���̂Ŋm���ɂP�������•`��
                        DrawStringByOneChar2(hdc, word, display_length, bkbrush, rect.X, iy, prof);
                    else
                        DrawWord(hdc, ix, iy, word); //���܂�A�z�ȕ`��G���W���̖�肩��͉�����ꂽ�I
                }
                //Debug.WriteLine("PW="+p.Pitch.Width+",TL="+(pb.Text.Length*p.Pitch.Width)+", real="+g.MeasureString(pb.Text, p.Font).Width);
                if(dec.Underline)
                    DrawUnderline(hdc, forecolorref, ix, iy+(int)prof.Pitch.Height-1, (int)(prof.Pitch.Width * display_length));

                fx += prof.Pitch.Width * display_length;
                word = word.Next;
                if(bkbrush!=IntPtr.Zero) Win32.DeleteObject(bkbrush);
            }
        }