Beispiel #1
0
        void IZMachineIO.PutTextRectangle(string[] lines)
        {
            if (lineInputActive)
            {
                Glk.glk_cancel_line_event(currentWin, out canceledLineEvent);
                lineInputActive = false;
            }

            if (currentWin == lowerWin)
            {
                foreach (string str in lines)
                {
                    if (unicode)
                    {
                        Glk.glk_put_string_uni(str);
                    }
                    else
                    {
                        Glk.glk_put_string(str);
                    }
                    Glk.glk_put_char((byte)'\n');
                }
            }
            else
            {
                int oxpos = xpos;

                foreach (string str in lines)
                {
                    Glk.glk_window_move_cursor(upperWin, (uint)oxpos, (uint)ypos);
                    if (unicode)
                    {
                        Glk.glk_put_string_uni(str);
                    }
                    else
                    {
                        Glk.glk_put_string(str);
                    }

                    ypos++;
                    if (ypos >= screenHeight)
                    {
                        ypos = (int)screenHeight - 1;
                    }

                    xpos = oxpos + str.Length;
                    if (xpos >= screenWidth)
                    {
                        xpos = (int)screenWidth - 1;
                    }
                }
            }
        }
Beispiel #2
0
        void IZMachineIO.PutString(string str)
        {
            if (lineInputActive)
            {
                Glk.glk_cancel_line_event(currentWin, out canceledLineEvent);
                lineInputActive = false;
                // glk_cancel_line_event prints a newline
                if (str.Length > 0 && str[0] == '\n')
                {
                    str = str.Substring(1);
                }
            }

            if (unicode)
            {
                Glk.glk_put_string_uni(str);
            }
            else
            {
                Glk.glk_put_string(str);
            }

            if (currentWin == upperWin)
            {
                xpos += str.Length;
                uint width, height;
                Glk.glk_window_get_size(upperWin, out width, out height);
                while (xpos >= width)
                {
                    xpos -= (int)width;
                    ypos++;
                    if (ypos >= height)
                    {
                        ypos = (int)height - 1;
                    }
                }
            }
        }