Example #1
0
 public static void GetHelp(CommandExecutionContext *context)
 {
     TextMode.WriteLine("Syntax: ");
     TextMode.WriteLine("     halt");
     TextMode.WriteLine("");
     TextMode.WriteLine("Halts the system.");
 }
Example #2
0
        public static void Execute(CommandExecutionContext *context)
        {
            CommandExecutionAttemptResult result = Prompter.CommandTable->HandleLine(context->parameters, false, true);

            if (result == CommandExecutionAttemptResult.NotFound)
            {
                int       indexOfSpace = context->parameters->IndexOf(" ");
                CString8 *tempStr;
                if (indexOfSpace >= 0)
                {
                    tempStr = context->parameters->Substring(0, indexOfSpace);
                }
                else
                {
                    tempStr = CString8.Copy(context->parameters);
                }

                TextMode.Write("No command '");
                TextMode.Write(tempStr);
                TextMode.WriteLine("' is available to retrieve help for.");
                TextMode.WriteLine(CommandTableHeader.inform_USE_HELP_COMMANDS);

                CString8.DISPOSE(tempStr);
                return;
            }
            if (result == CommandExecutionAttemptResult.BlankEntry)
            {
                ADC.MemoryUtil.Call((void *)Stubs.GetFunctionPointer(lblGetHelp), (void *)context);
            }
        }
Example #3
0
 public static void Error(string msg)
 {
     TextMode.SaveAttributes();
     SetErrorTextAttributes();
     TextMode.WriteLine(msg);
     TextMode.RestoreAttributes();
 }
Example #4
0
 public static void GetHelp(CommandExecutionContext *context)
 {
     TextMode.WriteLine("Syntax: ");
     TextMode.WriteLine("     egg");
     TextMode.WriteLine("");
     TextMode.WriteLine("And we a proud of it!");
 }
Example #5
0
		public void PerformBackspace ()
		{
			if (HasSelection ()) {
				DeleteSelection ();
				return;
			}

			// We're at the beginning of a line and there's
			// a line above us, go to the end of the prior line
			if (currentPos.Offset == 0 && currentPos.Line > 0) {
				int ntp = lines[currentPos.Line - 1].Length;

				lines[currentPos.Line - 1] = lines[currentPos.Line - 1] + lines[currentPos.Line];
				lines.RemoveAt (currentPos.Line);
				currentPos.Line--;
				currentPos.Offset = ntp;
			} else if (currentPos.Offset > 0) {
				// We're in the middle of a line, delete the previous character
				string ln = lines[currentPos.Line];

				// If we are at the end of a line, we don't need to place a compound string
				if (currentPos.Offset == ln.Length)
					lines[currentPos.Line] = ln.Substring (0, ln.Length - 1);
				else
					lines[currentPos.Line] = ln.Substring (0, currentPos.Offset - 1) + ln.Substring (currentPos.Offset);

				currentPos.Offset--;
			}

            selectionStart = currentPos;
			State = TextMode.Uncommitted;
            OnModified ();
		}
Example #6
0
        public static void Assert(bool cond, string msg)
        {
            if (!cond)
            {
                Barrier.Enter();

                TextMode.Write("Assertion Failed: ");
                TextMode.Write(msg);

                //if (Serial.Initialized)
                //{
                Debug.COM1.WriteLine("");
                Debug.COM1.WriteLine("----------------- ");
                Debug.COM1.WriteLine("Assertion Failed: ");
                Debug.COM1.WriteLine(msg);

                Debug.COM1.WriteLine("=============================================================");
                Debug.COM1.WriteLine("Stack Trace:");

                ExceptionHandling.DumpCallingStack();
                //}
                Panic(msg);

                Barrier.Exit();
            }
        }
Example #7
0
 public static void GetHelp(CommandExecutionContext *context)
 {
     TextMode.WriteLine("Syntax: ");
     TextMode.WriteLine("     reboot");
     TextMode.WriteLine("");
     TextMode.WriteLine("Restarts the machine.");
 }
Example #8
0
        public static void WriteKeymaps()
        {
            byte *table = (byte *)keymapArchive + 4;
            byte *buf   = getBuiltinKeyMapBuffer;

            for (int x = 0; x < keymapEntries; ++x)
            {
                int tSize   = 0;
                int error   = 0;
                int strSize = 0;

                strSize = BinaryTool.ReadPrefixedString(table, buf,
                                                        EntryModule.MaxKeyMapNameLength, &error);

                table += strSize;

                table += 2;                 // keymask/statebit

                // default table

                tSize  = *(int *)table;
                table += 4;
                table += tSize;

                // shifted table

                tSize  = *(int *)table;
                table += 4;
                table += tSize;

                // Write it out.
                TextMode.WriteLine(buf);
            }
        }
Example #9
0
        public static int Read7BitInt(void *ptr, int *ret_len)
        {
            // Originally from Mono: mcs/class/corlib/System.IO/BinaryReader.cs
            // Copyright (C) 2004 Novell

            int   ret   = 0;
            int   shift = 0;
            byte *bp    = (byte *)ptr;
            byte  b;

            do
            {
                b = *bp;
                ++bp;

                if (ret_len != null)
                {
                    (*ret_len)++;
                }

                ret    = ret | (((int)(b & 0x7f)) << shift);
                shift += 7;
            } while ((b & 0x80) == 0x80);

#if VERBOSE_BinaryTool
            TextMode.WriteLine("read7bit: ", ret);
#endif

            return(ret);
        }
Example #10
0
        public static void Execute(CommandExecutionContext *context)
        {
            if (context->parameters->Compare("--set", 0, 5) == 0)
            {
                CString8 *substr;
                int       result;

                if (context->parameters->Length <= 6)
                {
                    GetHelp(context);
                    return;
                }

                substr = context->parameters->Substring(6);
                result = Convert.ToInt32(substr);
                MemoryManager.Free(substr);

                TextMode.WriteLine("Setting timezone to `", result, "'");
                Clock.Timezone = (System.SByte)result;

                return;
            }

            TextMode.Write("Current timezone: ");
            TextMode.Write((int)Clock.Timezone);
            TextMode.WriteLine();
        }
Example #11
0
        public void PerformDelete()
        {
            if (HasSelection())
            {
                DeleteSelection();
                return;
            }

            // Where are we?!
            if ((currentPos.Line == lines.Count - 1) && (currentPos.Offset == lines[lines.Count - 1].Length))
            {
                // The cursor is at the end of the text block
                return;
            }
            else if (currentPos.Offset == lines[currentPos.Line].Length)
            {
                // End of a line, must merge strings
                lines[currentPos.Line] = lines[currentPos.Line] + lines[currentPos.Line + 1];
                lines.RemoveAt(currentPos.Line + 1);
            }
            else
            {
                // Middle of a line somewhere
                lines[currentPos.Line] = lines[currentPos.Line].Substring(0, currentPos.Offset) + (lines[currentPos.Line]).Substring(currentPos.Offset + 1);
            }

            State = TextMode.Uncommitted;

            OnModified();
        }
Example #12
0
 public static void GetHelp(CommandExecutionContext *context)
 {
     TextMode.WriteLine("Syntax: ");
     TextMode.WriteLine("     panic");
     TextMode.WriteLine("");
     TextMode.WriteLine("Causes a RSOD (Red Screen Of Death).");
 }
Example #13
0
 public static void GetHelp(CommandExecutionContext *context)
 {
     TextMode.WriteLine("Syntax: ");
     TextMode.WriteLine("     more <filename>");
     TextMode.WriteLine();
     TextMode.WriteLine("Displays the contents of a file");
 }
Example #14
0
        public void PerformEnter()
        {
            if (HasSelection())
            {
                DeleteSelection();
            }

            string currentLine = lines[currentPos.Line];

            if (currentPos.Offset == currentLine.Length)
            {
                // If we are at the end of a line, insert an empty line at the next line
                lines.Insert(currentPos.Line + 1, string.Empty);
            }
            else
            {
                lines.Insert(currentPos.Line + 1, currentLine.Substring(currentPos.Offset, currentLine.Length - currentPos.Offset));
                lines[currentPos.Line] = lines[currentPos.Line].Substring(0, currentPos.Offset);
            }

            State = TextMode.Uncommitted;

            currentPos.Line++;
            currentPos.Offset = 0;
            selectionStart    = currentPos;
            OnModified();
        }
Example #15
0
        public static void Execute(CommandExecutionContext *context)
        {
            try {
                TextMode.WriteLine("Reading..");

                string filename = Foundation.Convert.ToString(context->parameters);

                // for testing...
                if (string.IsNullOrEmpty(filename))
                {
                    filename = "/embedded/TEST0.TXT";
                }

                TextMode.Write("File:");
                TextMode.WriteLine(filename);

                TextMode.WriteLine("More.Execute.1");
                System.IO.Stream filestream = (System.IO.Stream)Vfs.VirtualFileSystem.Open(filename, System.IO.FileAccess.Read, System.IO.FileShare.Read);
                TextMode.WriteLine("More.Execute.2");
            }
            catch (Exception e) {
                TextMode.Write("Exception: ");
                TextMode.Write(e.ToString());
                TextMode.WriteLine();
            }
        }
Example #16
0
        internal static void DisplayCommandList(CommandTableHeader *commandTable)
        {
            Diagnostics.Assert(commandTable != null, "Prompter::DisplayCommandList(CommandTableHeader*): Parameter 'commandTable' is null");

            if (commandTable->firstEntry == null)
            {
                ADC.TextMode.WriteLine("No commands to display; the commands list is empty.");
                return;
            }
            else
            {
                TextColor origForecolor = TextMode.Foreground;
                const int firstColWidth = 22;

                TextMode.SetAttributes(TextColor.White, TextMode.Background);
                string colALabel = "  NAME";
                string colBLabel = "  DESCRIPTION";

                TextMode.Write(colALabel);

                for (int spaces = firstColWidth - colALabel.Length;
                     spaces > 0;
                     spaces--)
                {
                    ADC.TextMode.Write(" ");
                }

                TextMode.WriteLine(colBLabel);

                CommandTableEntry *currentEntry;

                for (currentEntry = commandTable->firstEntry;
                     currentEntry != null;
                     currentEntry = currentEntry->nextEntry)
                {
                    ADC.TextMode.SetAttributes(TextColor.BrightWhite, TextMode.Background);
                    ADC.TextMode.Write("[");
                    ADC.TextMode.SetAttributes(TextColor.Yellow, TextMode.Background);
                    ADC.TextMode.Write(currentEntry->name);
                    ADC.TextMode.SetAttributes(TextColor.BrightWhite, TextMode.Background);
                    ADC.TextMode.Write("]");

                    int spaces = firstColWidth - (currentEntry->name->Length) - 2;

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

                    for (; spaces > 0; spaces--)
                    {
                        ADC.TextMode.Write(" ");
                    }

                    ADC.TextMode.SetAttributes(TextColor.Yellow, TextMode.Background);
                    ADC.TextMode.WriteLine(currentEntry->shortDescription);
                }
                ADC.TextMode.SetAttributes(origForecolor, TextMode.Background);
            }
        }
Example #17
0
 public static void GetHelp(CommandExecutionContext *context)
 {
     TextMode.WriteLine("Syntax: ");
     TextMode.WriteLine("     lspci");
     TextMode.WriteLine("");
     TextMode.WriteLine("Gets information about PCI.");
 }
Example #18
0
        public void PerformDelete()
        {
            if (selectionRelativeIndex != 0)
            {
                DeleteSelection();
                return;
            }

            // Where are we?!
            if ((linePos == lines.Count - 1) && (textPos == lines[lines.Count - 1].Length))
            {
                // The cursor is at the end of the text block
                return;
            }
            else if (textPos == lines[linePos].Length)
            {
                // End of a line, must merge strings
                lines[linePos] = lines[linePos] + lines[linePos + 1];
                lines.RemoveAt(linePos + 1);
            }
            else
            {
                // Middle of a line somewhere
                lines[linePos] = lines[linePos].Substring(0, textPos) + (lines[linePos]).Substring(textPos + 1);
            }

            textMode = TextMode.Uncommitted;

            Recalculate();
        }
Example #19
0
        public void PerformEnter()
        {
            if (selectionRelativeIndex != 0)
            {
                DeleteSelection();
            }

            string currentLine = lines[linePos];

            if (textPos == currentLine.Length)
            {
                // If we are at the end of a line, insert an empty line at the next line
                lines.Insert(linePos + 1, string.Empty);
            }
            else
            {
                lines.Insert(linePos + 1, currentLine.Substring(textPos, currentLine.Length - textPos));
                lines[linePos] = lines[linePos].Substring(0, textPos);
            }

            textMode = TextMode.Uncommitted;

            linePos++;
            textPos = 0;
            Recalculate();
        }
Example #20
0
 public static void GetHelp(CommandExecutionContext *context)
 {
     TextMode.WriteLine("Syntax: ");
     TextMode.WriteLine("     mount <target> <source>");
     TextMode.WriteLine();
     TextMode.WriteLine("Mounts a file system at <target> from block device at <source>.");
 }
Example #21
0
		/// <summary>
		/// Pastes text from the clipboard.
		/// </summary>
		/// <returns>
		/// <c>true</c>, if the paste was successfully performed, <c>false</c> otherwise.
		/// </returns>
		public bool PerformPaste (Gtk.Clipboard clipboard)
		{
			string txt = string.Empty;
			txt = clipboard.WaitForText ();
			if (String.IsNullOrEmpty (txt))
				return false;

            if (HasSelection ())
                DeleteSelection ();

			string[] ins_lines = txt.Split (Environment.NewLine.ToCharArray (), StringSplitOptions.RemoveEmptyEntries);
			string endline = lines [currentPos.Line].Substring (currentPos.Offset);
			lines [currentPos.Line] = lines [currentPos.Line].Substring (0, currentPos.Offset);
			bool first = true;
			foreach (string ins_txt in ins_lines) {
				if (!first) {
					currentPos.Line++;
					lines.Insert (currentPos.Line, ins_txt);
					currentPos.Offset = ins_txt.Length;
				} else {
					first = false;
					lines[currentPos.Line] += ins_txt;
					currentPos.Offset += ins_txt.Length;
				}
			}
			lines [currentPos.Line] += endline;

            selectionStart = currentPos;
			State = TextMode.Uncommitted;

			OnModified ();
			return true;
		}
Example #22
0
        /// <summary>
        /// Runs tests on the int to string conversions.
        /// </summary>
        public unsafe static void __Test1()
        {
            int       t1 = 105;
            int       t2 = -1805;
            int       t3 = 0x6F;
            int       t4 = -0x96A;
            CString8 *p1 = (CString8 *)Stubs.CString("105");
            CString8 *p2 = (CString8 *)Stubs.CString("-1805");
            CString8 *p3 = (CString8 *)Stubs.CString("6F");
            CString8 *p4 = (CString8 *)Stubs.CString("-96A");


            if (!__StringComp(Convert.ToString(t1, false), p1))
            {
                TextMode.WriteLine("Convert.ToString(int, bool) Failed Test:  105");
            }

            if (!__StringComp(Convert.ToString(t2, false), p2))
            {
                TextMode.WriteLine("Convert.ToString(int, bool) Failed Test:  -1805");
            }

            if (!__StringComp(Convert.ToString(t3, true), p3))
            {
                TextMode.WriteLine("Convert.ToString(int, bool) Failed Test:  0x6F");
            }

            if (!__StringComp(Convert.ToString(t4, true), p4))
            {
                TextMode.WriteLine("Convert.ToString(int, bool) Failed Test:  -0x96A");
            }
        }
Example #23
0
 static unsafe void StageError(string message)
 {
     TextMode.SaveAttributes();
     TextMode.SetAttributes(TextColor.Red, TextColor.Black);
     TextMode.WriteLine(message);
     TextMode.RestoreAttributes();
 }
Example #24
0
 public static void GetHelp(CommandExecutionContext *context)
 {
     TextMode.WriteLine("Syntax: ");
     TextMode.WriteLine("     listresources");
     TextMode.WriteLine("");
     TextMode.WriteLine("Prints available devoce resources.");
 }
Example #25
0
 public unsafe static void Error(PString8 *msg)
 {
     TextMode.SaveAttributes();
     SetErrorTextAttributes();
     TextMode.WriteLine(msg);
     TextMode.RestoreAttributes();
 }
Example #26
0
        void OnCommit(object sender, Gtk.CommitArgs ca)
        {
            try {
                if (selectionRelativeIndex != 0)
                {
                    DeleteSelection();
                }
                for (int i = 0; i < ca.Str.Length; i++)
                {
                    char utf32Char;
                    if (char.IsHighSurrogate(ca.Str, i))
                    {
                        utf32Char = (char)char.ConvertToUtf32(ca.Str, i);
                        i++;
                    }
                    else
                    {
                        utf32Char = ca.Str[i];
                    }
                    lines[linePos] = lines[linePos].Insert(textPos, utf32Char.ToString());
                    textMode       = TextMode.Uncommitted;
                    textPos       += utf32Char.ToString().Length;
                }

                Recalculate();
            } finally {
                imContext.Reset();
            }
        }
Example #27
0
 public static void GetHelp(CommandExecutionContext *context)
 {
     TextMode.WriteLine("Syntax: ");
     TextMode.WriteLine("     stage");
     TextMode.WriteLine("");
     TextMode.WriteLine("Prints the current kernel stage.");
 }
Example #28
0
        public static void RenderItem(string title, uint value)
        {
            RenderItemTitle(title);

            TextMode.Write((int)value);
            TextMode.WriteLine();
        }
Example #29
0
 public static void GetHelp(CommandExecutionContext *context)
 {
     TextMode.WriteLine("Syntax: ");
     TextMode.WriteLine("     cpuid");
     TextMode.WriteLine("");
     TextMode.WriteLine("Gets information about the CPU.");
 }
Example #30
0
        public static TextCharMode TextCharModeFromTextMode(TextMode Mode)
        {
            switch (Mode)
            {
            case TextMode.COMMODORE_40_X_25_ECM:
            case TextMode.MEGA65_80_X_25_ECM:
            case TextMode.MEGA65_40_X_25_ECM:
                return(TextCharMode.COMMODORE_ECM);

            case TextMode.COMMODORE_40_X_25_HIRES:
            case TextMode.MEGA65_80_X_25_HIRES:
                return(TextCharMode.COMMODORE_HIRES);

            case TextMode.COMMODORE_40_X_25_MULTICOLOR:
            case TextMode.MEGA65_80_X_25_MULTICOLOR:
                return(TextCharMode.COMMODORE_MULTICOLOR);

            case TextMode.MEGA65_40_X_25_FCM:
            case TextMode.MEGA65_80_X_25_FCM:
                return(TextCharMode.MEGA65_FCM);

            case TextMode.MEGA65_40_X_25_FCM_16BIT:
            case TextMode.MEGA65_80_X_25_FCM_16BIT:
                return(TextCharMode.MEGA65_FCM_16BIT);

            case TextMode.COMMODORE_VIC20_22_X_23:
                return(TextCharMode.VIC20);

            default:
                Debug.Log("FromTextMode unsupported Mode " + Mode);
                return(TextCharMode.COMMODORE_HIRES);
            }
        }
Example #31
0
        public TextEngine()
        {
            lines = new List<string> ();
            lines.Add(string.Empty);
            textMode = TextMode.Unchanged;

            layout = new Pango.Layout (PintaCore.Chrome.Canvas.PangoContext);
            imContext = new Gtk.IMMulticontext ();
            imContext.Commit += OnCommit;
        }
Example #32
0
		public void Clear ()
		{
			lines.Clear();
			lines.Add(string.Empty);
			State = TextMode.Unchanged;

            currentPos = new TextPosition (0, 0);
            ClearSelection ();

			Origin = Point.Zero;

            OnModified ();
		}
Example #33
0
        public static string GetName(TextMode type)
        {
            string result = String.Empty;

            switch (type)
            {
                case TextMode.Text:
                    result = "text";
                    break;
                case TextMode.Password:
                    result = "password";
                    break;
            }

            return result;
        }
Example #34
0
		public TextEngine(List<string> lines)
		{
            this.lines = lines;
			State = TextMode.Unchanged;
		}
Example #35
0
 public TextFieldBase(string label, string name, bool required,TextMode mode)
     : base(label, name, required)
 {
     Mode = mode;
 }
Example #36
0
		private void DeleteText (TextPosition start, TextPosition end)
		{
            if (start.CompareTo(end) >= 0)
                throw new ArgumentException ("Invalid start position", "start");

            lines[start.Line] = lines[start.Line].Substring (0, start.Offset) +
                                lines[end.Line].Substring (end.Offset);

            // If this was a multi-line delete, remove all lines in between,
            // including the end line.
            lines.RemoveRange (start.Line + 1, end.Line - start.Line);

			State = TextMode.Uncommitted;
            OnModified ();
		}
Example #37
0
 public TextField(string label, string name,TextMode mode)
     : this(label, name, false, mode)
 {
 }
Example #38
0
        private void InitControl()
        {
            textMode = TextMode.String;

            minValue = 0;
            maxValue = int.MaxValue;
        }
Example #39
0
		public void PerformEnter ()
		{
			if (HasSelection ())
				DeleteSelection ();

			string currentLine = lines[currentPos.Line];

			if (currentPos.Offset == currentLine.Length) {
				// If we are at the end of a line, insert an empty line at the next line
				lines.Insert (currentPos.Line + 1, string.Empty);
			} else {
				lines.Insert (currentPos.Line + 1, currentLine.Substring (currentPos.Offset, currentLine.Length - currentPos.Offset));
				lines[currentPos.Line] = lines[currentPos.Line].Substring (0, currentPos.Offset);
			}

			State = TextMode.Uncommitted;

			currentPos.Line++;
			currentPos.Offset = 0;
            selectionStart = currentPos;
			OnModified ();
		}
Example #40
0
 public TextField(string label, string name, bool required, TextMode mode)
     : base(label, name, required, mode)
 {
 }
Example #41
0
        public void PerformBackspace()
        {
            if (selectionRelativeIndex != 0) {
                DeleteSelection ();
                return;
            }

            // We're at the beginning of a line and there's
            // a line above us, go to the end of the prior line
            if (textPos == 0 && linePos > 0) {
                int ntp = lines[linePos - 1].Length;

                lines[linePos - 1] = lines[linePos - 1] + lines[linePos];
                lines.RemoveAt (linePos);
                linePos--;
                textPos = ntp;
                Recalculate ();
            } else if (textPos > 0) {
                // We're in the middle of a line, delete the previous character
                string ln = lines[linePos];

                // If we are at the end of a line, we don't need to place a compound string
                if (textPos == ln.Length)
                    lines[linePos] = ln.Substring (0, ln.Length - 1);
                else
                    lines[linePos] = ln.Substring (0, textPos - 1) + ln.Substring (textPos);

                textPos--;
                Recalculate ();
            }

            textMode = TextMode.Uncommitted;
        }
Example #42
0
        public void Clear()
        {
            lines.Clear();
            lines.Add(string.Empty);
            textMode = TextMode.Unchanged;

            linePos = 0;
            textPos = 0;

            origin = Point.Zero;
            selectionRelativeIndex = 0;

            Recalculate ();
        }
Example #43
0
        void OnCommit(object sender, Gtk.CommitArgs ca)
        {
            try {
                if (selectionRelativeIndex != 0)
                    DeleteSelection ();
                for (int i = 0; i < ca.Str.Length; i++) {
                    char utf32Char;
                    if (char.IsHighSurrogate (ca.Str, i)) {
                        utf32Char = (char)char.ConvertToUtf32 (ca.Str, i);
                        i++;
                    } else {
                        utf32Char = ca.Str[i];
                    }
                    lines[linePos] = lines[linePos].Insert (textPos, utf32Char.ToString ());
                    textMode = TextMode.Uncommitted;
                    textPos += utf32Char.ToString ().Length;
                }

                Recalculate ();
            } finally {
                imContext.Reset ();
            }
        }
Example #44
0
        private void DeleteText(int startPos, int startLine, int len)
        {
            int TextPosLenght = len;
            int curlinepos = startLine;
            int startposition = startPos;
            if (startposition + len > lines[startLine].Length) {
                TextPosLenght -= lines[startLine].Length - startPos;
                lines[startLine] = lines[startLine].Substring (0, startposition);
                curlinepos++;
                startposition = 0;
            }

            while ((TextPosLenght != 0) && (TextPosLenght > lines[curlinepos].Length)) {
                TextPosLenght -= lines[curlinepos].Length + 1;
                lines.RemoveAt (curlinepos);
                startposition = 0;
            }
            if (TextPosLenght != 0) {
                if (startLine == curlinepos) {
                    lines[startLine] = lines[startLine].Substring (0, startposition) + lines[curlinepos].Substring (startposition + TextPosLenght);
                } else {
                    //lines[startLine] = lines[startLine].Substring (0, startposition) + lines[curlinepos].Substring (startposition + TextPosLenght - 1);
                    lines[startLine] += lines[curlinepos].Substring (startposition + TextPosLenght - 1);
                    lines.RemoveAt (curlinepos);
                }
            }

            textMode = TextMode.Uncommitted;

            Recalculate ();
        }
Example #45
0
        public void PerformDelete()
        {
            if (selectionRelativeIndex != 0) {
                DeleteSelection ();
                return;
            }

            // Where are we?!
            if ((linePos == lines.Count - 1) && (textPos == lines[lines.Count - 1].Length)) {
                // The cursor is at the end of the text block
                return;
            } else if (textPos == lines[linePos].Length) {
                // End of a line, must merge strings
                lines[linePos] = lines[linePos] + lines[linePos + 1];
                lines.RemoveAt (linePos + 1);
            } else {
                // Middle of a line somewhere
                lines[linePos] = lines[linePos].Substring (0, textPos) + (lines[linePos]).Substring (textPos + 1);
            }

            textMode = TextMode.Uncommitted;

            Recalculate ();
        }
Example #46
0
        /// <summary>
        /// Pastes text from the clipboard.
        /// </summary>
        /// <returns>
        /// <c>true</c>, if the paste was successfully performed, <c>false</c> otherwise.
        /// </returns>
        public bool PerformPaste(Gtk.Clipboard clipboard)
        {
            string txt = string.Empty;
            txt = clipboard.WaitForText ();
            if (String.IsNullOrEmpty (txt))
                return false;

            string[] ins_lines = txt.Split (Environment.NewLine.ToCharArray (), StringSplitOptions.None);
            string endline = lines [linePos].Substring (textPos);
            lines [linePos] = lines [linePos].Substring (0, textPos);
            bool first = true;
            foreach (string ins_txt in ins_lines) {
                if (!first) {
                    linePos++;
                    lines.Insert (linePos, ins_txt);
                    textPos = ins_txt.Length;
                } else {
                    first = false;
                    lines[linePos] += ins_txt;
                    textPos += ins_txt.Length;
                }
            }
            lines [linePos] += endline;

            textMode = TextMode.Uncommitted;

            Recalculate ();
            return true;
        }
Example #47
0
        public void PerformEnter()
        {
            if (selectionRelativeIndex != 0)
                DeleteSelection ();

            string currentLine = lines[linePos];

            if (textPos == currentLine.Length) {
                // If we are at the end of a line, insert an empty line at the next line
                lines.Insert (linePos + 1, string.Empty);
            } else {
                lines.Insert (linePos + 1, currentLine.Substring (textPos, currentLine.Length - textPos));
                lines[linePos] = lines[linePos].Substring (0, textPos);
            }

            textMode = TextMode.Uncommitted;

            linePos++;
            textPos = 0;
            Recalculate ();
        }
Example #48
0
        public void InsertText (string str)
        {
            if (HasSelection ())
                DeleteSelection ();

            lines[currentPos.Line] = lines[currentPos.Line].Insert (currentPos.Offset, str);
            State = TextMode.Uncommitted;
            currentPos.Offset += str.Length;
            selectionStart = currentPos;

            OnModified ();
        }
Example #49
0
		public void PerformDelete ()
		{
			if (HasSelection ()) {
				DeleteSelection ();
				return;
			}

			// Where are we?!
			if ((currentPos.Line == lines.Count - 1) && (currentPos.Offset == lines[lines.Count - 1].Length)) {
				// The cursor is at the end of the text block
				return;
			} else if (currentPos.Offset == lines[currentPos.Line].Length) {
				// End of a line, must merge strings
				lines[currentPos.Line] = lines[currentPos.Line] + lines[currentPos.Line + 1];
				lines.RemoveAt (currentPos.Line + 1);
			} else {
				// Middle of a line somewhere
				lines[currentPos.Line] = lines[currentPos.Line].Substring (0, currentPos.Offset) + (lines[currentPos.Line]).Substring (currentPos.Offset + 1);
			}

			State = TextMode.Uncommitted;

			OnModified ();
		}