Beispiel #1
0
        public void DrawMenu(TextBuffer GUIText)
        {
            ValidateSelected();
            Widget[] Entries = MenuEntries.ToArray();

            // Separator
            int Width = MenuTitle.Length + 5;
            int Height = 3;

            for (int i = 0; i < Entries.Length; i++) {
                Width = Math.Max(Width, Entries[i].Width + 3);
                Height += Entries[i].Height;
            }

            int X = GUIText.BufferWidth / 2 - Width / 2 - 1;
            int Y = GUIText.BufferHeight / 2 - Height / 2 - 1;

            //DrawBox(GUIText, Width, 0, 0, GUIText.BufferHeight - 1);

            // Outline
            for (int x = 0; x < Width; x++)
                for (int y = 0; y < Height; y++)
                    GUIText[X + x, Y + y] = 0;
            GUIText.DrawBox(X, Y, Width, Height);
            GUIText.Print(X + 2, Y, "[" + MenuTitle + "]");

            // Entries
            int YOff = 0;
            for (int i = 0; i < Entries.Length; i++) {
                Entries[i].Draw(GUIText, X + 2, Y + 2 + YOff, i == Selected);
                YOff += Entries[i].Height;
            }
            /*GUIText.Print(X + 2, Y + i + 2, Entries[i],
                i == Selected ? Color.Black : ConsoleColor.Gray.ToColor(), i == Selected ? Color.White : Color.Black);*/
        }
 public void Setup()
 {
     textBuffer = new TextBuffer(
         "    var a = 12.34;\n" +
         "    var b = 56.78;\n" +
         "    var c = 90.11;\n" +
         "    var d = 12345;\n" +
         "    var e = 67890;\n");
 }
		/// <summary>
		/// Initializes a new instance of the <see cref="ClassificationSpan"/> class.
		/// </summary>
		/// <exception cref="ArgumentNullException"><para><paramref name="classification"/> is <see langword="null"/>.</para></exception>
		public ClassificationSpan(TextBuffer buffer, Int32 start, Int32 length, String classification)
			: base(buffer, start, length)
		{
			if (classification == null)
			{
				throw new ArgumentNullException("classification");
			}
			_classification = classification;
		}
Beispiel #4
0
 public ParagraphModel EndParagraph()
 {
     _buffer.EndOfLine();
     var retval = new ParagraphModel(_buffer.ToArray(), _heading);
     _buffer.Clear();
     _buffer = null;
     _heading = null;
     return retval;
 }
 public MainWindow()
     : base(Gtk.WindowType.Toplevel)
 {
     Build ();
     GLib.Timeout.Add(50, new GLib.TimeoutHandler(TimerCallback));
     _textBuf = textview1.Buffer;
     Event.RegisterImpl(AddHandleFunc, UpdateHandleFunc, RemoveHandleFunc, AddTimeoutFunc, UpdateTimeoutFunc,
                            RemoveTimeoutFunc);
 }
Beispiel #6
0
        public void TestFindAllOccurences03()
        {
            string initialContent = "First line\nSecond line\nThird line\nFourth line";
            TextBuffer localBuffer = new TextBuffer(initialContent);
            Assert.AreEqual(4, localBuffer.GetLineCount());
            localBuffer.FindReplace("design", null, FindOptions.ReplaceOnce);
            List<FindPosition> findResults = new List<FindPosition>();
            localBuffer.GetSearchResults(ref findResults);

            Assert.AreEqual(0, findResults.Count);
        }
Beispiel #7
0
 public static int ReplaceFirst(Matcher m,Substitution substitution,TextBuffer dest)
 {
     int c=0;
     if(m.Find()) {
         if(m.Start>0) m.Group(Matcher.PREFIX,dest);
         substitution.AppendSubstitution(m,dest);
         c++;
         m.SetTarget(m,Matcher.SUFFIX);
     }
     m.Group(Matcher.TARGET,dest);
     return c;
 }
Beispiel #8
0
 public void TextWithGroupRuby(UString baseText, UString rubyText)
 {
     var baseBuffer = new TextBuffer(_zwSize, _wordWrap, _advancing, _latinMetric, 64);
     var rubyBuffer = new TextBuffer(_rubyZwSize, _wordWrap, _advancing, _latinMetric, 128);
     _buffer.MoveLastLetterStateTo(baseBuffer);
     baseBuffer.Append(baseText);
     rubyBuffer.Append(rubyText);
     _buffer.AppendObject(new GroupRuby(baseBuffer.ToArray(), rubyBuffer.ToArray()));
     baseBuffer.MoveLastLetterStateTo(_buffer);
     baseBuffer.Clear();
     rubyBuffer.Clear();
 }
		/// <summary>
		/// Initializes a new instance of the <see cref="VersionedTextSpan"/> class.
		/// </summary>
		/// <exception cref="ArgumentNullException">
		/// <para><paramref name="buffer"/> is <see langword="null"/>.</para>
		/// -or-
		/// <para><paramref name="span"/> is <see langword="null"/>.</para>
		/// </exception>
		public VersionedTextSpan(TextBuffer buffer, Span span)
		{
			if (buffer == null)
			{
				throw new ArgumentNullException("buffer");
			}
			if (span == null)
			{
				throw new ArgumentNullException("span");
			}
			this.Construct(buffer, buffer.Version, span.Start, span.Length, SpanTrackingMode.EdgeExclusive);
		}
Beispiel #10
0
 public override void Draw(TextBuffer TBuffer, int X, int Y, bool IsSelected)
 {
     Color Fg = ConsoleColor.Gray.ToColor();
     Color Bg = Color.Black;
     if (IsSelected) {
         Fg = Color.Black;
         if (Enabled)
             Bg = Color.White;
         else
             Bg = ConsoleColor.DarkGray.ToColor();
     }
     TBuffer.Print(X, Y, Txt, Fg, Bg);
 }
Beispiel #11
0
Datei: View.cs Projekt: dfr0/moon
	public override Widget GetView ()
	{
		if (scrolled_window != null)
			return scrolled_window;

		buffer = new TextBuffer (new TextTagTable ());
		buffer.Text = Text;
		view = new TextView (buffer);
		
		scrolled_window = new ScrolledWindow ();
		scrolled_window.Add (view);
		
		return scrolled_window;
	}
Beispiel #12
0
 public static int Replace(Matcher m,Substitution substitution,TextBuffer dest)
 {
     bool firstPass=true;
     int c=0;
     while(m.Find()) {
         if(m.End==0 && !firstPass) continue;  //allow to Replace at "^"
         if(m.Start>0) m.Group(Matcher.PREFIX,dest);
         substitution.AppendSubstitution(m,dest);
         c++;
         m.SetTarget(m,Matcher.SUFFIX);
         firstPass=false;
     }
     m.Group(Matcher.TARGET,dest);
     return c;
 }
Beispiel #13
0
      /// <summary>Formats the input BPL object into the output XML document.</summary>
      public override bool Format(BplObject input) {
         if (!PrepareFormatter(input)) return false;

         _output = new TextBuffer(this);
         try {
            _serializeObject(null, Input);
            _injectMapping(NSMapping);
            Output = _output.ToString();
         } catch (Exception e) {
            AddException(e);
         }
         _output = null;

         return Success;
      }
Beispiel #14
0
        public MenuState()
        {
            GUIText = new TextBuffer(80, 30);
            GUIText.SetFontTexture(ResourceMgr.Get<Texture>("font"));
            GUIText.Sprite.Scale = Renderer.Screen.Size.ToVec2f().Divide(GUIText.Sprite.Texture.Size.ToVec2f());
            GUIText.Sprite.Position = Renderer.Screen.Texture.Size.ToVec2f() / 2;
            GUIText.Sprite.Origin = GUIText.Sprite.Texture.Size.ToVec2f() / 2;

            AAA = new RenderSprite(Renderer.Screen.Size);
            BBB = new RenderSprite(Renderer.Screen.Size);
            CRT = new RenderSprite(Renderer.Screen.Size);

            MainMenu = new MenuEntry("Main Menu");
            if (Renderer.CountStates() > 0)
                MainMenu.Add(new WidgetButton("Continue Universe", () => Renderer.PopState()));

            MainMenu
                .Add(new WidgetButton("Create Universe", () => Renderer.PushState(new GameState())))
                .Add(new WidgetButton("Load Universe", () => CurrentMenu = LoadUniverse).Disable())
                .Add(new WidgetButton("Universal Constants", () => CurrentMenu = Constants))
                .Add(new WidgetButton("Terminate", () => Program.Running = false));

            Action BackToMainMenu = () => {
                GUIText.Clear();
                CurrentMenu = MainMenu;
            };

            LoadUniverse = new MenuEntry("Load Universe")
                .Add(new WidgetButton("Back", BackToMainMenu));

            Constants = new MenuEntry("Universal Constants")
                .Add(new WidgetTextbox("Resolution X", Program.ResX.ToString(), 6, (S) => {
                    if (S.Length > 0)
                        Program.ResX = int.Parse(S);
                    GUIText.Print(0, 0, "Restart required for changes to take effect");
                }, char.IsNumber))
                .Add(new WidgetTextbox("Resolution Y", Program.ResY.ToString(), 6, (S) => {
                    if (S.Length > 0)
                        Program.ResY = int.Parse(S);
                    GUIText.Print(0, 0, "Restart required for changes to take effect");
                }, char.IsNumber))
                .Add(new WidgetCheckbox("Debug", Program.Debug, (B) => Program.Debug = B))
                            .Add(new WidgetCheckbox("Border", Program.Border, (B) => Program.Border = B))
                .Add(new WidgetButton("Back", BackToMainMenu));

            CurrentMenu = MainMenu;
            CurrentMenu.DrawMenu(GUIText);
        }
Beispiel #15
0
        public void TestFindAllOccurences02()
        {
            string initialContent = "First line design\nSecond line\nThird line\nFourth design design";
            TextBuffer localBuffer = new TextBuffer(initialContent);
            Assert.AreEqual(4, localBuffer.GetLineCount());
            localBuffer.FindReplace("design", null, FindOptions.ReplaceOnce);
            List<FindPosition> findResults = new List<FindPosition>();
            localBuffer.GetSearchResults(ref findResults);

            Assert.AreEqual(new Point(11, 0), findResults[0].startPoint);
            Assert.AreEqual(new Point(16, 0), findResults[0].endPoint);
            Assert.AreEqual(new Point(7, 3), findResults[1].startPoint);
            Assert.AreEqual(new Point(12, 3), findResults[1].endPoint);
            Assert.AreEqual(new Point(14, 3), findResults[2].startPoint);
            Assert.AreEqual(new Point(19, 3), findResults[2].endPoint);
        }
		public TextFormattingSource(
			TextBuffer textBuffer
			, IClassificationFormatMap classificationFormatMap
			, Int32 startIndex
			, Int32 length
			, IList<ClassificationSpan> classificationSpans
			, IList<SpaceNegotiation> spaceNegotiations
			)
		{
			List<SpaceNegotiation> list = null;
			if (spaceNegotiations != null)
			{
				list = new List<SpaceNegotiation>(spaceNegotiations);
				list.Sort(new Comparison<SpaceNegotiation>(this.Comparison));
			}
			String text = textBuffer.GetText(startIndex, length);
			_normalizedSpanManager = new NormalizedSpanManager(text, startIndex, classificationSpans, list, classificationFormatMap);
		}
        public void BasicTest()
        {
            var str = "Test1Test2Test3";
            var text = new TextBuffer();
            var reader = text.GetReader();

            var evt = new AutoResetEvent(false);

            Action a = () =>
            {
                evt.WaitOne();
                text.Write(str);
                evt.WaitOne();
                text.Write(str);
            };

            var t = new Thread(new ThreadStart(a));
            t.Start();
            char[] buffer = new char[0x1000];
            var task = reader.ReadAsync(buffer, 0, 1000);
            evt.Set();
            task.Wait();
            var s = task.Result;
            log.WriteLine(s.ToString());

            task = reader.ReadAsync(buffer, 0, 1000);

            var reader2 = text.GetReader();

            evt.Set();

            var task2 = reader2.ReadToEndAsync();

            task.Wait();
            task2.Wait();
            s = task.Result;
            var s2 = task2.Result;
            Assert.True(!string.IsNullOrEmpty(s2));
            log.WriteLine(s.ToString());
            log.WriteLine(s2.ToString());

            t.Join();
        }
Beispiel #18
0
 public override bool GetParameters(TextBuffer textBuffer)
 {
     return true;
 }
Beispiel #19
0
    RepairRunIntervalWindow(Gtk.Window parent, RunInterval myRun, int pDN)
    {
        Glade.XML gladeXML;
        gladeXML = Glade.XML.FromAssembly (Util.GetGladePath() + "repair_sub_event.glade", "repair_sub_event", null);
        gladeXML.Autoconnect(this);
        repair_sub_event.Parent = parent;

        //put an icon to window
        UtilGtk.IconWindow(repair_sub_event);

        this.runInterval = myRun;

        repair_sub_event.Title = Catalog.GetString("Repair intervallic race");

        System.Globalization.NumberFormatInfo localeInfo = new System.Globalization.NumberFormatInfo();
        localeInfo = System.Globalization.NumberFormatInfo.CurrentInfo;
        label_header.Text = string.Format(Catalog.GetString("Use this window to repair this test.\nDouble clic any cell to edit it (decimal separator: '{0}')"), localeInfo.NumberDecimalSeparator);

        type = SqliteRunIntervalType.SelectAndReturnRunIntervalType(myRun.Type, false);

        TextBuffer tb = new TextBuffer (new TextTagTable());
        tb.Text = createTextForTextView(type);
        textview1.Buffer = tb;

        createTreeView(treeview_subevents);
        //count, time
        store = new TreeStore(typeof (string), typeof (string));
        treeview_subevents.Model = store;
        fillTreeView (treeview_subevents, store, myRun, pDN);

        button_add_before.Sensitive = false;
        button_add_after.Sensitive = false;
        button_delete.Sensitive = false;

        label_totaltime_value.Text = getTotalTime().ToString() + " " + Catalog.GetString("seconds");

        treeview_subevents.Selection.Changed += onSelectionEntry;
    }
Beispiel #20
0
 private void loadNoteToBuffer(String title)
 {
     if (title != null) {
         buf = editor.Buffer;
         buf.Text = notesStore.getNoteContent (title);
     }
 }
Beispiel #21
0
    protected virtual void onSearchbarKeyEvent(object o, Gtk.KeyPressEventArgs args)
    {
        string key = args.Event.Key.ToString ();
        Console.WriteLine ("searchbar key: " + key);

        if (key.Equals ("Return")) {

            if (!notesStore.doesNoteExist (searchbar.Text.Trim ()) && searchbar.Text != null && searchbar.Text.Length > 0) {
                Note newNote = new Note (searchbar.Text.Trim (), "");
                store.AddNode (new NoteNode (newNote));
                currentNote = newNote.title;
                notesStore.createNote (currentNote);
                buf = editor.Buffer;
                buf.Text = "";
                editor.GrabFocus ();
            }

        } else if (key.Equals ("Down")) {
            noteslist.GrabFocus ();

            NoteNode node = noteslist.NodeSelection.SelectedNode as NoteNode;

            loadNoteToBuffer (node);
        }
    }
			/// <summary>
			/// Initializes a new instance of the <see cref="LineWidthCache"/> class.
			/// </summary>
			public LineWidthCache(TextBuffer textBuffer)
			{
				_textBuffer = textBuffer;
			}
            private void PrintTitle(TextBuffer buffer,
						 ref TextIter iter)
            {
                if (game == null)
                    return;
                string title = String.Format ("{0} vs {1}",
                                  game.White,
                                  game.Black);

                buffer.CreateMark ("-1", iter, true);
                buffer.InsertWithTagsByName (ref iter, title,
                                 HEADING_TAG);
                buffer.Insert (ref iter, "\n");

                Widget tagdetails = GetTagDetailsWidget ();
                TextChildAnchor anchor =
                    buffer.CreateChildAnchor (ref iter);
                view.AddChildAtAnchor (tagdetails, anchor);
                buffer.Insert (ref iter, "\n\n");
            }
            private void UpdateGameDetails(TextBuffer buffer,
							ref TextIter iter)
            {
                PrintTitle (buffer, ref iter);
                if (game == null)
                    return;

                if (game.Comment != null)
                  {
                      buffer.InsertWithTags (ref
                                 iter,
                                 game.Comment,
                                 commentTag);
                      buffer.Insert (ref iter, "\n");
                  }

                int i = 0;
                int moveno = 1;
                foreach (PGNChessMove move in game.Moves)
                {
                    if (i % 2 == 0)
                      {
                          buffer.InsertWithTags (ref
                                     iter,
                                     moveno.
                                     ToString
                                     (),
                                     movenumberTag);
                          moveno++;
                          buffer.Insert (ref iter,
                                 ". ");
                      }

                    string markstr = i.ToString ();
                    string text = move.DetailedMove;
                    buffer.CreateMark (markstr, iter, true);	// left gravity
                    TextTag link_tag = new TextTag (null);
                    tag_links[link_tag] = i;
                    taglinks.Add (link_tag);
                    buffer.TagTable.Add (link_tag);
                    buffer.InsertWithTags (ref iter, text,
                                   moveTag,
                                   link_tag);
                    marks[markstr] = text.Length;
                    buffer.Insert (ref iter, " ");

                    if (move.comment != null)
                      {
                          buffer.Insert (ref iter,
                                 "\n");
                          buffer.InsertWithTags (ref
                                     iter,
                                     FormatComment
                                     (move.
                                      comment),
                                     commentTag);
                          buffer.Insert (ref iter,
                                 "\n");
                      }
                    i++;
                }
            }
            private void GetItersForMove(int idx,
						      TextBuffer buffer,
						      out TextIter start,
						      out TextIter end)
            {
                string markstr = idx.ToString ();
                int len = (int) marks[markstr];
                start = buffer.GetIterAtMark (buffer.
                                  GetMark
                                  (markstr));
                end = start;
                end.ForwardChars (len);
            }
Beispiel #26
0
    private void chronopicLabels(int cps)
    {
        label_connected_chronopics.Text = "<b>" + cps.ToString() + "</b>";
        label_connected_chronopics.UseMarkup = true;

        string myMessage = "";
        if(cps == 0)
            myMessage = Constants.SimulatedMessage;
        else if(cps == 1)
            myMessage = Constants.ChronopicOne;
        else
            myMessage = Constants.ChronopicMore;

        TextBuffer tb = new TextBuffer (new TextTagTable());
        tb.Text = myMessage;
        textview_message_connected_chronopics.Buffer = tb;

        /*
         * hidden to save space
        if(cps > 0)
            image_connected_chronopics.Hide();
        else
            image_connected_chronopics.Show();
        */
    }
Beispiel #27
0
    private void fillDialog()
    {
        int mySportID;
        int mySpeciallityID;
        int myLevelID;
        if(adding) {
            //now dateTime is undefined until user changes it
            dateTime = DateTime.MinValue;
            label_date.Text = Catalog.GetString("Undefined");

            mySportID = currentSession.PersonsSportID;
            mySpeciallityID = currentSession.PersonsSpeciallityID;
            myLevelID = currentSession.PersonsPractice;
        } else {
            //PERSON STUFF
            entry1.Text = currentPerson.Name;
            if (currentPerson.Sex == Constants.M) {
                radiobutton_man.Active = true;
            } else {
                radiobutton_woman.Active = true;
            }

            dateTime = currentPerson.DateBorn;
            if(dateTime == DateTime.MinValue)
                label_date.Text = Catalog.GetString("Undefined");
            else
                label_date.Text = dateTime.ToLongDateString();

            //country stuff
            if(currentPerson.CountryID != Constants.CountryUndefinedID) {
                string [] countryString = SqliteCountry.Select(currentPerson.CountryID);

                combo_continents.Active = UtilGtk.ComboMakeActive(continentsTranslated,
                        Catalog.GetString(countryString[3]));

                combo_countries.Active = UtilGtk.ComboMakeActive(countriesTranslated,
                        Catalog.GetString(countryString[1]));
            }

            TextBuffer tb1 = new TextBuffer (new TextTagTable());
            tb1.Text = currentPerson.Description;
            textview_description.Buffer = tb1;

            serverUniqueID = currentPerson.ServerUniqueID;

            //PERSONSESSION STUFF
            PersonSession myPS = SqlitePersonSession.Select(currentPerson.UniqueID, currentSession.UniqueID);

            spinbutton_height.Value = myPS.Height;
            spinbutton_weight.Value = myPS.Weight;

            weightIni = myPS.Weight; //store for tracking if changes

            mySportID = myPS.SportID;
            mySpeciallityID = myPS.SpeciallityID;
            myLevelID = myPS.Practice;

            TextBuffer tb2 = new TextBuffer (new TextTagTable());
            tb2.Text = myPS.Comments;
            textview_ps_comments.Buffer = tb2;
        }

        sport = SqliteSport.Select(false, mySportID);
        combo_sports.Active = UtilGtk.ComboMakeActive(sportsTranslated, sport.ToString());

        combo_speciallities.Active = UtilGtk.ComboMakeActive(speciallitiesTranslated, SqliteSpeciallity.Select(false, mySpeciallityID));

        combo_levels.Active = UtilGtk.ComboMakeActive(levels, myLevelID + ":" + Util.FindLevelName(myLevelID));
    }
Beispiel #28
0
 public override void SetParameters(TextBuffer textBuffer)
 {
 }
Beispiel #29
0
 public static TextBuffer TextViewPrint(string message)
 {
     TextBuffer tb = new TextBuffer (new TextTagTable());
     tb.Text = message;
     return tb;
 }
Beispiel #30
0
	void InsertWithMarkup (TextBuffer buffer, ref TextIter iter, string text)
	{
		Match match = markupRegex.Match (text);
		if (!match.Success) {
			buffer.Insert (ref iter, text);
			return;
		}

		int start = 0, len, idx;
		var tags = new List <string> ();
		while (match.Success) {
			len = match.Index - start;
			if (len > 0)
				buffer.InsertWithTagsByName (ref iter, text.Substring (start, len), tags.ToArray ());

			switch (match.Value.ToLowerInvariant ()) {
				case "<i>":
					if (!tags.Contains ("italic"))
						tags.Add ("italic");
					break;

				case "</i>":
					idx = tags.IndexOf ("italic");
					if (idx > -1)
						tags.RemoveAt (idx);
					break;

				case "<b>":
					if (!tags.Contains ("bold"))
						tags.Add ("bold");
					break;

				case "</b>":
					idx = tags.IndexOf ("bold");
					if (idx > -1)
						tags.RemoveAt (idx);
					break;

				case "<big>":
					if (!tags.Contains ("big"))
						tags.Add ("big");
					break;

				case "</big>":
					idx = tags.IndexOf ("big");
					if (idx > -1)
						tags.RemoveAt (idx);
					break;

				case "<s>":
					if (!tags.Contains ("strikethrough"))
						tags.Add ("strikethrough");
					break;

				case "</s>":
					idx = tags.IndexOf ("strikethrough");
					if (idx > -1)
						tags.RemoveAt (idx);
					break;

				case "<sub>":
					if (!tags.Contains ("sub"))
						tags.Add ("sub");
					break;

				case "</sub>":
					idx = tags.IndexOf ("sub");
					if (idx > -1)
						tags.RemoveAt (idx);
					break;

				case "<sup>":
					if (!tags.Contains ("sup"))
						tags.Add ("sup");
					break;

				case "</sup>":
					idx = tags.IndexOf ("sup");
					if (idx > -1)
						tags.RemoveAt (idx);
					break;

				case "<small>":
					if (!tags.Contains ("small"))
						tags.Add ("small");
					break;

				case "</small>":
					idx = tags.IndexOf ("small");
					if (idx > -1)
						tags.RemoveAt (idx);
					break;

				case "<tt>":
					if (!tags.Contains ("monospace"))
						tags.Add ("monospace");
					break;

				case "</tt>":
					idx = tags.IndexOf ("monospace");
					if (idx > -1)
						tags.RemoveAt (idx);
					break;

				case "<u>":
					if (!tags.Contains ("underline"))
						tags.Add ("underline");
					break;

				case "</u>":
					idx = tags.IndexOf ("underline");
					if (idx > -1)
						tags.RemoveAt (idx);
					break;
			}

			start = match.Index + match.Length;
			match = match.NextMatch ();
		}

		if (start < text.Length)
			buffer.InsertWithTagsByName (ref iter, text.Substring (start), tags.ToArray ());
	}