Skip to content
Snippets Groups Projects
Commit 27891753 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

*** empty log message ***

parent a1802176
No related branches found
No related tags found
No related merge requests found
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#include <readline/readline.h> #include <readline/readline.h>
#include <readline/history.h> #include <readline/history.h>
// compile with: g++ interact.cpp -lreadline // compile with: g++ interactive.cpp -lreadline
class GmshInteractiveClient{ class GmshInteractiveClient{
private: private:
...@@ -11,7 +11,8 @@ class GmshInteractiveClient{ ...@@ -11,7 +11,8 @@ class GmshInteractiveClient{
GmshInteractiveClient() GmshInteractiveClient()
{ {
using_history(); using_history();
char *socket = "/Users/geuzaine/.gmshsock"; char socket[256];
sprintf(socket, "%s/.gmshsock", getenv("HOME"));
if(_client.Connect(socket) < 0) { if(_client.Connect(socket) < 0) {
printf("Unable to connect to Gmsh\n"); printf("Unable to connect to Gmsh\n");
exit(1); exit(1);
...@@ -25,6 +26,12 @@ class GmshInteractiveClient{ ...@@ -25,6 +26,12 @@ class GmshInteractiveClient{
} }
void read(char *prompt) void read(char *prompt)
{ {
// preload a few commands in the history:
add_history("lc = 1.;");
add_history("Point(1) = {0,0,0,lc};");
add_history("Point(2) = {5,0,0,lc};");
add_history("Line(1) = {1,2};");
while (1) { while (1) {
// read input char until CR, LF, EOF, ^D // read input char until CR, LF, EOF, ^D
char *ptr = readline(prompt); char *ptr = readline(prompt);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment