Beispiel #1
0
        public ConsoleDisplayLine[] GetDisplayLines(Int64 lineNo)
        {
            if (lineNo < 0 || lineNo > displayLineList.Count)
            {
                return(null);
            }
            int count = 0;
            List <ConsoleDisplayLine> list = new List <ConsoleDisplayLine>();

            for (int i = displayLineList.Count - 1; i >= 0; i--)
            {
                if (count == lineNo)
                {
                    list.Insert(0, displayLineList[i]);
                }
                if (displayLineList[i].IsLogicalLine)
                {
                    count++;
                }
                if (count > lineNo)
                {
                    break;
                }
            }
            if (list.Count == 0)
            {
                return(null);
            }
            ConsoleDisplayLine[] ret = new ConsoleDisplayLine[list.Count];
            list.CopyTo(ret);
            return(ret);
        }
Beispiel #2
0
        public void deleteLine(int argNum)
        {
            int delNum = 0;
            int num    = argNum;

            while (delNum < num)
            {
                if (displayLineList.Count == 0)
                {
                    break;
                }
                ConsoleDisplayLine line = displayLineList[displayLineList.Count - 1];
                displayLineList.RemoveAt(displayLineList.Count - 1);
                lineNo--;
                if (line.IsLogicalLine)
                {
                    delNum++;
                    logicalLineCount--;
                }
            }
            if (lineNo < 0)
            {
                lineNo += int.MaxValue;
            }
            lastDrawnLineNo = -1;
            //RefreshStrings(true);
        }
Beispiel #3
0
        private void addDisplayLine(ConsoleDisplayLine line, bool force_LEFT)
        {
            if (LastLineIsTemporary)
            {
                deleteLine(1);
            }
            //不適正なFontのチェック
            AConsoleDisplayPart errorStr = null;

            foreach (ConsoleButtonString button in line.Buttons)
            {
                foreach (AConsoleDisplayPart css in button.StrArray)
                {
                    if (css.Error)
                    {
                        errorStr = css;
                        break;
                    }
                }
            }
            if (errorStr != null)
            {
                MessageBox.Show("Emueraの表示処理中に不適正なフォントを検出しました\n描画処理を続行できないため強制終了します", "フォント不適正");
                this.Quit();
                return;
            }
            if (force_LEFT)
            {
                line.SetAlignment(DisplayLineAlignment.LEFT);
            }
            else
            {
                line.SetAlignment(alignment);
            }
            line.LineNo = lineNo;
            displayLineList.Add(line);
            lineNo++;
            if (line.IsLogicalLine)
            {
                logicalLineCount++;
            }
            if (lineNo == int.MaxValue)
            {
                lastDrawnLineNo = -1;
                lineNo          = 0;
            }
            if (logicalLineCount == long.MaxValue)
            {
                logicalLineCount = 0;
            }
            if (displayLineList.Count > Config.MaxLog)
            {
                displayLineList.RemoveAt(0);
            }
        }
Beispiel #4
0
        public ConsoleDisplayLine FlushSingleLine(StringMeasure stringMeasure, bool temporary)
        {
            fromCssToButton();
            setWidthToButtonList(m_buttonList, stringMeasure, true);
            ConsoleButtonString[] dispLineButtonArray = new ConsoleButtonString[m_buttonList.Count];
            m_buttonList.CopyTo(dispLineButtonArray);
            ConsoleDisplayLine line = new ConsoleDisplayLine(dispLineButtonArray, true, temporary);

            this.clearBuffer();
            return(line);
        }
Beispiel #5
0
        internal ConsoleDisplayLine PrintPlainwithSingleLine(string str)
        {
            if (!this.Enabled)
            {
                return(null);
            }
            if (string.IsNullOrEmpty(str))
            {
                return(null);
            }
            printBuffer.AppendPlainText(str, Style);
            ConsoleDisplayLine dispLine = printBuffer.FlushSingleLine(stringMeasure, false);

            return(dispLine);
        }
Beispiel #6
0
        public void PrintSingleLine(string str, bool temporary)
        {
            if (string.IsNullOrEmpty(str))
            {
                return;
            }
            PrintFlush(false);
            printBuffer.Append(str, Style);
            ConsoleDisplayLine dispLine = BufferToSingleLine(true, temporary);

            if (dispLine == null)
            {
                return;
            }
            addDisplayLine(dispLine, false);
            RefreshStrings(false);
        }
Beispiel #7
0
        public ConsoleDisplayLine BufferToSingleLine(bool force, bool temporary)
        {
            if (!this.Enabled)
            {
                return(null);
            }
            if (!force && printBuffer.IsEmpty)
            {
                return(null);
            }
            if (force && printBuffer.IsEmpty)
            {
                printBuffer.Append(" ", Style);
            }
            ConsoleDisplayLine dispLine = printBuffer.FlushSingleLine(stringMeasure, temporary | force_temporary);

            return(dispLine);
        }
Beispiel #8
0
        internal void PrintErrorButton(string str, ScriptPosition pos)
        {
            if (string.IsNullOrEmpty(str))
            {
                return;
            }
            if (Program.DebugMode)
            {
                this.DebugPrint(str);
                this.DebugNewLine();
            }
            UseUserStyle = false;
            ConsoleDisplayLine dispLine = printBuffer.AppendAndFlushErrButton(str, Style, ErrorButtonsText, pos, stringMeasure);

            if (dispLine == null)
            {
                return;
            }
            addDisplayLine(dispLine, true);
            RefreshStrings(false);
        }
Beispiel #9
0
        public void PrintError(string str)
        {
            if (string.IsNullOrEmpty(str))
            {
                return;
            }
            if (Program.DebugMode)
            {
                this.DebugPrint(str);
                this.DebugNewLine();
            }
            PrintFlush(false);
            UseUserStyle = false;
            ConsoleDisplayLine dispLine = PrintPlainwithSingleLine(str);

            if (dispLine == null)
            {
                return;
            }
            addDisplayLine(dispLine, true);
            RefreshStrings(false);
        }
Beispiel #10
0
        public static ConsoleDisplayLine[] ButtonsToDisplayLines(List <ConsoleButtonString> buttonList, StringMeasure stringMeasure, bool nobr, bool temporary)
        {
            if (buttonList.Count == 0)
            {
                return(new ConsoleDisplayLine[0]);
            }
            setWidthToButtonList(buttonList, stringMeasure, nobr);
            List <ConsoleDisplayLine>  lineList       = new List <ConsoleDisplayLine>();
            List <ConsoleButtonString> lineButtonList = new List <ConsoleButtonString>();
            int  windowWidth = Config.DrawableWidth;
            bool firstLine   = true;

            for (int i = 0; i < buttonList.Count; i++)
            {
                if (buttonList[i] == null)
                {                //強制改行フラグ
                    lineList.Add(m_buttonsToDisplayLine(lineButtonList, firstLine, temporary));
                    firstLine = false;
                    buttonList.RemoveAt(i);
                    i--;
                    continue;
                }
                if (nobr || ((buttonList[i].PointX + buttonList[i].Width <= windowWidth)))
                {                //改行不要モードであるか表示可能領域に収まるならそのままでよい
                    lineButtonList.Add(buttonList[i]);
                    continue;
                }
                //新しい表示行を作る

                //ボタンを分割するか?
                //「ボタンの途中で行を折りかえさない」がfalseなら分割する
                //このボタンが単体で表示可能領域を上回るなら分割必須
                //クリック可能なボタンでないなら分割する。ただし「ver1739以前の非ボタン折り返しを再現する」ならクリックの可否を区別しない
                if ((!Config.ButtonWrap) || (lineButtonList.Count == 0) || (!buttonList[i].IsButton && !Config.CompatiLinefeedAs1739))
                {                //ボタン分割する
                    int divIndex = getDivideIndex(buttonList[i], stringMeasure);
                    if (divIndex > 0)
                    {
                        ConsoleButtonString newButton = buttonList[i].DivideAt(divIndex, stringMeasure);
                        //newButton.CalcPointX(buttonList[i].PointX + buttonList[i].Width);
                        buttonList.Insert(i + 1, newButton);
                        lineButtonList.Add(buttonList[i]);
                        i++;
                    }
                    else if (divIndex == 0 && (lineButtonList.Count > 0))
                    {                    //まるごと次の行に送る
                    }
                    else                 //分割できない要素のみで構成されたボタンは分割できない
                    {
                        lineButtonList.Add(buttonList[i]);
                        continue;
                    }
                }
                lineList.Add(m_buttonsToDisplayLine(lineButtonList, firstLine, temporary));
                firstLine = false;
                //位置調整
//				shiftX = buttonList[i].PointX;
                int pointX = 0;
                for (int j = i; j < buttonList.Count; j++)
                {
                    if (buttonList[j] == null)                    //強制改行を挟んだ後は調整無用
                    {
                        break;
                    }
                    buttonList[j].CalcPointX(pointX);
                    pointX += buttonList[j].Width;
                }
                i--;                //buttonList[i]は新しい行に含めないので次の行のために再検討する必要がある(直後のi++と相殺)
            }
            if (lineButtonList.Count > 0)
            {
                lineList.Add(m_buttonsToDisplayLine(lineButtonList, firstLine, temporary));
            }
            ConsoleDisplayLine[] ret = new ConsoleDisplayLine[lineList.Count];
            lineList.CopyTo(ret);
            return(ret);
        }
Beispiel #11
0
 void drawDisplayLine(ConsoleDisplayLine line, Graphics g, int pointY, bool isBackLog, bool clear)
 {
     if (Config.TextDrawingMode == TextDrawingMode.WINAPI)
     {
         //line.GDIClear(pointY);
         line.GDIDrawTo(pointY, isBackLog);
     }
     else
     {
         if (clear)
             line.Clear(new SolidBrush(this.bgColor), g, pointY);
         line.DrawTo(g, pointY, isBackLog, true, Config.TextDrawingMode);
     }
 }
Beispiel #12
0
 private void addRangeDisplayLine(ConsoleDisplayLine[] lineList)
 {
     for (int i = 0; i < lineList.Length; i++)
         addDisplayLine(lineList[i]);
 }
Beispiel #13
0
 private void addDisplayLine(ConsoleDisplayLine line)
 {
     if (LastLineIsTemporary)
         deleteLine(1);
     line.SetAlignment(alignment);
     line.LineNo = lineNo;
     displayLineList.Add(line);
     lineNo++;
     if (line.IsLogicalLine)
         logicalLineCount++;
     if (lineNo == int.MaxValue)
     {
         lastDrawnLineNo = -1;
         lineNo = 0;
     }
     if (logicalLineCount == long.MaxValue)
     {
         logicalLineCount = 0;
     }
     if (displayLineList.Count > Config.MaxLog)
         displayLineList.RemoveAt(0);
 }
 public ConsoleDisplayLine FlushSingleLine(StringMeasure stringMeasure, bool temporary)
 {
     fromCssToButton();
     setLengthToButtonList(stringMeasure);
     ConsoleButtonString[] dispLineButtonArray = new ConsoleButtonString[buttonList.Count];
     buttonList.CopyTo(dispLineButtonArray);
     ConsoleDisplayLine line = new ConsoleDisplayLine(parent, dispLineButtonArray, true, temporary);
     this.Clear();
     return line;
 }
        public ConsoleDisplayLine[] Flush(StringMeasure stringMeasure, bool temporary)
        {
            fromCssToButton();
            setLengthToButtonList(stringMeasure);
            if (buttonList.Count == 0)
                return new ConsoleDisplayLine[0];
            List<ConsoleDisplayLine> lineList = new List<ConsoleDisplayLine>();
            List<ConsoleButtonString> lineButtonList = new List<ConsoleButtonString>();
            ConsoleButtonString[] dispLineButtonArray = null;
            int shiftX = 0;
            int windowWidth = Config.WindowX;
            bool firstLine = true;
            bool newLine = false;
            for (int i = 0; i < buttonList.Count; i++)
            {
                if (newLine)
                {
                    shiftX = buttonList[i].PointX;
                    for (int j = i; j < buttonList.Count; j++)
                        buttonList[j].ShiftPositionX(-shiftX);
                    newLine = false;
                }
                if (buttonList[i].PointX + buttonList[i].Width > windowWidth)
                {//ここから新しい表示行
                    if ((!makeButtonWrap) || (lineButtonList.Count == 0) || (!buttonList[i].IsButton && !Config.CompatiLinefeedAs1739))
                    {//ボタン分割
                        int divIndex =getDivideIndex(buttonList[i], stringMeasure);
                        if (divIndex > 0)
                        {
                            ConsoleButtonString newButton = buttonList[i].DivideAt(divIndex, stringMeasure);
                            newButton.SetPointX(buttonList[i].PointX + buttonList[i].Width);
                            buttonList.Insert(i + 1, newButton);
                            lineButtonList.Add(buttonList[i]);
                            i++;
                        }
                    }
                    dispLineButtonArray = new ConsoleButtonString[lineButtonList.Count];
                    lineButtonList.CopyTo(dispLineButtonArray);
                    lineList.Add(new ConsoleDisplayLine(parent, dispLineButtonArray, firstLine, temporary));
                    firstLine = false;
                    lineButtonList.Clear();
                    newLine = true;
                    i--;
                    continue;
                }
                lineButtonList.Add(buttonList[i]);
                continue;
            }
            if (lineButtonList.Count > 0)
            {
                dispLineButtonArray = new ConsoleButtonString[lineButtonList.Count];
                lineButtonList.CopyTo(dispLineButtonArray);
                lineList.Add(new ConsoleDisplayLine(parent, dispLineButtonArray, firstLine, temporary));
            }

            //if (StaticConfig.ButtonWrap)
            //{//ボタン処理優先
            //    setLengthToButtonList(stringMeasure, false);
            //    ConsoleButtonString[] buttons = createButtons(stringMeasure, stringList);
            //    List<ConsoleButtonString> buttonList = new List<ConsoleButtonString>();
            //    int shiftX = 0;
            //    int windowWidth = StaticConfig.WindowX;
            //    bool firstLine = true;
            //    bool newLine = false;
            //    for (int i = 0; i < buttons.Length; i++)
            //    {
            //        if (newLine)
            //        {
            //            shiftX = buttons[i].PointX;
            //            for (int j = i; j < buttons.Length; j++)
            //                buttons[j].ShiftPositionX(-shiftX);
            //            newLine = false;
            //        }
            //        if ((buttons[i].PointX + buttons[i].Width > windowWidth) && (buttonList.Count > 0))
            //        {//ここから新しい表示行
            //            dispLineButtonArray = new ConsoleButtonString[buttonList.Count];
            //            buttonList.CopyTo(dispLineButtonArray);
            //            lineList.Add(new ConsoleDisplayLine(parent, dispLineButtonArray, firstLine, temporary));
            //            firstLine = false;
            //            buttonList.Clear();
            //            newLine = true;
            //            i--;
            //            continue;
            //            //buttonList.Add(buttons[i]);
            //            //continue;
            //        }
            //        buttonList.Add(buttons[i]);
            //        continue;
            //    }
            //    if (buttonList.Count > 0)
            //    {
            //        dispLineButtonArray = new ConsoleButtonString[buttonList.Count];
            //        buttonList.CopyTo(dispLineButtonArray);
            //        lineList.Add(new ConsoleDisplayLine(parent, dispLineButtonArray, firstLine, temporary));
            //    }
            //}
            //else
            //{//折り返し処理優先
            //    setLengthToButtonList(stringMeasure, true);
            //    List<ConsoleStyledString> buttonCssList = new List<ConsoleStyledString>();
            //    int pointX = -1;
            //    bool firstLine = true;
            //    for (int i = 0; i < stringList.Count; i++)
            //    {
            //        if ((buttonCssList.Count > 0) && (stringList[i].PointX == 0))
            //        {//ここから新しい表示行
            //            dispLineButtonArray = createButtons(stringMeasure, buttonCssList);
            //            lineList.Add(new ConsoleDisplayLine(parent, dispLineButtonArray, firstLine, temporary));
            //            firstLine = false;
            //            buttonCssList.Clear();
            //            buttonCssList.Add(stringList[i]);
            //            pointX = stringList[i].PointX;
            //            continue;
            //        }
            //        buttonCssList.Add(stringList[i]);
            //        pointX = stringList[i].PointX;
            //        continue;
            //    }
            //    if (buttonCssList.Count > 0)
            //    {
            //        dispLineButtonArray = createButtons(stringMeasure, buttonCssList);
            //        lineList.Add(new ConsoleDisplayLine(parent, dispLineButtonArray, firstLine, temporary));
            //        firstLine = false;
            //    }
            //}
            ConsoleDisplayLine[] ret = new ConsoleDisplayLine[lineList.Count];
            lineList.CopyTo(ret);
            this.Clear();
            return ret;
        }
 public ConsoleDisplayLine AppendErrButton(string str, StringStyle style, string input, ScriptPosition pos, StringMeasure sm)
 {
     fromCssToButton();
     stringList.Add(new ConsoleStyledString(str, style));
     if (stringList.Count == 0)
         return null;
     buttonList.Add(createButton(stringList, input, pos));
     stringList.Clear();
     setLengthToButtonList(sm);
     ConsoleButtonString[] dispLineButtonArray = new ConsoleButtonString[buttonList.Count];
     buttonList.CopyTo(dispLineButtonArray);
     ConsoleDisplayLine line = new ConsoleDisplayLine(parent, dispLineButtonArray, true, false);
     this.Clear();
     return line;
 }