Example #1
0
		public Text.StringBuilder Append (Text.StringBuilder sb)
		{
			if (bound)
				return sb.Append ("[*]");
			return sb.Append ('[')
				.Append (',', dimensions - 1)
				.Append (']');
			
		}
Example #2
0
 private void HistoryDown()
 {
     if (_historyIndex >= 0 && _historyIndex < History.Count - 1)
     {
         // Select next newer entry.
         _historyIndex++;
         Text.Clear();
         Text.Append(History[_historyIndex]);
         CaretIndex = Text.Length;
         InvalidateArrange();
     }
     else if (_historyIndex == History.Count - 1)
     {
         // No newer entry exists. Set current text to empty string for new input.
         _historyIndex = -1;
         Text.Clear();
         CaretIndex = Text.Length;
         InvalidateArrange();
     }
 }
Example #3
0
        private Token Step(int character, NameState newState, NameTokenType newNameTokenType, bool create = false)
        {
            Token res = null;

            if (create)
            {
                res = new Token((int)_nameTokenType, Text.ToString());
                Text.Clear();
            }

            if (character != IgnoreChar)
            {
                Text.Append((char)character);
            }

            CurrentState   = newState;
            _nameTokenType = newNameTokenType;

            return(res);
        }
 public new bool WriteText(System.Text.StringBuilder value, bool append = false)
 {
     try {
         if (append)
         {
             Text.Append(value);
         }
         else
         {
             Text = value;
         }
     } catch (Exception) {
         return(false);
     }
     if (AutoSyncText)
     {
         SyncText();
     }
     return(true);
 }
        public override TokenState Accept(char input, int position)
        {
            if (input == '=')
            {
                Context.Token.AddAttribute(new TokenAttribute(Text.ToString()));
                return(Move <TokenAttributeValueState>());
            }

            if (input == ' ' && Text.Length == 0)
            {
                return(this);
            }

            if (input == '{' || input == '}' || input == ',' || input == ' ')
            {
                return(Move <TokenErrorState>());
            }

            Text.Append(input);
            return(this);
        }
Example #6
0
        private void FixTabs()
        {
            StringBuilder ignored = new StringBuilder();

            if (Lines[0].Tokens[0].TokenType == TokenType.Text)
            {
                bool foundChar = false;
                foreach (char ch in ((Text)Lines[0].Tokens[0]).Content)
                {
                    if (!foundChar && char.IsWhiteSpace(ch))
                    {
                        ignored.Append(ch);
                    }
                    else
                    {
                        foundChar = true;
                    }
                }
                if (ignored.Length > 0)
                {
                    foreach (Line line in Lines)
                    {
                        if (line.Tokens.Count > 0 && line.Tokens[0].TokenType == TokenType.Text && ((Text)line.Tokens[0]).Content.StartsWith(ignored.ToString()))
                        {
                            string content = ((Text)line.Tokens[0]).Content.Replace(ignored.ToString(), string.Empty);
                            Text   text    = new Text();
                            foreach (char ch in content)
                            {
                                text.Append(ch);
                            }
                            line.Tokens[0] = text;
                        }
                    }
                }
            }
        }
Example #7
0
 public void ComposeText(string line)
 {
     Text.Append(line);
     Text.Append(System.Environment.NewLine);
     AmountLines++;
 }
 public override TokenState Accept(char input, int position)
 {
     Text.Append(input);
     return(this);
 }
Example #9
0
		public Text.StringBuilder Append (Text.StringBuilder sb)
		{
			return sb.Append ('*', pointer_level);
		}
Example #10
0
        /// <summary>Read a line terminated by a custom delimiter.</summary>
        /// <exception cref="System.IO.IOException"/>
        private int ReadCustomLine(Text str, int maxLineLength, int maxBytesToConsume)
        {
            /* We're reading data from inputStream, but the head of the stream may be
             *  already captured in the previous buffer, so we have several cases:
             *
             * 1. The buffer tail does not contain any character sequence which
             *    matches with the head of delimiter. We count it as a
             *    ambiguous byte count = 0
             *
             * 2. The buffer tail contains a X number of characters,
             *    that forms a sequence, which matches with the
             *    head of delimiter. We count ambiguous byte count = X
             *
             *    // ***  eg: A segment of input file is as follows
             *
             *    " record 1792: I found this bug very interesting and
             *     I have completely read about it. record 1793: This bug
             *     can be solved easily record 1794: This ."
             *
             *    delimiter = "record";
             *
             *    supposing:- String at the end of buffer =
             *    "I found this bug very interesting and I have completely re"
             *    There for next buffer = "ad about it. record 179       ...."
             *
             *     The matching characters in the input
             *     buffer tail and delimiter head = "re"
             *     Therefore, ambiguous byte count = 2 ****   //
             *
             *     2.1 If the following bytes are the remaining characters of
             *         the delimiter, then we have to capture only up to the starting
             *         position of delimiter. That means, we need not include the
             *         ambiguous characters in str.
             *
             *     2.2 If the following bytes are not the remaining characters of
             *         the delimiter ( as mentioned in the example ),
             *         then we have to include the ambiguous characters in str.
             */
            str.Clear();
            int txtLength = 0;
            // tracks str.getLength(), as an optimization
            long bytesConsumed      = 0;
            int  delPosn            = 0;
            int  ambiguousByteCount = 0;

            do
            {
                // To capture the ambiguous characters count
                int startPosn = bufferPosn;
                // Start from previous end position
                if (bufferPosn >= bufferLength)
                {
                    startPosn    = bufferPosn = 0;
                    bufferLength = FillBuffer(@in, buffer, ambiguousByteCount > 0);
                    if (bufferLength <= 0)
                    {
                        if (ambiguousByteCount > 0)
                        {
                            str.Append(recordDelimiterBytes, 0, ambiguousByteCount);
                            bytesConsumed += ambiguousByteCount;
                        }
                        break;
                    }
                }
                // EOF
                for (; bufferPosn < bufferLength; ++bufferPosn)
                {
                    if (buffer[bufferPosn] == recordDelimiterBytes[delPosn])
                    {
                        delPosn++;
                        if (delPosn >= recordDelimiterBytes.Length)
                        {
                            bufferPosn++;
                            break;
                        }
                    }
                    else
                    {
                        if (delPosn != 0)
                        {
                            bufferPosn--;
                            delPosn = 0;
                        }
                    }
                }
                int readLength = bufferPosn - startPosn;
                bytesConsumed += readLength;
                int appendLength = readLength - delPosn;
                if (appendLength > maxLineLength - txtLength)
                {
                    appendLength = maxLineLength - txtLength;
                }
                bytesConsumed += ambiguousByteCount;
                if (appendLength >= 0 && ambiguousByteCount > 0)
                {
                    //appending the ambiguous characters (refer case 2.2)
                    str.Append(recordDelimiterBytes, 0, ambiguousByteCount);
                    ambiguousByteCount = 0;
                    // since it is now certain that the split did not split a delimiter we
                    // should not read the next record: clear the flag otherwise duplicate
                    // records could be generated
                    UnsetNeedAdditionalRecordAfterSplit();
                }
                if (appendLength > 0)
                {
                    str.Append(buffer, startPosn, appendLength);
                    txtLength += appendLength;
                }
                if (bufferPosn >= bufferLength)
                {
                    if (delPosn > 0 && delPosn < recordDelimiterBytes.Length)
                    {
                        ambiguousByteCount = delPosn;
                        bytesConsumed     -= ambiguousByteCount;
                    }
                }
            }while (delPosn < recordDelimiterBytes.Length && bytesConsumed < maxBytesToConsume);
            //to be consumed in next
            if (bytesConsumed > int.MaxValue)
            {
                throw new IOException("Too many bytes before delimiter: " + bytesConsumed);
            }
            return((int)bytesConsumed);
        }
Example #11
0
        private static void AppendFormatCommandParameterInfo(CommandParameterInfo parameter, ref Text.StringBuilder result)
        {
            if (result.Length > 0)
            {
                // Add a space between parameters
                result.Append(" ");
            }

            if (parameter.ParameterType == typeof(SwitchParameter))
            {
                result.AppendFormat(CultureInfo.InvariantCulture, parameter.IsMandatory ? "-{0}" : "[-{0}]", parameter.Name);
            }
            else
            {
                string parameterTypeString = GetParameterTypeString(parameter.ParameterType, parameter.Attributes);

                if (parameter.IsMandatory)
                {
                    result.AppendFormat(CultureInfo.InvariantCulture,
                                        parameter.Position != int.MinValue ? "[-{0}] <{1}>" : "-{0} <{1}>",
                                        parameter.Name, parameterTypeString);
                }
                else
                {
                    result.AppendFormat(CultureInfo.InvariantCulture,
                                        parameter.Position != int.MinValue ? "[[-{0}] <{1}>]" : "[-{0} <{1}>]",
                                        parameter.Name, parameterTypeString);
                }
            }
        }
            public static bool Prefix(HumanDescriptionDef __instance, ref Text __result)
            {
                var instance = __instance;

                if (instance.Details == null)
                {
                    __result = new Text();
                    return(false);
                }
                if (instance.GetLocalizedDetails() != null && (bool)AccessTools.Field(typeof(BaseDescriptionDef), "detailsParsed").GetValue(instance))
                {
                    __result = instance.GetLocalizedDetails();
                    return(false);
                }
                Text text = new Text();

                if (instance.isGenerated)
                {
                    string[] strArray = instance.Details.Split(new string[4]
                    {
                        Environment.NewLine,
                        "<b>",
                        ":</b>",
                        "\n\n"
                    }, StringSplitOptions.RemoveEmptyEntries);
                    // pad the array length to make it even
                    if (strArray.Length % 2 != 0)
                    {
                        Array.Resize(ref strArray, strArray.Length + 1);
                    }
                    int index = 0;
                    while (index < strArray.Length)
                    {
                        text.Append("<b>{0}:</b> {1}\n\n", (object[])new string[2]
                        {
                            strArray[index],
                            strArray[index + 1]
                        });
                        index += 2;
                    }
                }
                else if (instance.isCommander)
                {
                    string   details   = instance.Details;
                    string[] separator = new string[1]
                    {
                        Environment.NewLine
                    };
                    int num = 1;
                    foreach (object obj in details.Split(separator, (StringSplitOptions)num))
                    {
                        text.Append("{0} \n\n", obj);
                    }
                }
                else
                {
                    text.Append(instance.Details, new object[0]);
                }
                AccessTools.Field(typeof(BaseDescriptionDef), "detailsParsed").SetValue(instance, true);
                AccessTools.Field(typeof(BaseDescriptionDef), "detailsParsed").SetValue(instance, text);
                __result = text;
                return(false);
            }
Example #13
0
 public void Append(string text)
 {
     Text.Append(text);
 }
Example #14
0
 /// <summary>
 /// Создаёт InputField с уже написнным текстом.
 /// </summary>
 public InputField(string initialText)
 {
     Text.Append(initialText);
 }
Example #15
0
 /// <summary>
 /// 添加SQL内容
 /// </summary>
 /// <param name="text">SQL内容</param>
 /// <returns>Command</returns>
 public Command AddSqlText(string text)
 {
     Text.Append(text);
     return(this);
 }
Example #16
0
		private Text.StringBuilder GetModifierString (Text.StringBuilder sb)
		{
			if (modifier_spec != null) {
				foreach (var md in modifier_spec)
					md.Append (sb);
			}

			if (is_byref)
				sb.Append ('&');

			return sb;
		}
Example #17
0
 /// <summary>
 /// 构建命令对象,并指定相应的SQL
 /// </summary>
 /// <param name="text">SQL语句</param>
 public Command(string text)
 {
     Text.Append(text);
 }
Example #18
0
        /// <summary>Read a line terminated by one of CR, LF, or CRLF.</summary>
        /// <exception cref="System.IO.IOException"/>
        private int ReadDefaultLine(Text str, int maxLineLength, int maxBytesToConsume)
        {
            /* We're reading data from in, but the head of the stream may be
             * already buffered in buffer, so we have several cases:
             * 1. No newline characters are in the buffer, so we need to copy
             *    everything and read another buffer from the stream.
             * 2. An unambiguously terminated line is in buffer, so we just
             *    copy to str.
             * 3. Ambiguously terminated line is in buffer, i.e. buffer ends
             *    in CR.  In this case we copy everything up to CR to str, but
             *    we also need to see what follows CR: if it's LF, then we
             *    need consume LF as well, so next call to readLine will read
             *    from after that.
             * We use a flag prevCharCR to signal if previous character was CR
             * and, if it happens to be at the end of the buffer, delay
             * consuming it until we have a chance to look at the char that
             * follows.
             */
            str.Clear();
            int txtLength = 0;
            //tracks str.getLength(), as an optimization
            int newlineLength = 0;
            //length of terminating newline
            bool prevCharCR = false;
            //true of prev char was CR
            long bytesConsumed = 0;

            do
            {
                int startPosn = bufferPosn;
                //starting from where we left off the last time
                if (bufferPosn >= bufferLength)
                {
                    startPosn = bufferPosn = 0;
                    if (prevCharCR)
                    {
                        ++bytesConsumed;
                    }
                    //account for CR from previous read
                    bufferLength = FillBuffer(@in, buffer, prevCharCR);
                    if (bufferLength <= 0)
                    {
                        break;
                    }
                }
                // EOF
                for (; bufferPosn < bufferLength; ++bufferPosn)
                {
                    //search for newline
                    if (buffer[bufferPosn] == Lf)
                    {
                        newlineLength = (prevCharCR) ? 2 : 1;
                        ++bufferPosn;
                        // at next invocation proceed from following byte
                        break;
                    }
                    if (prevCharCR)
                    {
                        //CR + notLF, we are at notLF
                        newlineLength = 1;
                        break;
                    }
                    prevCharCR = (buffer[bufferPosn] == Cr);
                }
                int readLength = bufferPosn - startPosn;
                if (prevCharCR && newlineLength == 0)
                {
                    --readLength;
                }
                //CR at the end of the buffer
                bytesConsumed += readLength;
                int appendLength = readLength - newlineLength;
                if (appendLength > maxLineLength - txtLength)
                {
                    appendLength = maxLineLength - txtLength;
                }
                if (appendLength > 0)
                {
                    str.Append(buffer, startPosn, appendLength);
                    txtLength += appendLength;
                }
            }while (newlineLength == 0 && bytesConsumed < maxBytesToConsume);
            if (bytesConsumed > int.MaxValue)
            {
                throw new IOException("Too many bytes before newline: " + bytesConsumed);
            }
            return((int)bytesConsumed);
        }