コード例 #1
0
ファイル: test.cs プロジェクト: xiaopangzi313/mono-curses
    static void Main()
    {
        // Standard Init sequence
        Curses.initscr();
        Curses.cbreak();
        Curses.noecho();

        // Recommended
        Curses.nonl();

        Curses.addch('ó');
        Curses.addch('ó');
        Curses.addch('ó');
        Curses.addch('ó');
        Curses.addch('ó');
        Curses.addch('ó');
        Curses.addch('ó');
        Curses.addstr("acción");
        Curses.refresh();
        Curses.getch();

        Curses.Window.Standard.intrflush(false);
        Curses.Window.Standard.keypad(true);

        // Shutdown
        Curses.endwin();
    }
コード例 #2
0
        public override void AddRune(Rune rune)
        {
            if (Clip.Contains(ccol, crow))
            {
                if (needMove)
                {
                    Curses.move(crow, ccol);
                    needMove = false;
                }
                Curses.addch((int)(uint)rune);
            }
            else
            {
                needMove = true;
            }
            if (sync)
            {
                Application.Driver.Refresh();
            }
            ccol++;
            var runeWidth = Rune.ColumnWidth(rune);

            if (runeWidth > 1)
            {
                for (int i = 1; i < runeWidth; i++)
                {
                    ccol++;
                }
            }
        }
コード例 #3
0
ファイル: viewfile.cs プロジェクト: spakis/mc
 public void ClearToEnd(int ccol)
 {
     for (int c = ccol; c < w; c++)
     {
         Curses.addch(' ');
     }
 }
コード例 #4
0
		public void DrawItem (int nth, bool is_selected)
		{
			char ch;
			
			if (nth >= listing.Count)
				throw new Exception ("overflow");

			is_selected = HasFocus && is_selected;
				
			Move (y + (nth-top) + 1, x + 1);
			
			Listing.FileNode node = listing [nth];
			int color;

			if (node == null)
				throw new Exception (String.Format ("Problem fetching item {0}", nth));

			if (node.Info.IsDirectory){
				color = is_selected ? ColorFocus : ColorDir;
				ch = '/';
			} else {
				color = is_selected ? ColorFocus : ColorNormal;
				ch = ' ';
			}
			if (node.Marked)
				color = is_selected ? ColorHotFocus : ColorHotNormal;

			Curses.attrset (color);
			for (int i = 0; i < node.Nested; i++)
				Curses.addstr ("  ");
			Curses.addch (ch);
			Curses.addstr (node.Name);
		}
コード例 #5
0
        void IListProvider.Render(int line, int col, int width, int item)
        {
            TorrentManager tm = torrent_list.GetSelected();
            string         name;

            if (tm == null)
            {
                name = "";
            }
            else
            {
                name = tm.Torrent.Files [item].Path;
            }

            string s = String.Format("{0}. {1}", item, name);

            if (s.Length > width)
            {
                s = s.Substring(0, width);
                Curses.addstr(s);
            }
            else
            {
                Curses.addstr(s);
                for (int i = s.Length; i < width; i++)
                {
                    Curses.addch(' ');
                }
            }
        }
コード例 #6
0
ファイル: viewfile.cs プロジェクト: spakis/mc
 void DrawStatus()
 {
     Move(y, x);
     Curses.attrset(Container.ContainerColorFocus);
     for (int i = 0; i < w; i++)
     {
         Curses.addch(' ');
     }
     Move(y, x);
     Curses.addstr("File: FOOBAR");
 }
コード例 #7
0
        public void WriteCharacterAt(int x, int y, char character, CharacterAttribute attributes)
        {
            _colorDriver.SetAttributes(attributes);
            //_colorDriver.SetColor(pairIdx, CharacterAttributes.Italic | CharacterAttributes.Blink);
            //Console.SetCursorPosition(x, y);

            //var wchar = new CcharT(pairIdx << 8, character);
            // Curses.mvadd_wch(y, x, ref wchar);
            //Curses.addch(character);
            Curses.move(y, x);
            Curses.addch(character);
        }
コード例 #8
0
ファイル: viewfile.cs プロジェクト: spakis/mc
 // Fills with blanks from the current column/row
 // until the end of the widget area
 public void ClearToEnd(int ccol, int crow)
 {
     for (int r = crow; r < h; r++)
     {
         Move(r + y, ccol + x);
         for (int c = ccol; c < w; c++)
         {
             Curses.addch(' ');
         }
         ccol = 0;
     }
 }
コード例 #9
0
        void IListProvider.Render(int line, int col, int width, int item)
        {
            string s = $"{item} This is item {item}";

            if (s.Length > width)
            {
                s = s.Substring(0, width);
                Curses.addstr(s);
            }
            else
            {
                Curses.addstr(s);
                for (int i = s.Length; i < width; i++)
                {
                    Curses.addch(' ');
                }
            }
        }
コード例 #10
0
        public override void Redraw()
        {
            Curses.attrset(ColorNormal);

            int i = 0;
            int l;
            int n = head > tail ? head - tail : (head + messages.Length) - tail;

            for (l = h - 1; l >= 0 && n-- > 0; l--)
            {
                int item = head - 1 - i;
                if (item < 0)
                {
                    item = messages.Length + item;
                }

                Move(y + l, x);

                int sl = messages [item].Length;
                if (sl < w)
                {
                    Curses.addstr(messages [item]);
                    for (int fi = 0; fi < w - sl; fi++)
                    {
                        Curses.addch(' ');
                    }
                }
                else
                {
                    Curses.addstr(messages [item].Substring(0, sl));
                }
                i++;
            }

            for (; l >= 0; l--)
            {
                Move(y + l, x);
                for (i = 0; i < w; i++)
                {
                    Curses.addch(' ');
                }
            }
        }
コード例 #11
0
 public override void AddRune(Rune rune)
 {
     if (Clip.Contains(ccol, crow))
     {
         if (needMove)
         {
             Curses.move(crow, ccol);
             needMove = false;
         }
         Curses.addch((int)(uint)rune);
     }
     else
     {
         needMove = true;
     }
     if (sync)
     {
         Application.Driver.Refresh();
     }
     ccol++;
 }
コード例 #12
0
        void IListProvider.Render(int line, int col, int width, int item)
        {
            TorrentManager manager = items [item];
            string         name    = manager.Torrent.Name;

            string s = String.Format("[{0,3:N0}%] {1}", manager.Progress, name);

            if (s.Length > width)
            {
                s = s.Substring(0, width);
                Curses.addstr(s);
            }
            else
            {
                Curses.addstr(s);
                for (int i = s.Length; i < width; i++)
                {
                    Curses.addch(' ');
                }
            }
        }
コード例 #13
0
ファイル: viewfile.cs プロジェクト: spakis/mc
        void DrawView()
        {
            int  col = 0;
            bool skip_until_newline = false;

            Curses.attrset(Container.ContainerColorNormal);
            Move(y + 1, x);
            SetPosition(top_byte);
            for (int row = 0; row < h;)
            {
                int c = GetChar();
                switch (c)
                {
                /* End of file */
                case -1:
                    ClearToEnd(col, row);
                    row = h;
                    continue;

                case 10:
                    ClearToEnd(col);
                    col = 0;
                    row++;
                    skip_until_newline = false;
                    Move(y + row, x + col);
                    continue;

                case 9:
                    for (int nc = (col / 8 + 1) * 8; col < nc; col++)
                    {
                        Curses.addch(' ');
                    }

                    continue;

                case 13:
                    continue;
                }

                // Control chars or unicode > 0xffff
                if (c < 32 || c > 0xffff)
                {
                    c = '.';
                }

                if (skip_until_newline)
                {
                    continue;
                }

                Curses.addch((char)c);
                col++;
                if (col > w)
                {
                    if (Wrap)
                    {
                        col = 0;
                        row++;
                    }
                    else
                    {
                        skip_until_newline = true;
                    }
                }
            }
        }