Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
QHyodaX11Xterm.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2022 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7#include "QHyodaX11Xterm.h"
8
9/******************************************************************************
10 * QHyodaX11Xterm
11 *****************************************************************************/
12QHyodaX11Xterm::QHyodaX11Xterm(QWidget *widget, QString tabName):QHyodaX11(widget,tabName)
13{
14 qDebug() << "[NEW] QHyodaX11Xterm";
15}
16
17
18/***********************************************
19 * ~QHyodaX11Xterm
20 ***********************************************/
21QHyodaX11Xterm::~QHyodaX11Xterm(void){
22/* qDebug() << "~QHyodaX11Xterm";
23 if (xterm!=NULL){
24 if (xterm->state()==QProcess::Running) {
25 qDebug() << "~QHyodaX11Xterm xterm";
26 xterm->close(); // Cela appelle notre finished
27 //delete xterm;
28 }
29 }
30 if (xtermContainer!=NULL){
31 qDebug() << "~QHyodaX11Xterm xtermContainer";
32 //delete xtermContainer;
33 }*/
34 //if(layout!=NULL) delete layout;
35}
36
37
38/**********************************************************
39 * embedIsEmbedded
40 **********************************************************/
41void QHyodaX11Xterm::clientIsEmbedded(){
42 qDebug()<<"[QHyodaX11Xterm::clientIsEmbedded]";
43}
44
45/**********************************************************
46 * embedClosed
47 **********************************************************/
48void QHyodaX11Xterm::clientClosed(){
49 qDebug() << "[QHyodaX11Xterm::embedClosed] Container clientClosed!";
50}
51
52/**********************************************************
53 * xtermError
54 **********************************************************/
55/*void QHyodaX11Xterm::error(QX11EmbedContainer::Error error){
56 qDebug() << "[QHyodaX11Xterm::error]"<<error;
57 }*/
58
59
60bool QHyodaX11Xterm::close()
61{
62 qDebug() << "[QHyodaX11Xterm::close]";
63 return true;
64}
65
66
67void QHyodaX11Xterm::started(){
68 qDebug() << "[QHyodaX11Xterm::started]";
69}
70
71
72/**********************************************************
73 * launchXtermInWindow
74 **********************************************************/
75void QHyodaX11Xterm::launch(QWidget *widget){
76 //X11Container.append(new QHyodaX11Embed(widget, this));
77 splitter->addWidget(this);
78
79 X11Process.append(new QProcess(widget));
80 X11Process.last()->setProcessChannelMode(QProcess::MergedChannels);
81 //connect(xterm, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(finished(int, QProcess::ExitStatus)));
82 //connect(xterm, SIGNAL(readyReadStandardOutput()), this, SLOT(readyReadStandardOutput()));
83 //connect(xterm, SIGNAL(stateChanged(QProcess::ProcessState)), this, SLOT(stateChanged(QProcess::ProcessState)));
84 //connect(xterm, SIGNAL(started()), this, SLOT(started()));
85 QString executable("/usr/bin/xterm");
86 QStringList arguments=QStringList() << "-fg" << "cyan"
87 << "-bg" << "black"
88 << "-vb" // Visual bell is preferred over an audible one
89 << "-sb" << "-sl" << "8192"
90 << "-bc" // Turn on text cursor blinking
91 << "+l" // Turn logging off
92 << "+lc" // Turn off support of automatic selection of locale encodings
93 << "-s" // xterm may scroll asynchronously
94 << "+aw" // auto-wraparound should not be allowed
95 << "-ut" // Do not write a record into the the system utmp log file
96 << "-into" << QString::number(this->winId());
97 X11Process.last()->start(executable, arguments);
98 if (!X11Process.last()->waitForStarted()) qFatal("QHyodaX11Xterm::refresh NOT started!");
99}
100
101
102void QHyodaX11Xterm::stateChanged(QProcess::ProcessState newState){
103 qDebug() << "[QHyodaX11Xterm::stateChanged]"<<newState;
104}
105
106
107void QHyodaX11Xterm::finished(int exitCode, QProcess::ExitStatus exitStatus){
108 qDebug() << "[QHyodaX11Xterm] xterm has finished with exitCode="<<exitCode<<", and exitStatus="<<exitStatus;
109 // Flush des channels
110 if (X11Process.last()!=NULL){
111 X11Process.last()->closeWriteChannel();
112 if (X11Process.last()->waitForFinished()) qFatal("xterm NOT closed!");
113 }
114// xtermContainer->hide();
115
116 // On enlève le tab s'il existe: on arrive avec le CTRL-Q alors qu'il est deleté!
117 //int idx=tabParent->indexOf(this);
118 //qDebug() << "[QHyodaX11Xterm] idx="<<idx;
119 //if (idx!=-1) tabParent->removeTab(idx);
120
121 // exitStatus à 0 pour le CTRL-D ou destructeur
122 // exitStatus à 1 depuis la croix
123/* if (exitStatus==0){
124 qDebug() << "[QHyodaX11Xterm] From CTRL-D ou destructeur!";
125 delete xterm; xterm=NULL;
126 delete layout; layout=NULL;
127 delete xtermContainer; xtermContainer=NULL;
128 }
129 if (exitStatus==1){
130 qDebug() << "[QHyodaX11Xterm] From X tab!";
131 }
132*/
133}
134
135void QHyodaX11Xterm::readyReadStandardOutput(void){
136 qDebug()<<X11Process.last()->readAllStandardOutput();
137}
138
139