Note that there are some explanatory texts on larger screens.

plurals
  1. POWriting a console within an application
    text
    copied!<p>My application requires a console to be <em>embeded</em> within the application window, an example would be in a program like autoCAD where the console is at the bottom of the window waiting for commands. </p> <p><img src="https://i.stack.imgur.com/628gl.png" alt="enter image description here"></p> <p>I need the console within my application so that I can change variables and other things, so the console is not needing to be a fully blown out shell.</p> <p>At the moment I have a simple console within my application, but It seems very clunky compared to a terminal(shell) which is what I want the console to be like.</p> <p><img src="https://i.stack.imgur.com/Yx1hd.png" alt="enter image description here"></p> <p>The way that I have done it with the console I have is when the user presses the <code>TAB</code> key the console shows, then they can type in their command/line; Once the <code>Return</code> key has been pressed the string that they have typed gets parsed and the command is processed. </p> <p>I am using <code>sf::Text</code> objects to print out text in my application window. There are a total of 5 <code>sf::Text</code> objects that are used, 4 for the previous commands/error messages and 1 for the current command line. When the <code>Return</code> key is pressed the 4th <code>sf::Text</code> changes its current string to the 3rd, the 3rd to the 2nd, the 2nd to the 1st and the 1st to the current command string then the current command string gets cleared and ready for input again. That way there is room for 4 'history' of commands and/or errors. Not the greatest but it was the best I could come up with. Of course the amount of history could be changed via adding more <code>sf::Text</code> objects. So in the end this is how I render the console to the screen</p> <pre><code>sf::RectangleShape rectangle; rectangle.setSize(sf::Vector2f(App-&gt;getSize().x, App-&gt;getSize().y / 3)); rectangle.setPosition(0, 0); rectangle.setFillColor(sf::Color::black); App-&gt;draw(rectangle); // This renders the console looking background rectangle App-&gt;draw(CLine); // This renders the current command line for(int i = 4; i &gt;= 0; --i) // This renders the history as described above, their idevidual positions are setup earlier on in the program { CHistory[i].setString(CS[i]); App-&gt;draw(CHistory[i]); } </code></pre> <p><code>App</code> is just a <code>sf::RenderWindow*</code> </p> <p>My overall question is, <strong>Is there a way that I can embed a console into my SFML window</strong> without it having to be simply an image of text objects rendered to look like a console as I have above. I would prefer to have an actual console/shell/terminal within my application. Like the standard bash shell, but of course my own shell interpreter.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload