-rw-r--r-- | core/apps/embeddedkonsole/MyPty.cpp | 10 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/TEHistory.cpp | 275 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/TEHistory.h | 50 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/TEScreen.cpp | 18 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/TEWidget.cpp | 148 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/TEWidget.h | 16 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/TEmulation.cpp | 1 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/commandeditdialog.cpp | 4 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/konsole.cpp | 2214 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/konsole.h | 224 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/main.cpp | 1 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/session.cpp | 20 | ||||
-rw-r--r-- | core/apps/embeddedkonsole/session.h | 5 |
13 files changed, 1941 insertions, 1045 deletions
diff --git a/core/apps/embeddedkonsole/MyPty.cpp b/core/apps/embeddedkonsole/MyPty.cpp index 7e820ad..e7d8274 100644 --- a/core/apps/embeddedkonsole/MyPty.cpp +++ b/core/apps/embeddedkonsole/MyPty.cpp | |||
@@ -74,16 +74,17 @@ | |||
74 | #include <signal.h> | 74 | #include <signal.h> |
75 | #include <fcntl.h> | 75 | #include <fcntl.h> |
76 | #include <unistd.h> | 76 | #include <unistd.h> |
77 | #include <termios.h> | 77 | #include <termios.h> |
78 | #include <sys/types.h> | 78 | #include <sys/types.h> |
79 | #include <sys/ioctl.h> | 79 | #include <sys/ioctl.h> |
80 | #include <sys/wait.h> | 80 | #include <sys/wait.h> |
81 | 81 | ||
82 | #undef HAVE_OPENPTY | ||
82 | #ifdef HAVE_OPENPTY | 83 | #ifdef HAVE_OPENPTY |
83 | #include <pty.h> | 84 | #include <pty.h> |
84 | #endif | 85 | #endif |
85 | 86 | ||
86 | #include "MyPty.h" | 87 | #include "MyPty.h" |
87 | 88 | ||
88 | 89 | ||
89 | #undef VERBOSE_DEBUG | 90 | #undef VERBOSE_DEBUG |
@@ -141,16 +142,22 @@ void MyPty::error() | |||
141 | int MyPty::run(const char* cmd, QStrList &, const char*, int) | 142 | int MyPty::run(const char* cmd, QStrList &, const char*, int) |
142 | { | 143 | { |
143 | // This is code from the Qt DumbTerminal example | 144 | // This is code from the Qt DumbTerminal example |
144 | cpid = fork(); | 145 | cpid = fork(); |
145 | 146 | ||
146 | if ( !cpid ) { | 147 | if ( !cpid ) { |
147 | // child - exec shell on tty | 148 | // child - exec shell on tty |
148 | for (int sig = 1; sig < NSIG; sig++) signal(sig,SIG_DFL); | 149 | for (int sig = 1; sig < NSIG; sig++) signal(sig,SIG_DFL); |
150 | |||
151 | // attempt to keep apm driver from killing us on power on/off | ||
152 | signal(SIGSTOP, SIG_IGN); | ||
153 | signal(SIGCONT, SIG_IGN); | ||
154 | signal(SIGTSTP, SIG_IGN); | ||
155 | |||
149 | int ttyfd = open(ttynam, O_RDWR); | 156 | int ttyfd = open(ttynam, O_RDWR); |
150 | dup2(ttyfd, STDIN_FILENO); | 157 | dup2(ttyfd, STDIN_FILENO); |
151 | dup2(ttyfd, STDOUT_FILENO); | 158 | dup2(ttyfd, STDOUT_FILENO); |
152 | dup2(ttyfd, STDERR_FILENO); | 159 | dup2(ttyfd, STDERR_FILENO); |
153 | // should be done with tty, so close it | 160 | // should be done with tty, so close it |
154 | close(ttyfd); | 161 | close(ttyfd); |
155 | static struct termios ttmode; | 162 | static struct termios ttmode; |
156 | if ( setsid() < 0 ) | 163 | if ( setsid() < 0 ) |
@@ -158,18 +165,17 @@ int MyPty::run(const char* cmd, QStrList &, const char*, int) | |||
158 | #if defined (TIOCSCTTY) | 165 | #if defined (TIOCSCTTY) |
159 | // grabbed from APUE by Stevens | 166 | // grabbed from APUE by Stevens |
160 | ioctl(STDIN_FILENO, TIOCSCTTY, 0); | 167 | ioctl(STDIN_FILENO, TIOCSCTTY, 0); |
161 | #endif | 168 | #endif |
162 | tcgetattr( STDIN_FILENO, &ttmode ); | 169 | tcgetattr( STDIN_FILENO, &ttmode ); |
163 | ttmode.c_cc[VINTR] = 3; | 170 | ttmode.c_cc[VINTR] = 3; |
164 | ttmode.c_cc[VERASE] = 8; | 171 | ttmode.c_cc[VERASE] = 8; |
165 | tcsetattr( STDIN_FILENO, TCSANOW, &ttmode ); | 172 | tcsetattr( STDIN_FILENO, TCSANOW, &ttmode ); |
166 | if(strlen(getenv("TERM"))<=0) | 173 | setenv("TERM","vt100",1); |
167 | setenv("TERM","vt100",1); | ||
168 | setenv("COLORTERM","0",1); | 174 | setenv("COLORTERM","0",1); |
169 | 175 | ||
170 | if (getuid() == 0) { | 176 | if (getuid() == 0) { |
171 | char msg[] = "WARNING: You are running this shell as root!\n"; | 177 | char msg[] = "WARNING: You are running this shell as root!\n"; |
172 | write(ttyfd, msg, sizeof(msg)); | 178 | write(ttyfd, msg, sizeof(msg)); |
173 | } | 179 | } |
174 | 180 | ||
175 | QString ccmd = "-"+QFileInfo(cmd).fileName(); //creates a login shell | 181 | QString ccmd = "-"+QFileInfo(cmd).fileName(); //creates a login shell |
diff --git a/core/apps/embeddedkonsole/TEHistory.cpp b/core/apps/embeddedkonsole/TEHistory.cpp index db9d10c..504cd13 100644 --- a/core/apps/embeddedkonsole/TEHistory.cpp +++ b/core/apps/embeddedkonsole/TEHistory.cpp | |||
@@ -1,219 +1,230 @@ | |||
1 | /* -------------------------------------------------------------------------- */ | 1 | /* -------------------------------------------------------------------------- */ |
2 | /* */ | 2 | /* */ |
3 | /* [TEHistory.C] History Buffer */ | 3 | /* [TEHistory.C] History Buffer */ |
4 | /* */ | 4 | /* */ |
5 | /* -------------------------------------------------------------------------- */ | 5 | /* -------------------------------------------------------------------------- */ |
6 | /* */ | 6 | /* */ |
7 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ | 7 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ |
8 | /* */ | 8 | /* */ |
9 | /* This file is part of Konsole - an X terminal for KDE */ | 9 | /* This file is part of Qkonsole - an X terminal for KDE */ |
10 | /* */ | 10 | /* */ |
11 | /* -------------------------------------------------------------------------- */ | 11 | /* -------------------------------------------------------------------------- */ |
12 | /* */ | 12 | /* */ |
13 | /* Ported Konsole to Qt/Embedded */ | 13 | /* Ported Qkonsole to Qt/Embedded */ |
14 | /* */ | 14 | /* */ |
15 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ | 15 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ |
16 | /* */ | 16 | /* */ |
17 | /* -------------------------------------------------------------------------- */ | 17 | /* -------------------------------------------------------------------------- */ |
18 | 18 | ||
19 | #include "TEHistory.h" | 19 | #include "TEHistory.h" |
20 | #include <stdlib.h> | 20 | #include <stdlib.h> |
21 | #include <assert.h> | 21 | #include <assert.h> |
22 | #include <stdio.h> | 22 | #include <stdio.h> |
23 | #include <sys/types.h> | 23 | #include <sys/types.h> |
24 | #include <unistd.h> | 24 | #include <unistd.h> |
25 | #include <errno.h> | 25 | #include <errno.h> |
26 | 26 | ||
27 | #include <qpe/config.h> | ||
28 | |||
27 | #define HERE printf("%s(%d): here\n",__FILE__,__LINE__) | 29 | #define HERE printf("%s(%d): here\n",__FILE__,__LINE__) |
28 | 30 | ||
29 | /* | 31 | /* |
30 | An arbitrary long scroll. | 32 | An arbitrary long scroll. |
31 | 33 | ||
32 | One can modify the scroll only by adding either cells | 34 | One can modify the scroll only by adding either cells |
33 | or newlines, but access it randomly. | 35 | or newlines, but access it randomly. |
34 | 36 | ||
35 | The model is that of an arbitrary wide typewriter scroll | 37 | The model is that of an arbitrary wide typewriter scroll |
36 | in that the scroll is a serie of lines and each line is | 38 | in that the scroll is a serie of lines and each line is |
37 | a serie of cells with no overwriting permitted. | 39 | a serie of cells with no overwriting permitted. |
38 | 40 | ||
39 | The implementation provides arbitrary length and numbers | 41 | The implementation provides arbitrary length and numbers |
40 | of cells and line/column indexed read access to the scroll | 42 | of cells and line/column indexed read access to the scroll |
41 | at constant costs. | 43 | at constant costs. |
42 | 44 | ||
43 | FIXME: some complain about the history buffer comsuming the | ||
44 | memory of their machines. This problem is critical | ||
45 | since the history does not behave gracefully in cases | ||
46 | where the memory is used up completely. | ||
47 | |||
48 | I put in a workaround that should handle it problem | ||
49 | now gracefully. I'm not satisfied with the solution. | ||
50 | |||
51 | FIXME: Terminating the history is not properly indicated | ||
52 | in the menu. We should throw a signal. | ||
53 | |||
54 | FIXME: There is noticable decrease in speed, also. Perhaps, | ||
55 | there whole feature needs to be revisited therefore. | ||
56 | Disadvantage of a more elaborated, say block-oriented | ||
57 | scheme with wrap around would be it's complexity. | ||
58 | */ | 45 | */ |
59 | 46 | ||
60 | //FIXME: tempory replacement for tmpfile | ||
61 | // this is here one for debugging purpose. | ||
62 | |||
63 | //#define tmpfile xTmpFile | ||
64 | |||
65 | FILE* xTmpFile() | ||
66 | { | ||
67 | static int fid = 0; | ||
68 | char fname[80]; | ||
69 | sprintf(fname,"TmpFile.%d",fid++); | ||
70 | return fopen(fname,"w"); | ||
71 | } | ||
72 | |||
73 | 47 | ||
74 | // History Buffer /////////////////////////////////////////// | 48 | HistoryScroll::HistoryScroll() |
75 | |||
76 | /* | ||
77 | A Row(X) data type which allows adding elements to the end. | ||
78 | */ | ||
79 | |||
80 | HistoryBuffer::HistoryBuffer() | ||
81 | { | 49 | { |
82 | ion = -1; | 50 | m_lines = NULL; |
83 | length = 0; | 51 | m_max_lines = 0; |
52 | m_cells = NULL; | ||
53 | m_max_cells = 0; | ||
54 | m_num_lines = 0; | ||
55 | m_first_line = 0; | ||
56 | m_last_cell = 0; | ||
57 | m_start_line = 0; | ||
84 | } | 58 | } |
85 | 59 | ||
86 | HistoryBuffer::~HistoryBuffer() | 60 | HistoryScroll::~HistoryScroll() |
87 | { | 61 | { |
88 | setScroll(FALSE); | 62 | setSize(0,0); |
89 | } | 63 | } |
90 | 64 | ||
91 | void HistoryBuffer::setScroll(bool on) | 65 | void HistoryScroll::setSize(int lines, int cells) |
92 | { | 66 | { |
93 | if (on == hasScroll()) return; | 67 | // could try to preserve the existing data... |
94 | 68 | // printf("setSize(%d,%d)\n", lines, cells); | |
95 | if (on) | 69 | if (m_lines) { |
96 | { | 70 | delete m_lines; |
97 | assert( ion < 0 ); | 71 | m_lines = NULL; |
98 | assert( length == 0); | ||
99 | FILE* tmp = tmpfile(); if (!tmp) { perror("konsole: cannot open temp file.\n"); return; } | ||
100 | ion = dup(fileno(tmp)); if (ion<0) perror("konsole: cannot dup temp file.\n"); | ||
101 | fclose(tmp); | ||
102 | } | 72 | } |
103 | else | 73 | if (m_cells) { |
104 | { | 74 | delete m_cells; |
105 | assert( ion >= 0 ); | 75 | m_cells = NULL; |
106 | close(ion); | ||
107 | ion = -1; | ||
108 | length = 0; | ||
109 | } | 76 | } |
77 | m_max_lines = m_max_cells = 0; | ||
78 | if (lines > 0 && cells > 0) { | ||
79 | m_max_lines = lines; | ||
80 | m_lines = new int[m_max_lines]; | ||
81 | m_lines[0] = 0; | ||
82 | m_max_cells = cells; | ||
83 | m_cells = new ca[m_max_cells]; | ||
84 | } | ||
85 | m_first_line = 0; | ||
86 | m_num_lines = 0; | ||
87 | m_last_cell = 0; | ||
88 | m_start_line = 0; | ||
110 | } | 89 | } |
111 | 90 | ||
112 | bool HistoryBuffer::hasScroll() | ||
113 | { | ||
114 | return ion >= 0; | ||
115 | } | ||
116 | |||
117 | void HistoryBuffer::add(const unsigned char* bytes, int len) | ||
118 | { int rc; | ||
119 | assert(hasScroll()); | ||
120 | rc = lseek( ion, length, SEEK_SET); | ||
121 | if (rc < 0) { perror("HistoryBuffer::add.seek"); setScroll(FALSE); return; } | ||
122 | rc = write( ion, bytes, len); | ||
123 | if (rc < 0) { perror("HistoryBuffer::add.write"); setScroll(FALSE); return; } | ||
124 | length += rc; | ||
125 | } | ||
126 | |||
127 | void HistoryBuffer::get(unsigned char* bytes, int len, int loc) { | ||
128 | int rc; | ||
129 | assert(hasScroll()); | ||
130 | // qDebug("history get len %d, loc %d, length %d", len, loc, length); | ||
131 | if (loc < 0 || len < 0 || loc + len > length) | ||
132 | fprintf(stderr,"getHist(...,%d,%d): invalid args.\n",len,loc); | ||
133 | |||
134 | rc = lseek( ion, loc, SEEK_SET); | ||
135 | if (rc < 0) { perror("HistoryBuffer::get.seek"); setScroll(FALSE); return; } | ||
136 | rc = read( ion, bytes, len); | ||
137 | if (rc < 0) { perror("HistoryBuffer::get.read"); setScroll(FALSE); return; } | ||
138 | } | ||
139 | |||
140 | int HistoryBuffer::len() | ||
141 | { | ||
142 | return length; | ||
143 | } | ||
144 | |||
145 | // History Scroll ////////////////////////////////////// | ||
146 | |||
147 | /* | ||
148 | The history scroll makes a Row(Row(Cell)) from | ||
149 | two history buffers. The index buffer contains | ||
150 | start of line positions which refere to the cells | ||
151 | buffer. | ||
152 | |||
153 | Note that index[0] addresses the second line | ||
154 | (line #1), while the first line (line #0) starts | ||
155 | at 0 in cells. | ||
156 | */ | ||
157 | |||
158 | HistoryScroll::HistoryScroll() | ||
159 | { | ||
160 | } | ||
161 | |||
162 | HistoryScroll::~HistoryScroll() | ||
163 | { | ||
164 | } | ||
165 | |||
166 | void HistoryScroll::setScroll(bool on) | 91 | void HistoryScroll::setScroll(bool on) |
167 | { | 92 | { |
168 | index.setScroll(on); | 93 | Config cfg("Qkonsole"); |
169 | cells.setScroll(on); | 94 | cfg.setGroup("History"); |
95 | // printf("setScroll(%d)\n", on); | ||
96 | if (on) { | ||
97 | int lines = cfg.readNumEntry("history_lines",300); | ||
98 | int avg_line = cfg.readNumEntry("avg_line_length",60); | ||
99 | int cells = lines * avg_line; | ||
100 | setSize(lines,cells); | ||
101 | } else { | ||
102 | setSize(0,0); | ||
103 | } | ||
170 | } | 104 | } |
171 | 105 | ||
172 | bool HistoryScroll::hasScroll() | 106 | bool HistoryScroll::hasScroll() |
173 | { | 107 | { |
174 | return index.hasScroll() && cells.hasScroll(); | 108 | return (m_max_lines > 0); |
175 | } | 109 | } |
176 | 110 | ||
177 | int HistoryScroll::getLines() | 111 | int HistoryScroll::getLines() |
178 | { | 112 | { |
179 | if (!hasScroll()) return 0; | 113 | return(m_num_lines); |
180 | return index.len() / sizeof(int); | ||
181 | } | 114 | } |
182 | 115 | ||
183 | int HistoryScroll::getLineLen(int lineno) | 116 | int HistoryScroll::getLineLen(int lineno) |
184 | { | 117 | { |
185 | if (!hasScroll()) return 0; | 118 | if (!hasScroll()) return 0; |
186 | return (startOfLine(lineno+1) - startOfLine(lineno)) / sizeof(ca); | 119 | if (lineno >= m_num_lines) { |
120 | // printf("getLineLen(%d) out of range %d\n", lineno, m_num_lines); | ||
121 | return(0); | ||
122 | } | ||
123 | int len = startOfLine(lineno+1) - startOfLine(lineno); | ||
124 | if (len < 0) { | ||
125 | len += m_max_cells; | ||
126 | } | ||
127 | // printf("getLineLen(%d) = %d\n", lineno, len); | ||
128 | return(len); | ||
187 | } | 129 | } |
188 | 130 | ||
189 | int HistoryScroll::startOfLine(int lineno) | 131 | int HistoryScroll::startOfLine(int lineno) |
190 | { | 132 | { |
191 | if (lineno <= 0) return 0; | 133 | // printf("startOfLine(%d) =", lineno); |
192 | if (!hasScroll()) return 0; | 134 | if (!hasScroll()) return 0; |
193 | if (lineno <= getLines()) | 135 | assert(lineno >= 0 && lineno <= m_num_lines); |
194 | { int res; | 136 | if (lineno < m_num_lines) { |
195 | index.get((unsigned char*)&res,sizeof(int),(lineno-1)*sizeof(int)); | 137 | int index = lineno + m_first_line; |
196 | return res; | 138 | if (index >= m_max_lines) |
139 | index -= m_max_lines; | ||
140 | // printf("%d\n", m_lines[index]); | ||
141 | return(m_lines[index]); | ||
142 | } else { | ||
143 | // printf("last %d\n", m_last_cell); | ||
144 | return(m_last_cell); | ||
197 | } | 145 | } |
198 | return cells.len(); | ||
199 | } | 146 | } |
200 | 147 | ||
201 | void HistoryScroll::getCells(int lineno, int colno, int count, ca res[]) | 148 | void HistoryScroll::getCells(int lineno, int colno, int count, ca *res) |
202 | { | 149 | { |
150 | // printf("getCells(%d,%d,%d) num_lines=%d\n", lineno, colno, count, m_num_lines); | ||
203 | assert(hasScroll()); | 151 | assert(hasScroll()); |
204 | //get(unsigned char* bytes, int len, int loc) | 152 | assert(lineno >= 0 && lineno < m_num_lines); |
205 | cells.get( (unsigned char*)res, count * sizeof(ca), startOfLine( lineno) + colno * sizeof(ca) ); | 153 | int index = lineno + m_first_line; |
154 | if (index >= m_max_lines) | ||
155 | index -= m_max_lines; | ||
156 | assert(index >= 0 && index < m_max_lines); | ||
157 | index = m_lines[index] + colno; | ||
158 | assert(index >= 0 && index < m_max_cells); | ||
159 | while(count-- > 0) { | ||
160 | *res++ = m_cells[index]; | ||
161 | if (++index >= m_max_cells) { | ||
162 | index = 0; | ||
163 | } | ||
164 | } | ||
206 | } | 165 | } |
207 | 166 | ||
208 | void HistoryScroll::addCells(ca text[], int count) | 167 | void HistoryScroll::addCells(ca *text, int count) |
209 | { | 168 | { |
210 | if (!hasScroll()) return; | 169 | if (!hasScroll()) return; |
211 | cells.add((unsigned char*)text,count*sizeof(ca)); | 170 | int start_cell = m_last_cell; |
171 | // printf("addCells count=%d start=%d first_line=%d first_cell=%d lines=%d\n", | ||
172 | // count, start_cell, m_first_line, m_lines[m_first_line], m_num_lines); | ||
173 | if (count <= 0) { | ||
174 | return; | ||
175 | } | ||
176 | while(count-- > 0) { | ||
177 | assert (m_last_cell >= 0 && m_last_cell < m_max_cells ); | ||
178 | m_cells[m_last_cell] = *text++; | ||
179 | if (++m_last_cell >= m_max_cells) { | ||
180 | m_last_cell = 0; | ||
181 | } | ||
182 | } | ||
183 | if (m_num_lines > 1) { | ||
184 | if (m_last_cell > start_cell) { | ||
185 | while(m_num_lines > 0 | ||
186 | && m_lines[m_first_line] >= start_cell | ||
187 | && m_lines[m_first_line] < m_last_cell) { | ||
188 | // printf("A remove %d>%d && %d<%d first_line=%d num_lines=%d\n", | ||
189 | // m_lines[m_first_line], start_cell, m_lines[m_first_line], m_last_cell, | ||
190 | // m_first_line, m_num_lines); | ||
191 | if (++m_first_line >= m_max_lines) { | ||
192 | m_first_line = 0; | ||
193 | } | ||
194 | m_num_lines--; | ||
195 | } | ||
196 | } else { | ||
197 | while(m_num_lines > 0 | ||
198 | && (m_lines[m_first_line] >= start_cell | ||
199 | || m_lines[m_first_line] < m_last_cell)) { | ||
200 | // printf("B remove %d>%d || %d<%d first_line=%d num_lines=%d\n", | ||
201 | // m_lines[m_first_line], start_cell, m_lines[m_first_line], m_last_cell, | ||
202 | // m_first_line, m_num_lines); | ||
203 | if (++m_first_line >= m_max_lines) { | ||
204 | m_first_line = 0; | ||
205 | } | ||
206 | m_num_lines--; | ||
207 | } | ||
208 | } | ||
209 | } | ||
212 | } | 210 | } |
213 | 211 | ||
214 | void HistoryScroll::addLine() | 212 | void HistoryScroll::addLine() |
215 | { | 213 | { |
216 | if (!hasScroll()) return; | 214 | if (!hasScroll()) return; |
217 | int locn = cells.len(); | 215 | int index = m_first_line + m_num_lines; |
218 | index.add((unsigned char*)&locn,sizeof(int)); | 216 | if (index >= m_max_lines) { |
217 | index -= m_max_lines; | ||
218 | } | ||
219 | // printf("addLine line=%d cell=%d\n", index, m_last_cell); | ||
220 | assert(index >= 0 && index < m_max_lines); | ||
221 | m_lines[index] = m_start_line; | ||
222 | m_start_line = m_last_cell; | ||
223 | if (m_num_lines >= m_max_lines) { | ||
224 | if (++m_first_line >= m_num_lines) { | ||
225 | m_first_line = 0; | ||
226 | } | ||
227 | } else { | ||
228 | m_num_lines++; | ||
229 | } | ||
219 | } | 230 | } |
diff --git a/core/apps/embeddedkonsole/TEHistory.h b/core/apps/embeddedkonsole/TEHistory.h index 11eb150..fcf6496 100644 --- a/core/apps/embeddedkonsole/TEHistory.h +++ b/core/apps/embeddedkonsole/TEHistory.h | |||
@@ -16,60 +16,42 @@ | |||
16 | /* */ | 16 | /* */ |
17 | /* -------------------------------------------------------------------------- */ | 17 | /* -------------------------------------------------------------------------- */ |
18 | 18 | ||
19 | #ifndef TEHISTORY_H | 19 | #ifndef TEHISTORY_H |
20 | #define TEHISTORY_H | 20 | #define TEHISTORY_H |
21 | 21 | ||
22 | #include "TECommon.h" | 22 | #include "TECommon.h" |
23 | 23 | ||
24 | /* | ||
25 | An extendable tmpfile(1) based buffer. | ||
26 | */ | ||
27 | class HistoryBuffer | ||
28 | { | ||
29 | public: | ||
30 | HistoryBuffer(); | ||
31 | ~HistoryBuffer(); | ||
32 | |||
33 | public: | ||
34 | void setScroll(bool on); | ||
35 | bool hasScroll(); | ||
36 | |||
37 | public: | ||
38 | void add(const unsigned char* bytes, int len); | ||
39 | void get(unsigned char* bytes, int len, int loc); | ||
40 | int len(); | ||
41 | |||
42 | private: | ||
43 | int ion; | ||
44 | int length; | ||
45 | }; | ||
46 | |||
47 | class HistoryScroll | 24 | class HistoryScroll |
48 | { | 25 | { |
49 | public: | 26 | public: |
50 | HistoryScroll(); | 27 | HistoryScroll(); |
51 | ~HistoryScroll(); | 28 | ~HistoryScroll(); |
52 | 29 | ||
53 | public: | 30 | public: |
54 | void setScroll(bool on); | 31 | void setSize(int lines, int cells); |
55 | bool hasScroll(); | 32 | void setScroll(bool on); |
33 | bool hasScroll(); | ||
56 | 34 | ||
57 | public: // access to history | 35 | int getLines(); |
58 | int getLines(); | 36 | int getLineLen(int lineno); |
59 | int getLineLen(int lineno); | 37 | void getCells(int lineno, int colno, int count, ca *res); |
60 | void getCells(int lineno, int colno, int count, ca res[]); | ||
61 | 38 | ||
62 | public: // backward compatibility (obsolete) | ||
63 | ca getCell(int lineno, int colno) { ca res; getCells(lineno,colno,1,&res); return res; } | 39 | ca getCell(int lineno, int colno) { ca res; getCells(lineno,colno,1,&res); return res; } |
64 | 40 | ||
65 | public: // adding lines. | 41 | void addCells(ca *text, int count); |
66 | void addCells(ca a[], int count); | ||
67 | void addLine(); | 42 | void addLine(); |
68 | 43 | ||
69 | private: | 44 | private: |
70 | int startOfLine(int lineno); | 45 | int startOfLine(int lineno); |
71 | HistoryBuffer index; // lines Row(int) | 46 | |
72 | HistoryBuffer cells; // text Row(ca) | 47 | int m_max_lines; |
48 | int *m_lines; | ||
49 | int m_max_cells; | ||
50 | ca *m_cells; | ||
51 | int m_first_line; | ||
52 | int m_last_cell; | ||
53 | int m_num_lines; | ||
54 | int m_start_line; | ||
73 | }; | 55 | }; |
74 | 56 | ||
75 | #endif // TEHISTORY_H | 57 | #endif // TEHISTORY_H |
diff --git a/core/apps/embeddedkonsole/TEScreen.cpp b/core/apps/embeddedkonsole/TEScreen.cpp index a6cf6a1..4ebc28e 100644 --- a/core/apps/embeddedkonsole/TEScreen.cpp +++ b/core/apps/embeddedkonsole/TEScreen.cpp | |||
@@ -505,16 +505,20 @@ void TEScreen::effectiveRendition() | |||
505 | */ | 505 | */ |
506 | 506 | ||
507 | ca* TEScreen::getCookedImage() | 507 | ca* TEScreen::getCookedImage() |
508 | { | 508 | { |
509 | int x,y; | 509 | int x,y; |
510 | ca* merged = (ca*)malloc(lines*columns*sizeof(ca)); | 510 | ca* merged = (ca*)malloc(lines*columns*sizeof(ca)); |
511 | ca dft(' ',DEFAULT_FORE_COLOR,DEFAULT_BACK_COLOR,DEFAULT_RENDITION); | 511 | ca dft(' ',DEFAULT_FORE_COLOR,DEFAULT_BACK_COLOR,DEFAULT_RENDITION); |
512 | 512 | ||
513 | if (histCursor > hist.getLines()) { | ||
514 | histCursor = hist.getLines(); | ||
515 | } | ||
516 | |||
513 | for (y = 0; (y < lines) && (y < (hist.getLines()-histCursor)); y++) | 517 | for (y = 0; (y < lines) && (y < (hist.getLines()-histCursor)); y++) |
514 | { | 518 | { |
515 | int len = QMIN(columns,hist.getLineLen(y+histCursor)); | 519 | int len = QMIN(columns,hist.getLineLen(y+histCursor)); |
516 | int yp = y*columns; | 520 | int yp = y*columns; |
517 | int yq = (y+histCursor)*columns; | 521 | int yq = (y+histCursor)*columns; |
518 | 522 | ||
519 | hist.getCells(y+histCursor,0,len,merged+yp); | 523 | hist.getCells(y+histCursor,0,len,merged+yp); |
520 | for (x = len; x < columns; x++) merged[yp+x] = dft; | 524 | for (x = len; x < columns; x++) merged[yp+x] = dft; |
@@ -553,17 +557,17 @@ ca* TEScreen::getCookedImage() | |||
553 | } | 557 | } |
554 | 558 | ||
555 | 559 | ||
556 | /*! | 560 | /*! |
557 | */ | 561 | */ |
558 | 562 | ||
559 | void TEScreen::reset() | 563 | void TEScreen::reset() |
560 | { | 564 | { |
561 | Config cfg("Konsole"); | 565 | Config cfg("Qkonsole"); |
562 | cfg.setGroup("ScrollBar"); | 566 | cfg.setGroup("ScrollBar"); |
563 | if( !cfg.readBoolEntry("HorzScroll",0) ) | 567 | if( !cfg.readBoolEntry("HorzScroll",0) ) |
564 | setMode(MODE_Wrap ); saveMode(MODE_Wrap ); // wrap at end of margin | 568 | setMode(MODE_Wrap ); saveMode(MODE_Wrap ); // wrap at end of margin |
565 | 569 | ||
566 | 570 | ||
567 | resetMode(MODE_Origin); saveMode(MODE_Origin); // position refere to [1,1] | 571 | resetMode(MODE_Origin); saveMode(MODE_Origin); // position refere to [1,1] |
568 | resetMode(MODE_Insert); saveMode(MODE_Insert); // overstroke | 572 | resetMode(MODE_Insert); saveMode(MODE_Insert); // overstroke |
569 | setMode(MODE_Cursor); // cursor visible | 573 | setMode(MODE_Cursor); // cursor visible |
@@ -966,24 +970,30 @@ void TEScreen::clearSelection() | |||
966 | { | 970 | { |
967 | sel_BR = -1; | 971 | sel_BR = -1; |
968 | sel_TL = -1; | 972 | sel_TL = -1; |
969 | sel_begin = -1; | 973 | sel_begin = -1; |
970 | } | 974 | } |
971 | 975 | ||
972 | void TEScreen::setSelBeginXY(const int x, const int y) | 976 | void TEScreen::setSelBeginXY(const int x, const int y) |
973 | { | 977 | { |
978 | if (histCursor > hist.getLines()) { | ||
979 | histCursor = hist.getLines(); | ||
980 | } | ||
974 | sel_begin = loc(x,y+histCursor) ; | 981 | sel_begin = loc(x,y+histCursor) ; |
975 | sel_BR = sel_begin; | 982 | sel_BR = sel_begin; |
976 | sel_TL = sel_begin; | 983 | sel_TL = sel_begin; |
977 | } | 984 | } |
978 | 985 | ||
979 | void TEScreen::setSelExtentXY(const int x, const int y) | 986 | void TEScreen::setSelExtentXY(const int x, const int y) |
980 | { | 987 | { |
981 | if (sel_begin == -1) return; | 988 | if (sel_begin == -1) return; |
989 | if (histCursor > hist.getLines()) { | ||
990 | histCursor = hist.getLines(); | ||
991 | } | ||
982 | int l = loc(x,y + histCursor); | 992 | int l = loc(x,y + histCursor); |
983 | 993 | ||
984 | if (l < sel_begin) | 994 | if (l < sel_begin) |
985 | { | 995 | { |
986 | sel_TL = l; | 996 | sel_TL = l; |
987 | sel_BR = sel_begin; | 997 | sel_BR = sel_begin; |
988 | } | 998 | } |
989 | else | 999 | else |
@@ -1180,16 +1190,22 @@ void TEScreen::addHistLine() | |||
1180 | } | 1190 | } |
1181 | 1191 | ||
1182 | if (!hasScroll()) histCursor = 0; //FIXME: a poor workaround | 1192 | if (!hasScroll()) histCursor = 0; //FIXME: a poor workaround |
1183 | } | 1193 | } |
1184 | 1194 | ||
1185 | void TEScreen::setHistCursor(int cursor) | 1195 | void TEScreen::setHistCursor(int cursor) |
1186 | { | 1196 | { |
1187 | histCursor = cursor; //FIXME:rangecheck | 1197 | histCursor = cursor; //FIXME:rangecheck |
1198 | if (histCursor > hist.getLines()) { | ||
1199 | histCursor = hist.getLines(); | ||
1200 | } | ||
1201 | if (histCursor < 0) { | ||
1202 | histCursor = 0; | ||
1203 | } | ||
1188 | } | 1204 | } |
1189 | 1205 | ||
1190 | void TEScreen::setHorzCursor(int cursor) | 1206 | void TEScreen::setHorzCursor(int cursor) |
1191 | { | 1207 | { |
1192 | horzCursor = cursor; | 1208 | horzCursor = cursor; |
1193 | } | 1209 | } |
1194 | 1210 | ||
1195 | int TEScreen::getHistCursor() | 1211 | int TEScreen::getHistCursor() |
diff --git a/core/apps/embeddedkonsole/TEWidget.cpp b/core/apps/embeddedkonsole/TEWidget.cpp index ec1b30c..98c3cdf 100644 --- a/core/apps/embeddedkonsole/TEWidget.cpp +++ b/core/apps/embeddedkonsole/TEWidget.cpp | |||
@@ -61,16 +61,17 @@ | |||
61 | 61 | ||
62 | #include <qcursor.h> | 62 | #include <qcursor.h> |
63 | #include <qregexp.h> | 63 | #include <qregexp.h> |
64 | #include <qpainter.h> | 64 | #include <qpainter.h> |
65 | #include <qclipboard.h> | 65 | #include <qclipboard.h> |
66 | #include <qstyle.h> | 66 | #include <qstyle.h> |
67 | #include <qfile.h> | 67 | #include <qfile.h> |
68 | #include <qdragobject.h> | 68 | #include <qdragobject.h> |
69 | #include <qnamespace.h> | ||
69 | 70 | ||
70 | #include <stdio.h> | 71 | #include <stdio.h> |
71 | #include <stdlib.h> | 72 | #include <stdlib.h> |
72 | #include <unistd.h> | 73 | #include <unistd.h> |
73 | #include <ctype.h> | 74 | #include <ctype.h> |
74 | #include <sys/stat.h> | 75 | #include <sys/stat.h> |
75 | #include <sys/types.h> | 76 | #include <sys/types.h> |
76 | #include <signal.h> | 77 | #include <signal.h> |
@@ -239,33 +240,27 @@ static QChar identicalMap(QChar c) | |||
239 | { | 240 | { |
240 | return c; | 241 | return c; |
241 | } | 242 | } |
242 | 243 | ||
243 | void TEWidget::fontChange(const QFont &) | 244 | void TEWidget::fontChange(const QFont &) |
244 | { | 245 | { |
245 | QFontMetrics fm(font()); | 246 | QFontMetrics fm(font()); |
246 | font_h = fm.height(); | 247 | font_h = fm.height(); |
247 | 248 | // font_w = fm.maxWidth(); | |
248 | // font_w = max width of ASCII chars (U.B.) | 249 | font_w = fm.width("m"); |
249 | font_w = 0; | 250 | font_a = fm.ascent(); |
250 | int fw; | 251 | printf("font h=%d max_width=%d width_m=%d assent=%d\n", font_h, |
251 | for (int i = 0x20; i < 0x80; i++) { | 252 | fm.maxWidth(), font_w, font_a); |
252 | if (isprint(i) && font_w < (fw = fm.width(i))) { | 253 | |
253 | font_w = fw; | 254 | //printf("font_h: %d\n",font_h); |
254 | } | 255 | //printf("font_w: %d\n",font_w); |
255 | } | 256 | //printf("font_a: %d\n",font_a); |
256 | //font_w = fm.maxWidth(); | 257 | //printf("charset: %s\n",QFont::encodingName(font().charSet()).ascii()); |
257 | 258 | //printf("rawname: %s\n",font().rawName().ascii()); | |
258 | font_a = fm.ascent(); | ||
259 | //printf("font_h: %d\n",font_h); | ||
260 | //printf("font_w: %d\n",font_w); | ||
261 | //printf("font_a: %d\n",font_a); | ||
262 | //printf("charset: %s\n",QFont::encodingName(font().charSet()).ascii()); | ||
263 | //printf("rawname: %s\n",font().rawName().ascii()); | ||
264 | fontMap = | 259 | fontMap = |
265 | #if QT_VERSION < 300 | 260 | #if QT_VERSION < 300 |
266 | strcmp(QFont::encodingName(font().charSet()).ascii(),"iso10646") | 261 | strcmp(QFont::encodingName(font().charSet()).ascii(),"iso10646") |
267 | ? vt100extended | 262 | ? vt100extended |
268 | : | 263 | : |
269 | #endif | 264 | #endif |
270 | identicalMap; | 265 | identicalMap; |
271 | propagateSize(); | 266 | propagateSize(); |
@@ -302,21 +297,21 @@ TEWidget::TEWidget(QWidget *parent, const char *name) : QFrame(parent,name) | |||
302 | 297 | ||
303 | scrollbar = new QScrollBar(this); | 298 | scrollbar = new QScrollBar(this); |
304 | scrollbar->setCursor( arrowCursor ); | 299 | scrollbar->setCursor( arrowCursor ); |
305 | connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); | 300 | connect(scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollChanged(int))); |
306 | 301 | ||
307 | hScrollbar = new QScrollBar(this); | 302 | hScrollbar = new QScrollBar(this); |
308 | hScrollbar->setCursor( arrowCursor ); | 303 | hScrollbar->setCursor( arrowCursor ); |
309 | hScrollbar->setOrientation(QScrollBar::Horizontal); | 304 | hScrollbar->setOrientation(QScrollBar::Horizontal); |
310 | hScrollbar->setMaximumHeight(16); | 305 | // hScrollbar->setMaximumHeight(16); |
311 | 306 | ||
312 | connect( hScrollbar, SIGNAL(valueChanged(int)), this, SLOT( hScrollChanged(int))); | 307 | connect( hScrollbar, SIGNAL(valueChanged(int)), this, SLOT( hScrollChanged(int))); |
313 | 308 | ||
314 | Config cfg("Konsole"); | 309 | Config cfg("Qkonsole"); |
315 | cfg.setGroup("ScrollBar"); | 310 | cfg.setGroup("ScrollBar"); |
316 | switch( cfg.readNumEntry("Position",2)){ | 311 | switch( cfg.readNumEntry("Position",2)){ |
317 | case 0: | 312 | case 0: |
318 | scrollLoc = SCRNONE; | 313 | scrollLoc = SCRNONE; |
319 | break; | 314 | break; |
320 | case 1: | 315 | case 1: |
321 | scrollLoc = SCRLEFT; | 316 | scrollLoc = SCRLEFT; |
322 | break; | 317 | break; |
@@ -679,23 +674,26 @@ void TEWidget::setScrollbarLocation(int loc) | |||
679 | void TEWidget::mousePressEvent(QMouseEvent* ev) | 674 | void TEWidget::mousePressEvent(QMouseEvent* ev) |
680 | { | 675 | { |
681 | //printf("press [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); | 676 | //printf("press [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); |
682 | if ( !contentsRect().contains(ev->pos()) ) return; | 677 | if ( !contentsRect().contains(ev->pos()) ) return; |
683 | QPoint tL = contentsRect().topLeft(); | 678 | QPoint tL = contentsRect().topLeft(); |
684 | int tLx = tL.x(); | 679 | int tLx = tL.x(); |
685 | int tLy = tL.y(); | 680 | int tLy = tL.y(); |
686 | 681 | ||
687 | word_selection_mode = FALSE; | 682 | mouse_down_x = ev->x(); |
683 | mouse_down_y = ev->y(); | ||
688 | 684 | ||
689 | //printf("press top left [%d,%d] by=%d\n",tLx,tLy, bY); | 685 | //printf("press top left [%d,%d] by=%d\n",tLx,tLy, bY); |
690 | if ( ev->button() == LeftButton) | 686 | if ( ev->button() == LeftButton) |
691 | { | 687 | { |
692 | QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); | 688 | QPoint pos = QPoint((ev->x()-tLx-blX)/font_w,(ev->y()-tLy-bY)/font_h); |
693 | 689 | ||
690 | word_selection_mode = (ev->state() & ShiftButton); | ||
691 | |||
694 | if ( ev->state() & ControlButton ) preserve_line_breaks = FALSE ; | 692 | if ( ev->state() & ControlButton ) preserve_line_breaks = FALSE ; |
695 | 693 | ||
696 | if (mouse_marks || (ev->state() & ShiftButton)) | 694 | if (mouse_marks || (ev->state() & ShiftButton)) |
697 | { | 695 | { |
698 | emit clearSelectionSignal(); | 696 | emit clearSelectionSignal(); |
699 | iPntSel = pntSel = pos; | 697 | iPntSel = pntSel = pos; |
700 | actSel = 1; // left mouse button pressed but nothing selected yet. | 698 | actSel = 1; // left mouse button pressed but nothing selected yet. |
701 | grabMouse( /*crossCursor*/ ); // handle with care! | 699 | grabMouse( /*crossCursor*/ ); // handle with care! |
@@ -810,16 +808,22 @@ void TEWidget::mouseMoveEvent(QMouseEvent* ev) | |||
810 | emit extendSelectionSignal( here.x(), here.y() ); | 808 | emit extendSelectionSignal( here.x(), here.y() ); |
811 | } | 809 | } |
812 | 810 | ||
813 | void TEWidget::mouseReleaseEvent(QMouseEvent* ev) | 811 | void TEWidget::mouseReleaseEvent(QMouseEvent* ev) |
814 | { | 812 | { |
815 | //printf("release [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); | 813 | //printf("release [%d,%d] %d\n",ev->x()/font_w,ev->y()/font_h,ev->button()); |
816 | if ( ev->button() == LeftButton) | 814 | if ( ev->button() == LeftButton) |
817 | { | 815 | { |
816 | if (QABS(ev->x() - mouse_down_x) < 3 | ||
817 | && QABS(ev->y() - mouse_down_y) < 3 | ||
818 | && ev->y() < qApp->desktop()->height()/8) { | ||
819 | emit setFullScreen(false); | ||
820 | } | ||
821 | |||
818 | if ( actSel > 1 ) emit endSelectionSignal(preserve_line_breaks); | 822 | if ( actSel > 1 ) emit endSelectionSignal(preserve_line_breaks); |
819 | preserve_line_breaks = TRUE; | 823 | preserve_line_breaks = TRUE; |
820 | actSel = 0; | 824 | actSel = 0; |
821 | 825 | ||
822 | //FIXME: emits a release event even if the mouse is | 826 | //FIXME: emits a release event even if the mouse is |
823 | // outside the range. The procedure used in `mouseMoveEvent' | 827 | // outside the range. The procedure used in `mouseMoveEvent' |
824 | // applies here, too. | 828 | // applies here, too. |
825 | 829 | ||
@@ -1025,17 +1029,16 @@ bool TEWidget::eventFilter( QObject *obj, QEvent *e ) | |||
1025 | QApplication::sendEvent(scrollbar, e); | 1029 | QApplication::sendEvent(scrollbar, e); |
1026 | } | 1030 | } |
1027 | 1031 | ||
1028 | #ifdef FAKE_CTRL_AND_ALT | 1032 | #ifdef FAKE_CTRL_AND_ALT |
1029 | static bool control = FALSE; | 1033 | static bool control = FALSE; |
1030 | static bool alt = FALSE; | 1034 | static bool alt = FALSE; |
1031 | // qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:"); | 1035 | // qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:"); |
1032 | bool dele=FALSE; | 1036 | bool dele=FALSE; |
1033 | |||
1034 | if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { | 1037 | if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { |
1035 | QKeyEvent* ke = (QKeyEvent*)e; | 1038 | QKeyEvent* ke = (QKeyEvent*)e; |
1036 | bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); | 1039 | bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); |
1037 | switch (ke->key()) { | 1040 | switch (ke->key()) { |
1038 | case Key_F9: // let this be "Control" | 1041 | case Key_F9: // let this be "Control" |
1039 | control = keydown; | 1042 | control = keydown; |
1040 | e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); | 1043 | e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); |
1041 | dele=TRUE; | 1044 | dele=TRUE; |
@@ -1064,35 +1067,93 @@ bool TEWidget::eventFilter( QObject *obj, QEvent *e ) | |||
1064 | #endif | 1067 | #endif |
1065 | 1068 | ||
1066 | if ( e->type() == QEvent::KeyPress ) { | 1069 | if ( e->type() == QEvent::KeyPress ) { |
1067 | QKeyEvent* ke = (QKeyEvent*)e; | 1070 | QKeyEvent* ke = (QKeyEvent*)e; |
1068 | actSel=0; // Key stroke implies a screen update, so TEWidget won't | 1071 | actSel=0; // Key stroke implies a screen update, so TEWidget won't |
1069 | // know where the current selection is. | 1072 | // know where the current selection is. |
1070 | 1073 | ||
1071 | // qDebug("key pressed is 0x%x, ascii is 0x%x, state %d", ke->key(), ke->ascii(), ke->state()); | 1074 | // qDebug("key pressed is 0x%x, ascii is 0x%x, state %d", ke->key(), ke->ascii(), ke->state()); |
1072 | if(ke->key() == Key_Escape) { | 1075 | |
1073 | qDebug("key pressed is 0x%x, ascii is 0x%x, state %d", ke->key(), ke->ascii(), ke->state()); | 1076 | bool special_function = true; |
1074 | 1077 | switch(ke->key()) { | |
1075 | } | 1078 | //case 0x201b: // fn-5 |
1076 | 1079 | //case Key_F1: | |
1077 | if( ke->state() == ShiftButton && ke->key() == Key_Tab) { | 1080 | // switch sessions (?) |
1078 | //lets hardcode this sucker | 1081 | // emitText("\\"); // expose (??) |
1079 | 1082 | // break; | |
1080 | // qDebug("key pressed 2 is 0x%x", ke->key()); | 1083 | |
1081 | emitText("\\"); // expose | 1084 | case 0x2016: // fn-p |
1082 | } | 1085 | case Key_F2: |
1083 | else if( ke->state() == ControlButton && ke->key() == Key_V) { | 1086 | pasteClipboard(); |
1084 | pasteClipboard(); | 1087 | break; |
1085 | } | 1088 | |
1086 | // else if( ke->state() == ControlButton && ke->key() == Key_C) { | 1089 | case 0x2018: // fn-S |
1087 | // pasteClipboard(); | 1090 | case Key_F3: |
1088 | // } | 1091 | emit changeSession(1); |
1089 | else | 1092 | break; |
1090 | emit keyPressedSignal(ke); // expose | 1093 | |
1094 | case 0x2019: // fn-n | ||
1095 | emit newSession(); | ||
1096 | break; | ||
1097 | |||
1098 | case Qt::Key_Tab: | ||
1099 | if (ke->state() == ControlButton) { | ||
1100 | emit changeSession(1); | ||
1101 | } else { | ||
1102 | special_function = false; | ||
1103 | } | ||
1104 | break; | ||
1105 | |||
1106 | #if 0 | ||
1107 | case Qt::Key_Left: | ||
1108 | if (vcolumns == 0) { | ||
1109 | emit changeSession(-1); | ||
1110 | } else { | ||
1111 | special_function = false; | ||
1112 | } | ||
1113 | break; | ||
1114 | |||
1115 | case Qt::Key_Right: | ||
1116 | if (vcolumns == 0) { | ||
1117 | emit changeSession(1); | ||
1118 | } else { | ||
1119 | special_function = false; | ||
1120 | } | ||
1121 | break; | ||
1122 | #endif | ||
1123 | |||
1124 | case 0x201b: // fn-5 | ||
1125 | case Key_F4: | ||
1126 | emit toggleFullScreen(); | ||
1127 | break; | ||
1128 | |||
1129 | case 0x200f: // fn-1 magnify minus | ||
1130 | case Key_F5: | ||
1131 | emit changeFontSize(-1); | ||
1132 | break; | ||
1133 | |||
1134 | case 0x2010: // fn-2 magnify plus | ||
1135 | case Key_F6: | ||
1136 | emit changeFontSize(1); | ||
1137 | break; | ||
1138 | |||
1139 | default: | ||
1140 | special_function = false; | ||
1141 | } | ||
1142 | if (special_function) { | ||
1143 | return true; | ||
1144 | } | ||
1145 | // else if( ke->state() == ControlButton && ke->key() == Key_V) { | ||
1146 | // pasteClipboard(); | ||
1147 | // } | ||
1148 | // else if( ke->state() == ControlButton && ke->key() == Key_C) { | ||
1149 | // pasteClipboard(); | ||
1150 | // } | ||
1151 | emit keyPressedSignal(ke); // expose | ||
1091 | ke->accept(); | 1152 | ke->accept(); |
1092 | #ifdef FAKE_CTRL_AND_ALT | 1153 | #ifdef FAKE_CTRL_AND_ALT |
1093 | if ( dele ) delete e; | 1154 | if ( dele ) delete e; |
1094 | #endif | 1155 | #endif |
1095 | return true; // stop the event | 1156 | return true; // stop the event |
1096 | } | 1157 | } |
1097 | if ( e->type() == QEvent::Enter ) { | 1158 | if ( e->type() == QEvent::Enter ) { |
1098 | QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()), | 1159 | QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()), |
@@ -1111,17 +1172,16 @@ bool TEWidget::eventFilter( QObject *obj, QEvent *e ) | |||
1111 | /* */ | 1172 | /* */ |
1112 | /* ------------------------------------------------------------------------- */ | 1173 | /* ------------------------------------------------------------------------- */ |
1113 | 1174 | ||
1114 | void TEWidget::frameChanged() | 1175 | void TEWidget::frameChanged() |
1115 | { | 1176 | { |
1116 | propagateSize(); | 1177 | propagateSize(); |
1117 | update(); | 1178 | update(); |
1118 | } | 1179 | } |
1119 | |||
1120 | /* ------------------------------------------------------------------------- */ | 1180 | /* ------------------------------------------------------------------------- */ |
1121 | /* */ | 1181 | /* */ |
1122 | /* Sound */ | 1182 | /* Sound */ |
1123 | /* */ | 1183 | /* */ |
1124 | /* ------------------------------------------------------------------------- */ | 1184 | /* ------------------------------------------------------------------------- */ |
1125 | 1185 | ||
1126 | void TEWidget::Bell() | 1186 | void TEWidget::Bell() |
1127 | { | 1187 | { |
@@ -1162,17 +1222,17 @@ void TEWidget::clearImage() | |||
1162 | 1222 | ||
1163 | // Create Image /////////////////////////////////////////////////////// | 1223 | // Create Image /////////////////////////////////////////////////////// |
1164 | 1224 | ||
1165 | void TEWidget::calcGeometry() | 1225 | void TEWidget::calcGeometry() |
1166 | { | 1226 | { |
1167 | int showhscrollbar = 1; | 1227 | int showhscrollbar = 1; |
1168 | int hwidth = 0; | 1228 | int hwidth = 0; |
1169 | int dcolumns; | 1229 | int dcolumns; |
1170 | Config cfg("Konsole"); | 1230 | Config cfg("Qkonsole"); |
1171 | cfg.setGroup("ScrollBar"); | 1231 | cfg.setGroup("ScrollBar"); |
1172 | useHorzScroll=cfg.readBoolEntry("HorzScroll",0); | 1232 | useHorzScroll=cfg.readBoolEntry("HorzScroll",0); |
1173 | 1233 | ||
1174 | if(vcolumns == 0) showhscrollbar = 0; | 1234 | if(vcolumns == 0) showhscrollbar = 0; |
1175 | if(showhscrollbar == 1) hwidth = QApplication::style().scrollBarExtent().width(); | 1235 | if(showhscrollbar == 1) hwidth = QApplication::style().scrollBarExtent().width(); |
1176 | 1236 | ||
1177 | scrollbar->resize(QApplication::style().scrollBarExtent().width(), | 1237 | scrollbar->resize(QApplication::style().scrollBarExtent().width(), |
1178 | contentsRect().height() - hwidth); | 1238 | contentsRect().height() - hwidth); |
@@ -1363,11 +1423,11 @@ void TEWidget::drop_menu_activated(int item) | |||
1363 | break; | 1423 | break; |
1364 | } | 1424 | } |
1365 | #endif | 1425 | #endif |
1366 | } | 1426 | } |
1367 | 1427 | ||
1368 | void TEWidget::setWrapAt(int columns) | 1428 | void TEWidget::setWrapAt(int columns) |
1369 | { | 1429 | { |
1370 | vcolumns = columns; | 1430 | vcolumns = columns; |
1371 | propagateSize(); | 1431 | propagateSize(); |
1372 | update(); | 1432 | update(); |
1373 | } | 1433 | } |
diff --git a/core/apps/embeddedkonsole/TEWidget.h b/core/apps/embeddedkonsole/TEWidget.h index 5597f27..792b109 100644 --- a/core/apps/embeddedkonsole/TEWidget.h +++ b/core/apps/embeddedkonsole/TEWidget.h | |||
@@ -32,17 +32,18 @@ | |||
32 | extern unsigned short vt100_graphics[32]; | 32 | extern unsigned short vt100_graphics[32]; |
33 | 33 | ||
34 | class TESession; | 34 | class TESession; |
35 | 35 | ||
36 | // class Konsole; | 36 | // class Konsole; |
37 | 37 | ||
38 | class TEWidget : public QFrame | 38 | class TEWidget : public QFrame |
39 | // a widget representing attributed text | 39 | // a widget representing attributed text |
40 | { Q_OBJECT | 40 | { |
41 | Q_OBJECT | ||
41 | 42 | ||
42 | // friend class Konsole; | 43 | // friend class Konsole; |
43 | 44 | ||
44 | public: | 45 | public: |
45 | 46 | ||
46 | TEWidget(QWidget *parent=0, const char *name=0); | 47 | TEWidget(QWidget *parent=0, const char *name=0); |
47 | virtual ~TEWidget(); | 48 | virtual ~TEWidget(); |
48 | 49 | ||
@@ -69,16 +70,17 @@ public: | |||
69 | void calcGeometry(); | 70 | void calcGeometry(); |
70 | void propagateSize(); | 71 | void propagateSize(); |
71 | QSize calcSize(int cols, int lins) const; | 72 | QSize calcSize(int cols, int lins) const; |
72 | 73 | ||
73 | QSize sizeHint() const; | 74 | QSize sizeHint() const; |
74 | 75 | ||
75 | bool useHorzScroll; | 76 | bool useHorzScroll; |
76 | bool useBeep; | 77 | bool useBeep; |
78 | int color_menu_item; | ||
77 | 79 | ||
78 | void Bell(); | 80 | void Bell(); |
79 | void emitText(QString text); | 81 | void emitText(QString text); |
80 | void pasteClipboard(); | 82 | void pasteClipboard(); |
81 | 83 | ||
82 | signals: | 84 | signals: |
83 | 85 | ||
84 | void keyPressedSignal(QKeyEvent *e); | 86 | void keyPressedSignal(QKeyEvent *e); |
@@ -88,16 +90,21 @@ signals: | |||
88 | void changedHorzCursor(int value); | 90 | void changedHorzCursor(int value); |
89 | void configureRequest( TEWidget*, int state, int x, int y ); | 91 | void configureRequest( TEWidget*, int state, int x, int y ); |
90 | 92 | ||
91 | void clearSelectionSignal(); | 93 | void clearSelectionSignal(); |
92 | void beginSelectionSignal( const int x, const int y ); | 94 | void beginSelectionSignal( const int x, const int y ); |
93 | void extendSelectionSignal( const int x, const int y ); | 95 | void extendSelectionSignal( const int x, const int y ); |
94 | void endSelectionSignal(const BOOL preserve_line_breaks); | 96 | void endSelectionSignal(const BOOL preserve_line_breaks); |
95 | 97 | ||
98 | void changeFontSize(int); | ||
99 | void toggleFullScreen(); | ||
100 | void setFullScreen(bool); | ||
101 | void changeSession(int); | ||
102 | void newSession(); | ||
96 | 103 | ||
97 | protected: | 104 | protected: |
98 | virtual void styleChange( QStyle& ); | 105 | virtual void styleChange( QStyle& ); |
99 | 106 | ||
100 | bool eventFilter( QObject *, QEvent * ); | 107 | bool eventFilter( QObject *, QEvent * ); |
101 | 108 | ||
102 | void drawAttrStr(QPainter &paint, QRect rect, | 109 | void drawAttrStr(QPainter &paint, QRect rect, |
103 | QString& str, ca attr, BOOL pm, BOOL clear); | 110 | QString& str, ca attr, BOOL pm, BOOL clear); |
@@ -147,17 +154,17 @@ protected slots: | |||
147 | void scrollChanged(int value); | 154 | void scrollChanged(int value); |
148 | void hScrollChanged(int value); | 155 | void hScrollChanged(int value); |
149 | void blinkEvent(); | 156 | void blinkEvent(); |
150 | 157 | ||
151 | private: | 158 | private: |
152 | 159 | ||
153 | QChar (*fontMap)(QChar); // possible vt100 font extention | 160 | QChar (*fontMap)(QChar); // possible vt100 font extention |
154 | 161 | ||
155 | bool fixed_font; // has fixed pitch | 162 | // bool fixed_font; // has fixed pitch |
156 | int font_h; // height | 163 | int font_h; // height |
157 | int font_w; // width | 164 | int font_w; // width |
158 | int font_a; // ascend | 165 | int font_a; // ascend |
159 | 166 | ||
160 | int blX; // actual offset (left) | 167 | int blX; // actual offset (left) |
161 | int brX; // actual offset (right) | 168 | int brX; // actual offset (right) |
162 | int bY; // actual offset | 169 | int bY; // actual offset |
163 | 170 | ||
@@ -177,28 +184,31 @@ private: | |||
177 | int actSel; // selection state | 184 | int actSel; // selection state |
178 | BOOL word_selection_mode; | 185 | BOOL word_selection_mode; |
179 | BOOL preserve_line_breaks; | 186 | BOOL preserve_line_breaks; |
180 | 187 | ||
181 | QClipboard* cb; | 188 | QClipboard* cb; |
182 | QScrollBar* scrollbar, *hScrollbar; | 189 | QScrollBar* scrollbar, *hScrollbar; |
183 | 190 | ||
184 | int scrollLoc, hScrollLoc; | 191 | int scrollLoc, hScrollLoc; |
185 | int hposition, vcolumns; | 192 | int hposition, vcolumns; |
186 | 193 | ||
194 | int mouse_down_x, mouse_down_y; | ||
187 | 195 | ||
188 | //#define SCRNONE 0 | 196 | //#define SCRNONE 0 |
189 | //#define SCRLEFT 1 | 197 | //#define SCRLEFT 1 |
190 | //#define SCRRIGHT 2 | 198 | //#define SCRRIGHT 2 |
191 | 199 | ||
192 | BOOL blinking; // hide text in paintEvent | 200 | BOOL blinking; // hide text in paintEvent |
193 | BOOL hasBlinker; // has characters to blink | 201 | BOOL hasBlinker; // has characters to blink |
194 | QTimer* blinkT; // active when hasBlinker | 202 | QTimer* blinkT; // active when hasBlinker |
195 | QPopupMenu* m_drop; | 203 | QPopupMenu* m_drop; |
196 | QString dropText; | 204 | QString dropText; |
205 | |||
197 | public: | 206 | public: |
198 | // current session in this widget | 207 | // current session in this widget |
199 | TESession *currentSession; | 208 | TESession *currentSession; |
209 | |||
200 | private slots: | 210 | private slots: |
201 | void drop_menu_activated(int item); | 211 | void drop_menu_activated(int item); |
202 | }; | 212 | }; |
203 | 213 | ||
204 | #endif // TE_WIDGET_H | 214 | #endif // TE_WIDGET_H |
diff --git a/core/apps/embeddedkonsole/TEmulation.cpp b/core/apps/embeddedkonsole/TEmulation.cpp index c19f2a1..a539757 100644 --- a/core/apps/embeddedkonsole/TEmulation.cpp +++ b/core/apps/embeddedkonsole/TEmulation.cpp | |||
@@ -190,16 +190,17 @@ void TEmulation::setKeytrans(const char * no) | |||
190 | /*! | 190 | /*! |
191 | */ | 191 | */ |
192 | 192 | ||
193 | void TEmulation::onRcvChar(int c) | 193 | void TEmulation::onRcvChar(int c) |
194 | // process application unicode input to terminal | 194 | // process application unicode input to terminal |
195 | // this is a trivial scanner | 195 | // this is a trivial scanner |
196 | { | 196 | { |
197 | c &= 0xff; | 197 | c &= 0xff; |
198 | |||
198 | switch (c) | 199 | switch (c) |
199 | { | 200 | { |
200 | case '\b' : scr->BackSpace(); break; | 201 | case '\b' : scr->BackSpace(); break; |
201 | case '\t' : scr->Tabulate(); break; | 202 | case '\t' : scr->Tabulate(); break; |
202 | case '\n' : scr->NewLine(); break; | 203 | case '\n' : scr->NewLine(); break; |
203 | case '\r' : scr->Return(); break; | 204 | case '\r' : scr->Return(); break; |
204 | case 0x07 : gui->Bell(); break; | 205 | case 0x07 : gui->Bell(); break; |
205 | default : scr->ShowCharacter(c); break; | 206 | default : scr->ShowCharacter(c); break; |
diff --git a/core/apps/embeddedkonsole/commandeditdialog.cpp b/core/apps/embeddedkonsole/commandeditdialog.cpp index dd35466..03cba87 100644 --- a/core/apps/embeddedkonsole/commandeditdialog.cpp +++ b/core/apps/embeddedkonsole/commandeditdialog.cpp | |||
@@ -97,17 +97,17 @@ connect(ToolButton5,SIGNAL(clicked()),m_PlayListSelection,SLOT(moveSelectedDown( | |||
97 | 97 | ||
98 | 98 | ||
99 | 99 | ||
100 | QListViewItem *current = m_SuggestedCommandList->selectedItem(); | 100 | QListViewItem *current = m_SuggestedCommandList->selectedItem(); |
101 | if ( current ) | 101 | if ( current ) |
102 | item->moveItem( current ); | 102 | item->moveItem( current ); |
103 | m_SuggestedCommandList->setSelected( item, TRUE ); | 103 | m_SuggestedCommandList->setSelected( item, TRUE ); |
104 | m_SuggestedCommandList->ensureItemVisible( m_SuggestedCommandList->selectedItem() ); | 104 | m_SuggestedCommandList->ensureItemVisible( m_SuggestedCommandList->selectedItem() ); |
105 | Config cfg("Konsole"); | 105 | Config cfg("Qkonsole"); |
106 | cfg.setGroup("Commands"); | 106 | cfg.setGroup("Commands"); |
107 | if (cfg.readEntry("Commands Set","FALSE") == "TRUE") { | 107 | if (cfg.readEntry("Commands Set","FALSE") == "TRUE") { |
108 | for (int i = 0; i < 100; i++) { | 108 | for (int i = 0; i < 100; i++) { |
109 | QString tmp; | 109 | QString tmp; |
110 | tmp = cfg.readEntry( QString::number(i),""); | 110 | tmp = cfg.readEntry( QString::number(i),""); |
111 | if (!tmp.isEmpty()) | 111 | if (!tmp.isEmpty()) |
112 | m_PlayListSelection->addStringToSelection(tmp); | 112 | m_PlayListSelection->addStringToSelection(tmp); |
113 | } | 113 | } |
@@ -147,17 +147,17 @@ m_PlayListSelection->addStringToSelection("traceroute"); | |||
147 | } | 147 | } |
148 | CommandEditDialog::~CommandEditDialog() | 148 | CommandEditDialog::~CommandEditDialog() |
149 | { | 149 | { |
150 | } | 150 | } |
151 | 151 | ||
152 | void CommandEditDialog::accept() | 152 | void CommandEditDialog::accept() |
153 | { | 153 | { |
154 | int i = 0; | 154 | int i = 0; |
155 | Config *cfg = new Config("Konsole"); | 155 | Config *cfg = new Config("Qkonsole"); |
156 | cfg->setGroup("Commands"); | 156 | cfg->setGroup("Commands"); |
157 | cfg->clearGroup(); | 157 | cfg->clearGroup(); |
158 | 158 | ||
159 | QListViewItemIterator it( m_PlayListSelection ); | 159 | QListViewItemIterator it( m_PlayListSelection ); |
160 | 160 | ||
161 | for ( ; it.current(); ++it ) { | 161 | for ( ; it.current(); ++it ) { |
162 | // qDebug(it.current()->text(0)); | 162 | // qDebug(it.current()->text(0)); |
163 | cfg->writeEntry(QString::number(i),it.current()->text(0)); | 163 | cfg->writeEntry(QString::number(i),it.current()->text(0)); |
diff --git a/core/apps/embeddedkonsole/konsole.cpp b/core/apps/embeddedkonsole/konsole.cpp index ce8fb6b..d10b66d 100644 --- a/core/apps/embeddedkonsole/konsole.cpp +++ b/core/apps/embeddedkonsole/konsole.cpp | |||
@@ -1,8 +1,9 @@ | |||
1 | |||
1 | /* ---------------------------------------------------------------------- */ | 2 | /* ---------------------------------------------------------------------- */ |
2 | /* */ | 3 | /* */ |
3 | /* [main.C] Konsole */ | 4 | /* [main.C] Konsole */ |
4 | /* */ | 5 | /* */ |
5 | /* ---------------------------------------------------------------------- */ | 6 | /* ---------------------------------------------------------------------- */ |
6 | /* */ | 7 | /* */ |
7 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ | 8 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ |
8 | /* */ | 9 | /* */ |
@@ -16,17 +17,17 @@ | |||
16 | /* Ported Konsole to Qt/Embedded */ | 17 | /* Ported Konsole to Qt/Embedded */ |
17 | /* */ | 18 | /* */ |
18 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ | 19 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ |
19 | /* */ | 20 | /* */ |
20 | /* -------------------------------------------------------------------------- */ | 21 | /* -------------------------------------------------------------------------- */ |
21 | // enhancements added by L.J. Potter <ljp@llornkcor.com> | 22 | // enhancements added by L.J. Potter <ljp@llornkcor.com> |
22 | //#define QT_QWS_OPIE | 23 | //#define QT_QWS_OPIE |
23 | 24 | ||
24 | #include "signal.h" | 25 | #include <stdlib.h> |
25 | 26 | ||
26 | #include <qpe/resource.h> | 27 | #include <qpe/resource.h> |
27 | 28 | ||
28 | #include <qdir.h> | 29 | #include <qdir.h> |
29 | #include <qevent.h> | 30 | #include <qevent.h> |
30 | #include <qdragobject.h> | 31 | #include <qdragobject.h> |
31 | #include <qobjectlist.h> | 32 | #include <qobjectlist.h> |
32 | #include <qtoolbutton.h> | 33 | #include <qtoolbutton.h> |
@@ -39,639 +40,1049 @@ | |||
39 | #include <qmessagebox.h> | 40 | #include <qmessagebox.h> |
40 | #include <qaction.h> | 41 | #include <qaction.h> |
41 | #include <qapplication.h> | 42 | #include <qapplication.h> |
42 | #include <qfontmetrics.h> | 43 | #include <qfontmetrics.h> |
43 | #include <qcombobox.h> | 44 | #include <qcombobox.h> |
44 | #include <qevent.h> | 45 | #include <qevent.h> |
45 | #include <qtabwidget.h> | 46 | #include <qtabwidget.h> |
46 | #include <qtabbar.h> | 47 | #include <qtabbar.h> |
48 | #include <qpe/config.h> | ||
47 | #include <qstringlist.h> | 49 | #include <qstringlist.h> |
48 | #include <qpalette.h> | 50 | #include <qpalette.h> |
49 | #include <qpe/config.h> | 51 | #include <qfontdatabase.h> |
50 | #include <qpe/qpeapplication.h> | 52 | #include <qfile.h> |
53 | #include <qspinbox.h> | ||
54 | #include <qlayout.h> | ||
55 | #include <qvbox.h> | ||
51 | 56 | ||
52 | #include <unistd.h> | 57 | #include <sys/wait.h> |
53 | #include <pwd.h> | ||
54 | #include <sys/types.h> | ||
55 | //#include <sys/wait.h> | ||
56 | #include <stdio.h> | 58 | #include <stdio.h> |
57 | #include <stdlib.h> | 59 | #include <stdlib.h> |
58 | #include <assert.h> | 60 | #include <assert.h> |
59 | 61 | ||
60 | #include "konsole.h" | 62 | #include "konsole.h" |
61 | #include "keytrans.h" | 63 | #include "keytrans.h" |
62 | #include "commandeditdialog.h" | 64 | #include "commandeditdialog.h" |
63 | 65 | ||
64 | #ifdef QT_QWS_OPIE | 66 | #ifdef QT_QWS_OPIE |
65 | #include <opie/colorpopupmenu.h> | 67 | #include <opie/colorpopupmenu.h> |
66 | #endif | 68 | #endif |
67 | 69 | ||
68 | #include <qfontdatabase.h>// U.B. | 70 | class EKNumTabBar : public QTabBar |
69 | #include <qstringlist.h>// U.B. | 71 | { |
70 | #include <qvaluelist.h> // U.B. | ||
71 | |||
72 | class EKNumTabBar : public QTabBar { | ||
73 | public: | 72 | public: |
73 | EKNumTabBar(QWidget *parent = 0, const char *name = 0) : | ||
74 | QTabBar(parent, name) | ||
75 | {} | ||
76 | |||
77 | // QList<QTab> *getTabList() { return(tabList()); } | ||
78 | |||
74 | void numberTabs() | 79 | void numberTabs() |
75 | { | 80 | { |
76 | // Yes, it really is this messy. QTabWidget needs functions | 81 | // Yes, it really is this messy. QTabWidget needs functions |
77 | // that provide acces to tabs in a sequential way. | 82 | // that provide acces to tabs in a sequential way. |
78 | int m=INT_MIN; | 83 | int m=INT_MIN; |
79 | for (int i=0; i<count(); i++) { | 84 | for (int i=0; i<count(); i++) |
80 | QTab* left=0; | 85 | { |
81 | QListIterator<QTab> it(*tabList()); | 86 | QTab* left=0; |
82 | int x=INT_MAX; | 87 | QListIterator<QTab> it(*tabList()); |
83 | for( QTab* t; (t=it.current()); ++it ) { | 88 | int x=INT_MAX; |
84 | int tx = t->rect().x(); | 89 | for( QTab* t; (t=it.current()); ++it ) |
85 | if ( tx<x && tx>m ) { | 90 | { |
86 | x = tx; | 91 | int tx = t->rect().x(); |
87 | left = t; | 92 | if ( tx<x && tx>m ) |
88 | } | 93 | { |
89 | } | 94 | x = tx; |
90 | if ( left ) { | 95 | left = t; |
91 | left->setText(QString::number(i+1)); | 96 | } |
92 | m = left->rect().x(); | 97 | } |
93 | } | 98 | if ( left ) |
94 | } | 99 | { |
100 | left->setText(QString::number(i+1)); | ||
101 | m = left->rect().x(); | ||
102 | } | ||
103 | } | ||
95 | } | 104 | } |
105 | |||
106 | virtual QSize sizeHint() const | ||
107 | { | ||
108 | if (isHidden()) | ||
109 | { | ||
110 | return(QSize(0,0)); | ||
111 | } | ||
112 | else | ||
113 | { | ||
114 | QSize size = QTabBar::sizeHint(); | ||
115 | int shrink = 5; | ||
116 | if (qApp->desktop()->width() > 600 || qApp->desktop()->height() > 600) | ||
117 | { | ||
118 | shrink = 10; | ||
119 | } | ||
120 | size.setHeight(size.height() - shrink); | ||
121 | return(size); | ||
122 | } | ||
123 | } | ||
124 | |||
96 | }; | 125 | }; |
97 | 126 | ||
98 | class EKNumTabWidget : public QTabWidget { | 127 | class EKNumTabWidget : public QTabWidget |
128 | { | ||
99 | public: | 129 | public: |
100 | EKNumTabWidget(QWidget* parent) : QTabWidget(parent) | 130 | EKNumTabWidget(QWidget* parent) : QTabWidget(parent) |
101 | { | 131 | { |
132 | setTabBar(new EKNumTabBar(parent,"EKTabBar")); | ||
133 | setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); | ||
102 | } | 134 | } |
103 | 135 | ||
136 | EKNumTabBar *getTabBar() const | ||
137 | { | ||
138 | return ((EKNumTabBar*)tabBar()); | ||
139 | } | ||
140 | |||
141 | |||
104 | void addTab(QWidget* w) | 142 | void addTab(QWidget* w) |
105 | { | 143 | { |
106 | QTab* t = new QTab(QString::number(tabBar()->count()+1)); | 144 | QTab* t = new QTab(QString::number(tabBar()->count()+1)); |
107 | QTabWidget::addTab(w,t); | 145 | QTabWidget::addTab(w,t); |
108 | } | 146 | } |
109 | 147 | ||
110 | void removeTab(QWidget* w) | 148 | void removeTab(QWidget* w) |
111 | { | 149 | { |
112 | removePage(w); | 150 | removePage(w); |
113 | ((EKNumTabBar*)tabBar())->numberTabs(); | 151 | ((EKNumTabBar*)tabBar())->numberTabs(); |
114 | } | 152 | } |
115 | }; | 153 | }; |
116 | 154 | ||
117 | // This could be configurable or dynamicly generated from the bash history | 155 | // This could be configurable or dynamicly generated from the bash history |
118 | // file of the user | 156 | // file of the user |
119 | static const char *commonCmds[] = | 157 | static const char *commonCmds[] = |
120 | { | 158 | { |
121 | "ls ", // I left this here, cause it looks better than the first alpha | 159 | "ls ", // I left this here, cause it looks better than the first alpha |
122 | "cardctl eject", | 160 | "cardctl eject", |
123 | "cat ", | 161 | "cat ", |
124 | "cd ", | 162 | "cd ", |
125 | "chmod ", | 163 | "chmod ", |
126 | "clear", | 164 | "clear", |
127 | "cp ", | 165 | "cp ", |
128 | "dc ", | 166 | "dc ", |
129 | "df ", | 167 | "df ", |
130 | "dmesg", | 168 | "dmesg", |
131 | "echo ", | 169 | "echo ", |
132 | "env", | 170 | "env", |
133 | "find ", | 171 | "find ", |
134 | "free", | 172 | "free", |
135 | "grep ", | 173 | "grep ", |
136 | "ifconfig ", | 174 | "ifconfig ", |
137 | "ipkg ", | 175 | "ipkg ", |
138 | "mkdir ", | 176 | "mkdir ", |
139 | "mv ", | 177 | "mv ", |
140 | "nc localhost 7776", | 178 | "nc localhost 7776", |
141 | "nc localhost 7777", | 179 | "nc localhost 7777", |
142 | "netstat ", | 180 | "netstat ", |
143 | "nslookup ", | 181 | "nslookup ", |
144 | "ping ", | 182 | "ping ", |
145 | "ps aux", | 183 | "ps aux", |
146 | "pwd ", | 184 | "pwd ", |
147 | "qcop QPE/System 'linkChanged(QString)' ''", | 185 | "qcop QPE/System 'linkChanged(QString)' ''", |
148 | "qcop QPE/System 'restart()'", | 186 | "qcop QPE/System 'restart()'", |
149 | "qcop QPE/System 'quit()'", | 187 | "qcop QPE/System 'quit()'", |
150 | "rm ", | 188 | "rm ", |
151 | "rmdir ", | 189 | "rmdir ", |
152 | "route ", | 190 | "route ", |
153 | "set ", | 191 | "set ", |
154 | "traceroute", | 192 | "traceroute", |
155 | 193 | ||
156 | /* | 194 | /* |
157 | "gzip", | 195 | "gzip", |
158 | "gunzip", | 196 | "gunzip", |
159 | "chgrp", | 197 | "chgrp", |
160 | "chown", | 198 | "chown", |
161 | "date", | 199 | "date", |
162 | "dd", | 200 | "dd", |
163 | "df", | 201 | "df", |
164 | "dmesg", | 202 | "dmesg", |
165 | "fuser", | 203 | "fuser", |
166 | "hostname", | 204 | "hostname", |
167 | "kill", | 205 | "kill", |
168 | "killall", | 206 | "killall", |
169 | "ln", | 207 | "ln", |
170 | "ping", | 208 | "ping", |
171 | "mount", | 209 | "mount", |
172 | "more", | 210 | "more", |
173 | "sort", | 211 | "sort", |
174 | "touch", | 212 | "touch", |
175 | "umount", | 213 | "umount", |
176 | "mknod", | 214 | "mknod", |
177 | "netstat", | 215 | "netstat", |
178 | */ | 216 | */ |
217 | |||
218 | "exit", | ||
219 | NULL | ||
220 | }; | ||
179 | 221 | ||
180 | "exit", | ||
181 | NULL | ||
182 | }; | ||
183 | 222 | ||
184 | static void konsoleInit(const char** shell) { | 223 | Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : |
185 | if(setuid(getuid()) !=0) qDebug("setuid failed"); | 224 | QMainWindow(parent, name, fl) |
186 | if(setgid(getgid()) != 0) qDebug("setgid failed"); // drop privileges | 225 | { |
226 | QStrList args; | ||
227 | init("/bin/bash",args); | ||
228 | } | ||
187 | 229 | ||
188 | // signal (SIGSTOP, SIG_IGN); | 230 | Konsole::Konsole(const char* name, const char* _pgm, QStrList & _args, int) |
189 | 231 | : QMainWindow(0, name) | |
190 | // QPEApplication::grabKeyboard(); // for CTRL and ALT | 232 | { |
233 | init(_pgm,_args); | ||
234 | } | ||
191 | 235 | ||
192 | // qDebug("keyboard grabbed"); | 236 | struct HistoryItem |
193 | #ifdef FAKE_CTRL_AND_ALT | 237 | { |
194 | qDebug("Fake Ctrl and Alt defined"); | 238 | HistoryItem(int c, const QString &l) |
195 | QPEApplication::grabKeyboard(); // for CTRL and ALT | 239 | { |
196 | #endif | 240 | count = c; |
241 | line = l; | ||
242 | } | ||
243 | int count; | ||
244 | QString line; | ||
245 | }; | ||
197 | 246 | ||
198 | *shell = getenv("SHELL"); | 247 | class HistoryList : public QList<HistoryItem> |
199 | // qWarning("SHell initially is %s", *shell ); | 248 | { |
249 | virtual int compareItems( QCollection::Item item1, QCollection::Item item2) | ||
250 | { | ||
251 | int c1 = ((HistoryItem*)item1)->count; | ||
252 | int c2 = ((HistoryItem*)item2)->count; | ||
253 | if (c1 > c2) | ||
254 | return(1); | ||
255 | if (c1 < c2) | ||
256 | return(-1); | ||
257 | return(0); | ||
258 | } | ||
259 | }; | ||
200 | 260 | ||
201 | if (shell == NULL || *shell == '\0') { | 261 | void Konsole::initCommandList() |
202 | struct passwd *ent = 0; | 262 | { |
203 | uid_t me = getuid(); | 263 | // qDebug("Konsole::initCommandList"); |
204 | *shell = "/bin/sh"; | 264 | Config cfg("Qkonsole"); |
265 | cfg.setGroup("Commands"); | ||
266 | // commonCombo->setInsertionPolicy(QComboBox::AtCurrent); | ||
267 | commonCombo->clear(); | ||
205 | 268 | ||
206 | while ( (ent = getpwent()) != 0 ) { | 269 | if (cfg.readEntry("ShellHistory","TRUE") == "TRUE") |
207 | if (ent->pw_uid == me) { | 270 | { |
208 | if (ent->pw_shell != "") | 271 | QString histfilename = QString(getenv("HOME")) + "/.bash_history"; |
209 | *shell = ent->pw_shell; | 272 | histfilename = cfg.readEntry("ShellHistoryPath",histfilename); |
210 | break; | 273 | QFile histfile(histfilename); |
274 | // note: compiler barfed on: | ||
275 | // QFile histfile(QString(getenv("HOME")) + "/.bash_history"); | ||
276 | if (histfile.open( IO_ReadOnly )) | ||
277 | { | ||
278 | QString line; | ||
279 | uint i; | ||
280 | HistoryList items; | ||
281 | |||
282 | int lineno = 0; | ||
283 | while(!histfile.atEnd()) | ||
284 | { | ||
285 | if (histfile.readLine(line, 200) < 0) | ||
286 | { | ||
287 | break; | ||
288 | } | ||
289 | line = line.left(line.length()-1); | ||
290 | lineno++; | ||
291 | |||
292 | for(i=0; i<items.count(); i++) | ||
293 | { | ||
294 | if (line == items.at(i)->line) | ||
295 | { | ||
296 | // weight recent commands & repeated commands more | ||
297 | // by adding up the index of each command | ||
298 | items.at(i)->count += lineno; | ||
299 | break; | ||
300 | } | ||
301 | } | ||
302 | if (i >= items.count()) | ||
303 | { | ||
304 | items.append(new HistoryItem(lineno, line)); | ||
305 | } | ||
306 | } | ||
307 | items.sort(); | ||
308 | int n = items.count(); | ||
309 | if (n > 40) | ||
310 | { | ||
311 | n = 40; | ||
211 | } | 312 | } |
313 | for(int i=0; i<n; i++) | ||
314 | { | ||
315 | // should insert start of command, but keep whole thing | ||
316 | if (items.at(items.count()-i-1)->line.length() < 30) | ||
317 | { | ||
318 | commonCombo->insertItem(items.at(items.count()-i-1)->line); | ||
319 | } | ||
320 | } | ||
321 | histfile.close(); | ||
322 | } | ||
323 | } | ||
324 | if (cfg.readEntry("Commands Set","FALSE") == "FALSE") | ||
325 | { | ||
326 | for (int i = 0; commonCmds[i] != NULL; i++) | ||
327 | { | ||
328 | commonCombo->insertItem(commonCmds[i]); | ||
329 | } | ||
330 | } | ||
331 | else | ||
332 | { | ||
333 | for (int i = 0; i < 100; i++) | ||
334 | { | ||
335 | if (!(cfg.readEntry( QString::number(i),"")).isEmpty()) | ||
336 | commonCombo->insertItem(cfg.readEntry( QString::number(i),"")); | ||
212 | } | 337 | } |
213 | endpwent(); | ||
214 | } | 338 | } |
215 | 339 | ||
216 | // qWarning("SHELL now is %s", *shell ); | ||
217 | 340 | ||
218 | if( putenv((char*)"COLORTERM=") !=0) | ||
219 | qDebug("putenv failed"); // to trigger mc's color detection | ||
220 | } | 341 | } |
221 | 342 | ||
222 | Konsole::Konsole(QWidget* parent, const char* name, WFlags fl) : | 343 | static void sig_handler(int x) |
223 | QMainWindow(parent, name, fl) | ||
224 | { | 344 | { |
225 | QStrList tmp; const char* shell; | 345 | printf("got signal %d\n",x); |
226 | |||
227 | setCaption( tr("Terminal") ); | ||
228 | |||
229 | konsoleInit( &shell); | ||
230 | // qWarning("Using shell %s", shell); | ||
231 | init(shell,tmp); | ||
232 | } | 346 | } |
233 | 347 | ||
234 | 348 | void Konsole::init(const char* _pgm, QStrList & _args) | |
235 | |||
236 | void Konsole::initCommandList() | ||
237 | { | 349 | { |
238 | // qDebug("Konsole::initCommandList"); | 350 | |
239 | Config cfg("Konsole"); | 351 | #if 0 |
240 | cfg.setGroup("Commands"); | 352 | for(int i=1; i<=31; i++) |
241 | commonCombo->setInsertionPolicy(QComboBox::AtCurrent); | 353 | { |
242 | commonCombo->clear(); | 354 | if (i != SIGPIPE && i != SIGPROF && i != SIGSEGV |
243 | if (cfg.readEntry("Commands Set","FALSE") == "FALSE") { | 355 | && i != SIGINT && i != SIGILL && i != SIGTERM |
244 | for (int i = 0; commonCmds[i] != NULL; i++) { | 356 | && i != SIGBUS) |
245 | commonCombo->insertItem(commonCmds[i],i); | 357 | signal(i,sig_handler); |
358 | } | ||
359 | #endif | ||
360 | signal(SIGSTOP, sig_handler); | ||
361 | signal(SIGCONT, sig_handler); | ||
362 | signal(SIGTSTP, sig_handler); | ||
363 | |||
364 | b_scroll = TRUE; // histon; | ||
365 | n_keytab = 0; | ||
366 | n_render = 0; | ||
367 | startUp=0; | ||
368 | fromMenu = FALSE; | ||
369 | fullscreen = false; | ||
370 | |||
371 | setCaption( "Qkonsole" ); | ||
372 | setIcon( Resource::loadPixmap( "qkonsole/qkonsole" ) ); | ||
373 | |||
374 | Config cfg("Qkonsole"); | ||
375 | cfg.setGroup("Font"); | ||
376 | QString tmp; | ||
377 | |||
378 | // initialize the list of allowed fonts /////////////////////////////////// | ||
379 | |||
380 | QString cfgFontName = cfg.readEntry("FontName","Lcfont"); | ||
381 | int cfgFontSize = cfg.readNumEntry("FontSize",18); | ||
382 | |||
383 | cfont = -1; | ||
384 | |||
385 | // this code causes repeated access to all the font files | ||
386 | // which does slow down startup | ||
387 | QFontDatabase fontDB; | ||
388 | QStringList familyNames; | ||
389 | familyNames = fontDB.families( FALSE ); | ||
390 | QString s; | ||
391 | int fontIndex = 0; | ||
392 | int familyNum = 0; | ||
393 | fontList = new QPopupMenu( this ); | ||
394 | |||
395 | for(uint j = 0; j < (uint)familyNames.count(); j++) | ||
396 | { | ||
397 | s = familyNames[j]; | ||
398 | if ( s.contains('-') ) | ||
399 | { | ||
400 | int i = s.find('-'); | ||
401 | s = s.right( s.length() - i - 1 ) + " [" + s.left( i ) + "]"; | ||
246 | } | 402 | } |
247 | } else { | 403 | s[0] = s[0].upper(); |
248 | for (int i = 0; i < 100; i++) { | 404 | |
249 | if (!(cfg.readEntry( QString::number(i),"")).isEmpty()) | 405 | QValueList<int> sizes = fontDB.pointSizes( familyNames[j] ); |
250 | commonCombo->insertItem((cfg.readEntry( QString::number(i),""))); | 406 | |
407 | printf("family[%d] = %s with %d sizes\n", j, familyNames[j].latin1(), | ||
408 | sizes.count()); | ||
409 | |||
410 | if (sizes.count() > 0) | ||
411 | { | ||
412 | QPopupMenu *sizeMenu; | ||
413 | QFont f; | ||
414 | int last_width = -1; | ||
415 | sizeMenu = NULL; | ||
416 | |||
417 | for(uint i = 0; i < (uint)sizes.count() + 4; i++) | ||
418 | { | ||
419 | // printf("family %s size %d ", familyNames[j].latin1(), sizes[i]); | ||
420 | // need to divide by 10 on the Z, but not otherwise | ||
421 | int size; | ||
422 | |||
423 | if (i >= (uint)sizes.count()) | ||
424 | { | ||
425 | // try for expandable fonts | ||
426 | size = sizes[sizes.count()-1] + 2 * (i - sizes.count() + 1); | ||
427 | } | ||
428 | else | ||
429 | { | ||
430 | printf("sizes[%d] = %d\n", i, sizes[i]); | ||
431 | size = sizes[i]; | ||
432 | } | ||
433 | #ifndef __i386__ | ||
434 | // a hack, sizes on Z seem to be points*10 | ||
435 | size /= 10; | ||
436 | #endif | ||
437 | |||
438 | f = QFont(familyNames[j], size); | ||
439 | f.setFixedPitch(true); | ||
440 | QFontMetrics fm(f); | ||
441 | // don't trust f.fixedPitch() or f.exactMatch(), they lie!! | ||
442 | if (fm.width("l") == fm.width("m") | ||
443 | && (i < (uint)sizes.count() | ||
444 | || fm.width("m") > last_width)) | ||
445 | { | ||
446 | if (i < (uint)sizes.count()) | ||
447 | { | ||
448 | last_width = fm.width("m"); | ||
449 | } | ||
450 | if (sizeMenu == NULL) | ||
451 | { | ||
452 | sizeMenu = new QPopupMenu(); | ||
453 | } | ||
454 | int id = sizeMenu->insertItem(QString("%1").arg(size), fontIndex); | ||
455 | sizeMenu->setItemParameter(id, fontIndex); | ||
456 | sizeMenu->connectItem(id, this, SLOT(setFont(int))); | ||
457 | QString name = s + " " + QString::number(size); | ||
458 | fonts.append(new VTFont(name, f, familyNames[j], familyNum, size)); | ||
459 | if (familyNames[j] == cfgFontName && size == cfgFontSize) | ||
460 | { | ||
461 | cfont = fontIndex; | ||
462 | } | ||
463 | printf("FOUND: %s family %s size %d\n", name.latin1(), familyNames[j].latin1(), size); | ||
464 | fontIndex++; | ||
465 | } | ||
466 | } | ||
467 | if (sizeMenu) | ||
468 | { | ||
469 | fontList->insertItem(s, sizeMenu, familyNum + 1000); | ||
470 | |||
471 | familyNum++; | ||
472 | } | ||
251 | } | 473 | } |
474 | |||
252 | } | 475 | } |
253 | 476 | ||
254 | } | 477 | if (cfont < 0 || cfont >= (int)fonts.count()) |
478 | { | ||
479 | cfont = 0; | ||
480 | } | ||
255 | 481 | ||
256 | void Konsole::init(const char* _pgm, QStrList & _args) | 482 | // create terminal emulation framework //////////////////////////////////// |
257 | { | 483 | nsessions = 0; |
258 | b_scroll = TRUE; // histon; | ||
259 | n_keytab = 0; | ||
260 | n_render = 0; | ||
261 | startUp=0; | ||
262 | fromMenu = FALSE; | ||
263 | |||
264 | setCaption( tr("Terminal") ); | ||
265 | setIcon( Resource::loadPixmap( "konsole" ) ); | ||
266 | |||
267 | Config cfg("Konsole"); | ||
268 | cfg.setGroup("Konsole"); | ||
269 | QString tmp; | ||
270 | // initialize the list of allowed fonts /////////////////////////////////// | ||
271 | cfont = cfg.readNumEntry("FontID", 1); | ||
272 | |||
273 | QFont f = QFont("Micro", 4, QFont::Normal); | ||
274 | f.setFixedPitch(TRUE); | ||
275 | fonts.append(new VTFont(tr("Micro"), f)); | ||
276 | |||
277 | f = QFont("Fixed", 7, QFont::Normal); | ||
278 | f.setFixedPitch(TRUE); | ||
279 | fonts.append(new VTFont(tr("Small Fixed"), f)); | ||
280 | |||
281 | f = QFont("Fixed", 12, QFont::Normal); | ||
282 | f.setFixedPitch(TRUE); | ||
283 | fonts.append(new VTFont(tr("Medium Fixed"), f)); | ||
284 | |||
285 | // NEW STUFF | ||
286 | |||
287 | QStringList ignfont = cfg.readListEntry("IgnFont", ','); | ||
288 | /* If there is no "IgnFont = ..." entry in "myonsole.conf", | ||
289 | * put some Japanese fonts of the SL-C7x0 to "ignfont". */ | ||
290 | |||
291 | if (ignfont.isEmpty()) { | ||
292 | ignfont = QStringList::split (',',"jisupasp,mmkjg1,mmkjg4,mmkjg5"); | ||
293 | } | ||
294 | |||
295 | //QFont | ||
296 | f = QFont("Fixed", 16, QFont::Normal); | ||
297 | f.setFixedPitch(true); | ||
298 | fonts.append(new VTFont(tr("Default"), f)); | ||
299 | |||
300 | int fcount = 1; | ||
301 | |||
302 | f.setCharSet(QFont::AnyCharSet); | ||
303 | f.setStyleHint(QFont::TypeWriter, QFont::PreferMatch); | ||
304 | // f.setWeight(QFont::Normal); | ||
305 | 484 | ||
306 | /* | 485 | tab = new EKNumTabWidget(this); |
307 | * Look for installed font families. If the family is not in | 486 | // tab->setMargin(tab->margin()-5); |
308 | * the "ignfont" list, look for available sizes. | 487 | connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); |
309 | * If it is fixed pitch font, put the font and the size | ||
310 | * to the fontlist. | ||
311 | */ | ||
312 | QFontDatabase fdb; | ||
313 | QStringList ff = fdb.families(false); | ||
314 | |||
315 | for (QStringList::Iterator it = ff.begin(); it != ff.end(); ++it ) { | ||
316 | QString fit = *it; | ||
317 | |||
318 | if( fit != "fixed" && fit != "micro" ) { | ||
319 | if ( ignfont.contains(*it) == 0) { | ||
320 | QValueList<int> pt = fdb.pointSizes(*it); | ||
321 | |||
322 | for (QValueList<int>::Iterator itv = pt.begin(); | ||
323 | itv != pt.end(); ++itv ) { | ||
324 | int size = (*itv)/10; | ||
325 | if(size > 0) { | ||
326 | f.setFamily(*it); | ||
327 | f.setPointSize(size); | ||
328 | } | ||
329 | |||
330 | QFontMetrics fm(f); | ||
331 | |||
332 | //qDebug("%s %d:\twidth('i')=%d, width('w')=%d", (*it).latin1(), (*itv)/10, fm.width('i'), fm.width('w')); | ||
333 | |||
334 | if (fm.width('i') == fm.width('w') ) { | ||
335 | qDebug((*it)); | ||
336 | f.setFixedPitch(true); | ||
337 | fonts.append(new VTFont(*it + ' ' + QString::number(size), f)); | ||
338 | fcount++; | ||
339 | } | ||
340 | } | ||
341 | } | ||
342 | } | ||
343 | } | ||
344 | |||
345 | // END NEW STUFF | ||
346 | |||
347 | |||
348 | // create terminal emulation framework //////////////////////////////////// | ||
349 | nsessions = 0; | ||
350 | |||
351 | tab = new EKNumTabWidget(this); | ||
352 | |||
353 | connect(tab, SIGNAL(currentChanged(QWidget*)), this, SLOT(switchSession(QWidget*))); | ||
354 | |||
355 | // create terminal toolbar //////////////////////////////////////////////// | ||
356 | setToolBarsMovable( FALSE ); | ||
357 | QToolBar *menuToolBar = new QToolBar( this ); | ||
358 | menuToolBar->setHorizontalStretchable( TRUE ); | ||
359 | |||
360 | QMenuBar *menuBar = new QMenuBar( menuToolBar ); | ||
361 | |||
362 | fontList = new QPopupMenu( this ); | ||
363 | for(uint i = 0; i < fonts.count(); i++) { | ||
364 | VTFont *fnt = fonts.at(i); | ||
365 | fontList->insertItem(fnt->getName(), i); | ||
366 | } | ||
367 | 488 | ||
368 | fontChanged(cfont); | 489 | // create terminal toolbar //////////////////////////////////////////////// |
490 | setToolBarsMovable( FALSE ); | ||
491 | menuToolBar = new QToolBar( this ); | ||
492 | menuToolBar->setHorizontalStretchable( TRUE ); | ||
369 | 493 | ||
370 | configMenu = new QPopupMenu( this); | 494 | QMenuBar *menuBar = new QMenuBar( menuToolBar ); |
371 | colorMenu = new QPopupMenu( this); | ||
372 | scrollMenu = new QPopupMenu( this); | ||
373 | editCommandListMenu = new QPopupMenu( this); | ||
374 | 495 | ||
375 | configMenu->insertItem(tr("Command List"), editCommandListMenu); | 496 | bool c7xx = false; |
497 | if (qApp->desktop()->width() > 600 || qApp->desktop()->height() > 600) | ||
498 | { | ||
499 | c7xx = true; | ||
500 | } | ||
501 | QFont menuFont; | ||
502 | menuFont.setPointSize(c7xx? 18 : 10); | ||
503 | qApp->setFont(menuFont, true); | ||
376 | 504 | ||
377 | bool listHidden; | 505 | setFont(cfont); |
378 | cfg.setGroup("Menubar"); | ||
379 | if( cfg.readEntry("Hidden","FALSE") == "TRUE") { | ||
380 | editCommandListMenu->insertItem( tr( "Show command list" )); | ||
381 | listHidden=TRUE; | ||
382 | } else { | ||
383 | editCommandListMenu->insertItem( tr( "Hide command list" )); | ||
384 | listHidden=FALSE; | ||
385 | } | ||
386 | 506 | ||
387 | cfg.setGroup("Tabs"); | 507 | configMenu = new QPopupMenu( this); |
388 | tmp=cfg.readEntry("Position","Bottom"); | 508 | colorMenu = new QPopupMenu( this); |
389 | if(tmp=="Top") { | 509 | scrollMenu = new QPopupMenu( this); |
390 | tab->setTabPosition(QTabWidget::Top); | 510 | editCommandListMenu = new QPopupMenu( this); |
391 | configMenu->insertItem( tr( "Tabs on Bottom" ) ); | 511 | |
392 | } else { | 512 | configMenu->insertItem(tr("Command List"), editCommandListMenu); |
393 | tab->setTabPosition(QTabWidget::Bottom); | 513 | |
394 | configMenu->insertItem(tr("Tabs on Top")); | 514 | bool listHidden; |
395 | } | 515 | cfg.setGroup("Menubar"); |
396 | configMenu->insertSeparator(2); | 516 | if( cfg.readEntry("Hidden","FALSE") == "TRUE") |
397 | 517 | { | |
398 | colorMenu->insertItem(tr( "Green on Black")); | 518 | ec_cmdlist = editCommandListMenu->insertItem( tr( "Show command list" )); |
399 | colorMenu->insertItem(tr( "Black on White")); | 519 | listHidden=TRUE; |
400 | colorMenu->insertItem(tr( "White on Black")); | 520 | } |
401 | colorMenu->insertItem(tr( "Black on Transparent")); | 521 | else |
402 | colorMenu->insertItem(tr( "Black on Red")); | 522 | { |
403 | colorMenu->insertItem(tr( "Red on Black")); | 523 | ec_cmdlist = editCommandListMenu->insertItem( tr( "Hide command list" )); |
404 | colorMenu->insertItem(tr( "Green on Yellow")); | 524 | listHidden=FALSE; |
405 | colorMenu->insertItem(tr( "Blue on Magenta")); | 525 | } |
406 | colorMenu->insertItem(tr( "Magenta on Blue")); | 526 | |
407 | colorMenu->insertItem(tr( "Cyan on White")); | 527 | cfg.setGroup("Tabs"); |
408 | colorMenu->insertItem(tr( "White on Cyan")); | 528 | |
409 | colorMenu->insertItem(tr( "Blue on Black")); | 529 | tabMenu = new QPopupMenu(this); |
410 | colorMenu->insertItem(tr( "Amber on Black")); | 530 | tm_bottom = tabMenu->insertItem(tr("Bottom" )); |
531 | tm_top = tabMenu->insertItem(tr("Top")); | ||
532 | tm_hidden = tabMenu->insertItem(tr("Hidden")); | ||
533 | |||
534 | configMenu->insertItem(tr("Tabs"), tabMenu); | ||
535 | |||
536 | tmp=cfg.readEntry("Position","Top"); | ||
537 | if(tmp=="Top") | ||
538 | { | ||
539 | tab->setTabPosition(QTabWidget::Top); | ||
540 | tab->getTabBar()->show(); | ||
541 | tabPos = tm_top; | ||
542 | } | ||
543 | else if (tmp=="Bottom") | ||
544 | { | ||
545 | tab->setTabPosition(QTabWidget::Bottom); | ||
546 | tab->getTabBar()->show(); | ||
547 | tabPos = tm_bottom; | ||
548 | } | ||
549 | else | ||
550 | { | ||
551 | tab->getTabBar()->hide(); | ||
552 | tab->setMargin(tab->margin()); | ||
553 | tabPos = tm_hidden; | ||
554 | } | ||
555 | |||
556 | cm_bw = colorMenu->insertItem(tr( "Black on White")); | ||
557 | cm_wb = colorMenu->insertItem(tr( "White on Black")); | ||
558 | cm_gb = colorMenu->insertItem(tr( "Green on Black")); | ||
559 | // cm_bt = colorMenu->insertItem(tr( "Black on Transparent")); | ||
560 | cm_br = colorMenu->insertItem(tr( "Black on Pink")); | ||
561 | cm_rb = colorMenu->insertItem(tr( "Pink on Black")); | ||
562 | cm_gy = colorMenu->insertItem(tr( "Green on Yellow")); | ||
563 | cm_bm = colorMenu->insertItem(tr( "Blue on Magenta")); | ||
564 | cm_mb = colorMenu->insertItem(tr( "Magenta on Blue")); | ||
565 | cm_cw = colorMenu->insertItem(tr( "Cyan on White")); | ||
566 | cm_wc = colorMenu->insertItem(tr( "White on Cyan")); | ||
567 | cm_bb = colorMenu->insertItem(tr( "Blue on Black")); | ||
568 | cm_ab = colorMenu->insertItem(tr( "Amber on Black")); | ||
569 | cm_default = colorMenu->insertItem(tr("default")); | ||
411 | 570 | ||
412 | #ifdef QT_QWS_OPIE | 571 | #ifdef QT_QWS_OPIE |
413 | colorMenu->insertItem(tr( "Custom")); | 572 | |
573 | colorMenu->insertItem(tr( "Custom")); | ||
414 | #endif | 574 | #endif |
415 | 575 | ||
416 | configMenu->insertItem( tr("Font"), fontList ); | 576 | configMenu->insertItem(tr( "Colors") ,colorMenu); |
417 | configMenu->insertItem(tr( "Colors") ,colorMenu); | ||
418 | |||
419 | connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); | ||
420 | connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); | ||
421 | connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) )); | ||
422 | connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int))); | ||
423 | connect(editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int))); | ||
424 | |||
425 | menuBar->insertItem( tr("Options"), configMenu ); | ||
426 | |||
427 | QToolBar *toolbar = new QToolBar( this ); | ||
428 | |||
429 | QAction *a; | ||
430 | |||
431 | // Button Commands | ||
432 | a = new QAction( tr("New"), Resource::loadPixmap( "konsole" ), QString::null, 0, this, 0 ); | ||
433 | connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); a->addTo( toolbar ); | ||
434 | a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); | ||
435 | connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolbar ); | ||
436 | a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); | ||
437 | connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolbar ); | ||
438 | a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 ); | ||
439 | connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolbar ); | ||
440 | a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); | ||
441 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); | ||
442 | a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); | ||
443 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); | ||
444 | a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); | ||
445 | connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); a->addTo( toolbar ); | ||
446 | /* | ||
447 | a = new QAction( tr("Up"), Resource::loadPixmap( "up" ), QString::null, 0, this, 0 ); | ||
448 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolbar ); | ||
449 | a = new QAction( tr("Down"), Resource::loadPixmap( "down" ), QString::null, 0, this, 0 ); | ||
450 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolbar ); | ||
451 | */ | ||
452 | 577 | ||
453 | secondToolBar = new QToolBar( this ); | 578 | sessionList = new QPopupMenu(this); |
454 | secondToolBar->setHorizontalStretchable( TRUE ); | 579 | sessionList-> insertItem ( Resource::loadPixmap ( "qkonsole/qkonsole" ), tr( "new session" ), this, |
580 | SLOT(newSession()) ); | ||
455 | 581 | ||
456 | commonCombo = new QComboBox( secondToolBar ); | 582 | // connect( fontList, SIGNAL( activated(int) ), this, SLOT( fontChanged(int) )); |
457 | commonCombo->setMaximumWidth(236); | 583 | connect( configMenu, SIGNAL( activated(int) ), this, SLOT( configMenuSelected(int) )); |
584 | connect( colorMenu, SIGNAL( activated(int) ), this, SLOT( colorMenuIsSelected(int) )); | ||
585 | connect( tabMenu, SIGNAL( activated(int) ), this, SLOT( tabMenuSelected(int) )); | ||
586 | connect( scrollMenu, SIGNAL(activated(int)),this,SLOT(scrollMenuSelected(int))); | ||
587 | connect( editCommandListMenu,SIGNAL(activated(int)),this,SLOT(editCommandListMenuSelected(int))); | ||
588 | connect( sessionList, SIGNAL(activated(int)), this, SLOT( sessionListSelected(int) ) ); | ||
458 | 589 | ||
459 | editCommandListMenu->insertItem( tr( "Quick Edit" ) ); | 590 | menuBar->insertItem( tr("View"), configMenu ); |
460 | if( listHidden) { | 591 | menuBar->insertItem( tr("Fonts"), fontList ); |
461 | secondToolBar->hide(); | 592 | menuBar->insertItem( tr("Sessions"), sessionList ); |
462 | editCommandListMenu->setItemEnabled(-23 ,FALSE); | 593 | |
463 | } | 594 | toolBar = new QToolBar( this ); |
464 | editCommandListMenu->insertItem(tr( "Edit" ) ); | ||
465 | 595 | ||
466 | cfg.setGroup("Commands"); | 596 | QAction *a; |
467 | commonCombo->setInsertionPolicy(QComboBox::AtCurrent); | ||
468 | 597 | ||
469 | initCommandList(); | 598 | // Button Commands |
470 | // for (int i = 0; commonCmds[i] != NULL; i++) { | 599 | a = new QAction( tr("New"), Resource::loadPixmap( "konsole/Terminal" ), QString::null, 0, this, 0 ); |
471 | // commonCombo->insertItem( commonCmds[i], i ); | 600 | connect( a, SIGNAL( activated() ), this, SLOT( newSession() ) ); |
472 | // tmp = cfg.readEntry( QString::number(i),""); | 601 | a->addTo( toolBar ); |
473 | // if(tmp != "") | ||
474 | // commonCombo->changeItem( tmp,i ); | ||
475 | // } | ||
476 | 602 | ||
477 | connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); | 603 | a = new QAction( tr("Full Screen"), Resource::loadPixmap( "fullscreen" ), QString::null, 0, this, 0 ); |
604 | connect( a, SIGNAL( activated() ), this, SLOT( toggleFullScreen() ) ); | ||
605 | a->addTo( toolBar ); | ||
478 | 606 | ||
479 | scrollMenu->insertItem(tr( "None" )); | 607 | a = new QAction( tr("Zoom"), Resource::loadPixmap( "zoom" ), QString::null, 0, this, 0 ); |
480 | scrollMenu->insertItem(tr( "Left" )); | 608 | connect( a, SIGNAL( activated() ), this, SLOT( cycleZoom() ) ); |
481 | scrollMenu->insertItem(tr( "Right" )); | 609 | a->addTo( toolBar ); |
482 | // scrollMenu->insertSeparator(4); | ||
483 | // scrollMenu->insertItem(tr( "Horizontal" )); | ||
484 | 610 | ||
485 | configMenu->insertItem(tr( "ScrollBar" ),scrollMenu); | ||
486 | 611 | ||
487 | int jut = configMenu->insertItem(tr( "Wrap" )); | 612 | /* |
613 | a = new QAction( tr("Enter"), Resource::loadPixmap( "konsole/enter" ), QString::null, 0, this, 0 ); | ||
614 | connect( a, SIGNAL( activated() ), this, SLOT( hitEnter() ) ); a->addTo( toolBar ); | ||
615 | a = new QAction( tr("Space"), Resource::loadPixmap( "konsole/space" ), QString::null, 0, this, 0 ); | ||
616 | connect( a, SIGNAL( activated() ), this, SLOT( hitSpace() ) ); a->addTo( toolBar ); | ||
617 | a = new QAction( tr("Tab"), Resource::loadPixmap( "konsole/tab" ), QString::null, 0, this, 0 ); | ||
618 | connect( a, SIGNAL( activated() ), this, SLOT( hitTab() ) ); a->addTo( toolBar ); | ||
619 | */ | ||
620 | /* | ||
621 | a = new QAction( tr("Up"), Resource::loadPixmap( "konsole/up" ), QString::null, 0, this, 0 ); | ||
622 | connect( a, SIGNAL( activated() ), this, SLOT( hitUp() ) ); a->addTo( toolBar ); | ||
623 | a = new QAction( tr("Down"), Resource::loadPixmap( "konsole/down" ), QString::null, 0, this, 0 ); | ||
624 | connect( a, SIGNAL( activated() ), this, SLOT( hitDown() ) ); a->addTo( toolBar ); | ||
625 | */ | ||
626 | a = new QAction( tr("Paste"), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); | ||
627 | connect( a, SIGNAL( activated() ), this, SLOT( hitPaste() ) ); | ||
628 | a->addTo( toolBar ); | ||
629 | |||
630 | secondToolBar = new QToolBar( this ); | ||
631 | secondToolBar->setHorizontalStretchable( TRUE ); | ||
632 | |||
633 | commonCombo = new QComboBox( secondToolBar ); | ||
634 | // commonCombo->setMaximumWidth(236); | ||
635 | |||
636 | ec_quick = editCommandListMenu->insertItem( tr( "Quick Edit" ) ); | ||
637 | if( listHidden) | ||
638 | { | ||
639 | secondToolBar->hide(); | ||
640 | editCommandListMenu->setItemEnabled(ec_quick ,FALSE); | ||
641 | } | ||
642 | ec_edit = editCommandListMenu->insertItem(tr( "Edit" ) ); | ||
643 | |||
644 | cfg.setGroup("Commands"); | ||
645 | commonCombo->setInsertionPolicy(QComboBox::AtCurrent); | ||
646 | |||
647 | initCommandList(); | ||
648 | // for (int i = 0; commonCmds[i] != NULL; i++) { | ||
649 | // commonCombo->insertItem( commonCmds[i], i ); | ||
650 | // tmp = cfg.readEntry( QString::number(i),""); | ||
651 | // if(tmp != "") | ||
652 | // commonCombo->changeItem( tmp,i ); | ||
653 | // } | ||
654 | |||
655 | connect( commonCombo, SIGNAL( activated(int) ), this, SLOT( enterCommand(int) )); | ||
656 | |||
657 | sm_none = scrollMenu->insertItem(tr( "None" )); | ||
658 | sm_left = scrollMenu->insertItem(tr( "Left" )); | ||
659 | sm_right = scrollMenu->insertItem(tr( "Right" )); | ||
660 | // scrollMenu->insertSeparator(4); | ||
661 | // scrollMenu->insertItem(tr( "Horizontal" )); | ||
662 | |||
663 | configMenu->insertItem(tr( "ScrollBar" ),scrollMenu); | ||
664 | |||
665 | configMenu->insertItem(tr( "History" ), this, SLOT(historyDialog())); | ||
666 | |||
667 | cm_wrap = configMenu->insertItem(tr( "Wrap" )); | ||
488 | cfg.setGroup("ScrollBar"); | 668 | cfg.setGroup("ScrollBar"); |
489 | configMenu->setItemChecked(jut, cfg.readBoolEntry("HorzScroll",0)); | 669 | configMenu->setItemChecked(cm_wrap, cfg.readBoolEntry("HorzScroll",0)); |
490 | 670 | ||
491 | jut = configMenu->insertItem(tr( "Use Beep" )); | 671 | cm_beep = configMenu->insertItem(tr( "Use Beep" )); |
492 | cfg.setGroup("Menubar"); | 672 | cfg.setGroup("Menubar"); |
493 | 673 | configMenu->setItemChecked(cm_beep, cfg.readBoolEntry("useBeep",0)); | |
494 | configMenu->setItemChecked(jut, cfg.readBoolEntry("useBeep",0)); | 674 | |
495 | 675 | fullscreen_msg = new QLabel(this); | |
496 | 676 | fullscreen_msg-> setAlignment ( AlignCenter | SingleLine ); | |
497 | //scrollMenuSelected(-29); | 677 | fullscreen_msg-> hide(); |
498 | // cfg.setGroup("ScrollBar"); | 678 | fullscreen_msg-> setSizePolicy ( QSizePolicy ( QSizePolicy::Expanding, QSizePolicy::Expanding )); |
499 | // if(cfg.readBoolEntry("HorzScroll",0)) { | 679 | fullscreen_msg-> setAutoResize(true); |
500 | // if(cfg.readNumEntry("Position",2) == 0) | 680 | fullscreen_msg-> setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
501 | // te->setScrollbarLocation(1); | 681 | fullscreen_msg-> setText(tr("To exit fullscreen, tap here.")); |
502 | // else | 682 | |
503 | // te->setScrollbarLocation(0); | 683 | fullscreen_timer = new QTimer(this); |
504 | // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); | 684 | connect(fullscreen_timer, SIGNAL(timeout()), |
505 | // te->setWrapAt(120); | 685 | this, SLOT(fullscreenTimeout())); |
506 | // } | 686 | show_fullscreen_msg = true; |
507 | // create applications ///////////////////////////////////////////////////// | 687 | |
508 | setCentralWidget(tab); | 688 | //scrollMenuSelected(-29); |
509 | 689 | // cfg.setGroup("ScrollBar"); | |
510 | // load keymaps //////////////////////////////////////////////////////////// | 690 | // if(cfg.readBoolEntry("HorzScroll",0)) { |
511 | KeyTrans::loadAll(); | 691 | // if(cfg.readNumEntry("Position",2) == 0) |
512 | for (int i = 0; i < KeyTrans::count(); i++) | 692 | // te->setScrollbarLocation(1); |
513 | { KeyTrans* s = KeyTrans::find(i); | 693 | // else |
514 | assert( s ); | 694 | // te->setScrollbarLocation(0); |
515 | } | 695 | // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); |
696 | // te->setWrapAt(120); | ||
697 | // } | ||
698 | // create applications ///////////////////////////////////////////////////// | ||
699 | setCentralWidget(tab); | ||
700 | |||
701 | // load keymaps //////////////////////////////////////////////////////////// | ||
702 | KeyTrans::loadAll(); | ||
703 | for (int i = 0; i < KeyTrans::count(); i++) | ||
704 | { | ||
705 | KeyTrans* s = KeyTrans::find(i); | ||
706 | assert( s ); | ||
707 | } | ||
708 | |||
709 | se_pgm = _pgm; | ||
710 | se_args = _args; | ||
711 | |||
712 | cfg.setGroup("CommandLine"); | ||
516 | 713 | ||
517 | se_pgm = _pgm; | 714 | if (cfg.hasKey("shell_args")) |
518 | se_args = _args; | 715 | { |
519 | se_args.prepend("--login"); | 716 | QStringList se_args_list = cfg.readListEntry("shell_args",'|'); |
520 | parseCommandLine(); | 717 | for(uint i = 0; i < se_args_list.count(); i++) |
521 | // read and apply default values /////////////////////////////////////////// | 718 | { |
522 | resize(321, 321); // Dummy. | 719 | se_args.prepend(se_args_list[se_args_list.count() - i - 1].latin1()); |
523 | QSize currentSize = size(); | 720 | } |
524 | if (currentSize != size()) | 721 | } |
525 | defaultSize = size(); | 722 | else |
723 | { | ||
724 | se_args.prepend("--login"); | ||
725 | } | ||
726 | |||
727 | se_pgm = cfg.readEntry("shell_bin", QString(se_pgm)); | ||
728 | |||
729 | // this is the "documentation" for those who know to look | ||
730 | if (! cfg.hasKey("shell_args")) | ||
731 | { | ||
732 | cfg.writeEntry("shell_args",QStringList::fromStrList(se_args),'|'); | ||
733 | } | ||
734 | if (! cfg.hasKey("shell_bin")) | ||
735 | { | ||
736 | cfg.writeEntry("shell_bin",QString(se_pgm)); | ||
737 | } | ||
738 | |||
739 | parseCommandLine(); | ||
740 | |||
741 | // read and apply default values /////////////////////////////////////////// | ||
742 | resize(321, 321); // Dummy. | ||
743 | QSize currentSize = size(); | ||
744 | if (currentSize != size()) | ||
745 | defaultSize = size(); | ||
746 | |||
747 | |||
748 | /* allows us to catch cancel/escape */ | ||
749 | reparent ( 0, WStyle_Customize | WStyle_NoBorder, | ||
750 | QPoint ( 0, 0 )); | ||
526 | } | 751 | } |
527 | 752 | ||
528 | void Konsole::show() | 753 | void Konsole::show() |
529 | { | 754 | { |
530 | if ( !nsessions ) { | 755 | if ( !nsessions ) |
531 | newSession(); | 756 | { |
532 | } | 757 | newSession(); |
533 | QMainWindow::show(); | 758 | } |
759 | QMainWindow::show(); | ||
534 | 760 | ||
535 | } | 761 | } |
536 | 762 | ||
537 | void Konsole::initSession(const char*, QStrList &) | 763 | void Konsole::initSession(const char*, QStrList &) |
538 | { | 764 | { |
539 | QMainWindow::show(); | 765 | QMainWindow::show(); |
540 | } | 766 | } |
541 | 767 | ||
542 | Konsole::~Konsole() | 768 | Konsole::~Konsole() |
543 | { | 769 | { |
544 | while (nsessions > 0) { | 770 | while (nsessions > 0) |
545 | doneSession(getTe()->currentSession, 0); | 771 | { |
546 | } | 772 | doneSession(getTe(), 0); |
773 | } | ||
774 | } | ||
775 | |||
776 | void | ||
777 | Konsole::historyDialog() | ||
778 | { | ||
779 | QDialog *d = new QDialog ( this, "histdlg", true ); | ||
780 | // d-> setCaption ( tr( "History" )); | ||
781 | |||
782 | QBoxLayout *lay = new QVBoxLayout ( d, 4, 4 ); | ||
783 | |||
784 | QLabel *l = new QLabel ( tr( "History Lines:" ), d ); | ||
785 | lay-> addWidget ( l ); | ||
786 | |||
787 | Config cfg("Qkonsole"); | ||
788 | cfg.setGroup("History"); | ||
789 | int hist = cfg.readNumEntry("history_lines",300); | ||
790 | int avg_line = cfg.readNumEntry("avg_line_length",60); | ||
791 | |||
792 | QSpinBox *spin = new QSpinBox ( 1, 100000, 20, d ); | ||
793 | spin-> setValue ( hist ); | ||
794 | spin-> setWrapping ( true ); | ||
795 | spin-> setButtonSymbols ( QSpinBox::PlusMinus ); | ||
796 | lay-> addWidget ( spin ); | ||
797 | |||
798 | if ( d-> exec ( ) == QDialog::Accepted ) | ||
799 | { | ||
800 | cfg.writeEntry("history_lines", spin->value()); | ||
801 | cfg.writeEntry("avg_line_length", avg_line); | ||
802 | if (getTe() != NULL) | ||
803 | { | ||
804 | getTe()->currentSession->setHistory(true); | ||
805 | } | ||
806 | } | ||
807 | |||
808 | delete d; | ||
809 | } | ||
810 | |||
811 | |||
812 | void Konsole::cycleZoom() | ||
813 | { | ||
814 | TEWidget* te = getTe(); | ||
815 | QFont font = te->getVTFont(); | ||
816 | int size = font.pointSize(); | ||
817 | changeFontSize(1); | ||
818 | font = te->getVTFont(); | ||
819 | if (font.pointSize() <= size) | ||
820 | { | ||
821 | do | ||
822 | { | ||
823 | font = te->getVTFont(); | ||
824 | size = font.pointSize(); | ||
825 | changeFontSize(-1); | ||
826 | font = te->getVTFont(); | ||
827 | } | ||
828 | while (font.pointSize() < size); | ||
829 | } | ||
830 | } | ||
831 | |||
832 | void Konsole::changeFontSize(int delta) | ||
833 | { | ||
834 | // printf("delta font size %d\n", delta); | ||
835 | TEWidget* te = getTe(); | ||
836 | QFont font = te->getVTFont(); | ||
837 | int size = font.pointSize(); | ||
838 | int closest = delta > 0? 10000 : -10000; | ||
839 | int closest_font = -1; | ||
840 | for(uint i = 0; i < fonts.count(); i++) | ||
841 | { | ||
842 | if (fonts.at(i)->getFont() == font) | ||
843 | { | ||
844 | if (delta > 0) | ||
845 | { | ||
846 | if (i+1 < fonts.count() | ||
847 | && fonts.at(i+1)->getFamilyNum() == fonts.at(i)->getFamilyNum()) | ||
848 | { | ||
849 | setFont(i+1); | ||
850 | printf("font %d\n", i+1); | ||
851 | return; | ||
852 | } | ||
853 | } | ||
854 | else if (delta < 0) | ||
855 | { | ||
856 | if (i > 0 | ||
857 | && fonts.at(i-1)->getFamilyNum() == fonts.at(i)->getFamilyNum()) | ||
858 | { | ||
859 | setFont(i-1); | ||
860 | printf("font %d\n", i-1); | ||
861 | return; | ||
862 | } | ||
863 | } | ||
864 | } | ||
865 | int fsize = fonts.at(i)->getSize(); | ||
866 | printf("%d size=%d fsize=%d closest=%d\n", i, size, fsize, closest); | ||
867 | if ((delta > 0 && fsize > size && fsize < closest) | ||
868 | || (delta < 0 && fsize < size && fsize > closest)) | ||
869 | { | ||
870 | closest = fsize; | ||
871 | closest_font = i; | ||
872 | } | ||
873 | } | ||
874 | if (closest_font >= 0) | ||
875 | { | ||
876 | printf("font closest %d (%d)\n", closest_font, closest); | ||
877 | setFont(closest_font); | ||
878 | } | ||
879 | } | ||
880 | |||
881 | int Konsole::findFont(QString name, int size, bool exactMatch) | ||
882 | { | ||
883 | for(uint i = 0; i < fonts.count(); i++) | ||
884 | { | ||
885 | if (fonts.at(i)->getName() == name | ||
886 | && fonts.at(i)->getSize() == size) | ||
887 | { | ||
888 | return(i); | ||
889 | } | ||
890 | } | ||
891 | if (exactMatch) | ||
892 | { | ||
893 | return(-1); | ||
894 | } | ||
895 | for(uint i = 0; i < fonts.count(); i++) | ||
896 | { | ||
897 | if (fonts.at(i)->getSize() == size) | ||
898 | { | ||
899 | return(i); | ||
900 | } | ||
901 | } | ||
902 | return(-1); | ||
903 | } | ||
547 | 904 | ||
548 | Config cfg("Konsole"); | 905 | void Konsole::setFont(int f) |
549 | cfg.setGroup("Konsole"); | 906 | { |
550 | cfg.writeEntry("FontID", cfont); | 907 | VTFont* font = fonts.at(f); |
908 | if (font) | ||
909 | { | ||
910 | TEWidget* te = getTe(); | ||
911 | if (te != 0) | ||
912 | { | ||
913 | te->setVTFont(font->getFont()); | ||
914 | } | ||
915 | cfont = f; | ||
916 | |||
917 | int familyNum = font->getFamilyNum(); | ||
918 | int size = font->getSize(); | ||
919 | printf("familyNum = %d size = %d count=%d\n", familyNum, size, | ||
920 | fontList->count()); | ||
921 | for(int i = 0; i < (int)fontList->count(); i++) | ||
922 | { | ||
923 | fontList->setItemChecked(i + 1000, i == familyNum); | ||
924 | } | ||
925 | for(int i = 0; i < (int)fonts.count(); i++) | ||
926 | { | ||
927 | fontList->setItemChecked(i, fonts.at(i)->getFamilyNum() == familyNum | ||
928 | && fonts.at(i)->getSize() == size); | ||
929 | } | ||
930 | Config cfg("Qkonsole"); | ||
931 | cfg.setGroup("Font"); | ||
932 | QString ss = "Session"+ QString::number(tab->currentPageIndex()+1); | ||
933 | if (tab->currentPageIndex() == 0) | ||
934 | { | ||
935 | cfg.writeEntry("FontName", fonts.at(cfont)->getFamily()); | ||
936 | cfg.writeEntry("FontSize", fonts.at(cfont)->getSize()); | ||
937 | } | ||
938 | cfg.writeEntry("FontName"+ss, fonts.at(cfont)->getFamily()); | ||
939 | cfg.writeEntry("FontSize"+ss, fonts.at(cfont)->getSize()); | ||
940 | } | ||
551 | } | 941 | } |
552 | 942 | ||
943 | #if 0 | ||
553 | void Konsole::fontChanged(int f) | 944 | void Konsole::fontChanged(int f) |
554 | { | 945 | { |
555 | VTFont* font = fonts.at(f); | 946 | VTFont* font = fonts.at(f); |
556 | if (font != 0) { | 947 | if (font != 0) |
557 | for(uint i = 0; i < fonts.count(); i++) { | 948 | { |
949 | for(uint i = 0; i < fonts.count(); i++) | ||
950 | { | ||
558 | fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE); | 951 | fontList->setItemChecked(i, (i == (uint) f) ? TRUE : FALSE); |
559 | } | 952 | } |
560 | 953 | ||
561 | cfont = f; | 954 | cfont = f; |
562 | 955 | ||
563 | TEWidget* te = getTe(); | 956 | TEWidget* te = getTe(); |
564 | if (te != 0) { | 957 | if (te != 0) |
958 | { | ||
565 | te->setVTFont(font->getFont()); | 959 | te->setVTFont(font->getFont()); |
566 | } | 960 | } |
567 | } | 961 | } |
568 | } | 962 | } |
963 | #endif | ||
569 | 964 | ||
570 | 965 | ||
571 | void Konsole::enterCommand(int c) | 966 | void Konsole::enterCommand(int c) |
572 | { | 967 | { |
573 | TEWidget* te = getTe(); | 968 | TEWidget* te = getTe(); |
574 | if (te != 0) { | 969 | if (te != 0) |
575 | if(!commonCombo->editable()) { | 970 | { |
971 | if(!commonCombo->editable()) | ||
972 | { | ||
576 | QString text = commonCombo->text(c); //commonCmds[c]; | 973 | QString text = commonCombo->text(c); //commonCmds[c]; |
577 | te->emitText(text); | 974 | te->emitText(text); |
578 | } else { | 975 | } |
976 | else | ||
977 | { | ||
579 | changeCommand( commonCombo->text(c), c); | 978 | changeCommand( commonCombo->text(c), c); |
580 | } | 979 | } |
581 | } | 980 | } |
582 | } | 981 | } |
583 | 982 | ||
584 | void Konsole::hitEnter() | 983 | void Konsole::hitEnter() |
585 | { | 984 | { |
586 | TEWidget* te = getTe(); | 985 | TEWidget* te = getTe(); |
587 | if (te != 0) { | 986 | if (te != 0) |
588 | te->emitText(QString("\r")); | 987 | { |
988 | te->emitText(QString("\r")); | ||
589 | } | 989 | } |
590 | } | 990 | } |
591 | 991 | ||
592 | void Konsole::hitSpace() | 992 | void Konsole::hitSpace() |
593 | { | 993 | { |
594 | TEWidget* te = getTe(); | 994 | TEWidget* te = getTe(); |
595 | if (te != 0) { | 995 | if (te != 0) |
596 | te->emitText(QString(" ")); | 996 | { |
997 | te->emitText(QString(" ")); | ||
597 | } | 998 | } |
598 | } | 999 | } |
599 | 1000 | ||
600 | void Konsole::hitTab() | 1001 | void Konsole::hitTab() |
601 | { | 1002 | { |
602 | TEWidget* te = getTe(); | 1003 | TEWidget* te = getTe(); |
603 | if (te != 0) { | 1004 | if (te != 0) |
604 | te->emitText(QString("\t")); | 1005 | { |
1006 | te->emitText(QString("\t")); | ||
605 | } | 1007 | } |
606 | } | 1008 | } |
607 | 1009 | ||
608 | void Konsole::hitPaste() | 1010 | void Konsole::hitPaste() |
609 | { | 1011 | { |
610 | TEWidget* te = getTe(); | 1012 | TEWidget* te = getTe(); |
611 | if (te != 0) { | 1013 | if (te != 0) |
612 | te->pasteClipboard(); | 1014 | { |
1015 | te->pasteClipboard(); | ||
613 | } | 1016 | } |
614 | } | 1017 | } |
615 | 1018 | ||
616 | void Konsole::hitUp() | 1019 | void Konsole::hitUp() |
617 | { | 1020 | { |
618 | TEWidget* te = getTe(); | 1021 | TEWidget* te = getTe(); |
619 | if (te != 0) { | 1022 | if (te != 0) |
620 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0); | 1023 | { |
621 | QApplication::sendEvent( te, &ke ); | 1024 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Up, 0, 0); |
1025 | QApplication::sendEvent( te, &ke ); | ||
622 | } | 1026 | } |
623 | } | 1027 | } |
624 | 1028 | ||
625 | void Konsole::hitDown() | 1029 | void Konsole::hitDown() |
626 | { | 1030 | { |
627 | TEWidget* te = getTe(); | 1031 | TEWidget* te = getTe(); |
628 | if (te != 0) { | 1032 | if (te != 0) |
629 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0); | 1033 | { |
630 | QApplication::sendEvent( te, &ke ); | 1034 | QKeyEvent ke( QKeyEvent::KeyPress, Qt::Key_Down, 0, 0); |
1035 | QApplication::sendEvent( te, &ke ); | ||
631 | } | 1036 | } |
632 | } | 1037 | } |
633 | 1038 | ||
634 | /** | 1039 | /** |
635 | This function calculates the size of the external widget | 1040 | This function calculates the size of the external widget |
636 | needed for the internal widget to be | 1041 | needed for the internal widget to be |
637 | */ | 1042 | */ |
638 | QSize Konsole::calcSize(int columns, int lines) { | 1043 | QSize Konsole::calcSize(int columns, int lines) |
1044 | { | ||
639 | TEWidget* te = getTe(); | 1045 | TEWidget* te = getTe(); |
640 | if (te != 0) { | 1046 | if (te != 0) |
641 | QSize size = te->calcSize(columns, lines); | 1047 | { |
642 | return size; | 1048 | QSize size = te->calcSize(columns, lines); |
643 | } else { | 1049 | return size; |
644 | QSize size; | 1050 | } |
645 | return size; | 1051 | else |
1052 | { | ||
1053 | QSize size; | ||
1054 | return size; | ||
646 | } | 1055 | } |
647 | } | 1056 | } |
648 | 1057 | ||
649 | /** | 1058 | /** |
650 | sets application window to a size based on columns X lines of the te | 1059 | sets application window to a size based on columns X lines of the te |
651 | guest widget. Call with (0,0) for setting default size. | 1060 | guest widget. Call with (0,0) for setting default size. |
652 | */ | 1061 | */ |
653 | 1062 | ||
654 | void Konsole::setColLin(int columns, int lines) | 1063 | void Konsole::setColLin(int columns, int lines) |
655 | { | 1064 | { |
656 | qDebug("konsole::setColLin:: Columns %d", columns); | 1065 | qDebug("konsole::setColLin:: Columns %d", columns); |
657 | 1066 | ||
658 | if ((columns==0) || (lines==0)) | 1067 | if ((columns==0) || (lines==0)) |
659 | { | ||
660 | if (defaultSize.isEmpty()) // not in config file : set default value | ||
661 | { | 1068 | { |
662 | defaultSize = calcSize(80,24); | 1069 | if (defaultSize.isEmpty()) // not in config file : set default value |
663 | // notifySize(24,80); // set menu items (strange arg order !) | 1070 | { |
1071 | defaultSize = calcSize(80,24); | ||
1072 | // notifySize(24,80); // set menu items (strange arg order !) | ||
1073 | } | ||
1074 | resize(defaultSize); | ||
1075 | } | ||
1076 | else | ||
1077 | { | ||
1078 | resize(calcSize(columns, lines)); | ||
1079 | // notifySize(lines,columns); // set menu items (strange arg order !) | ||
664 | } | 1080 | } |
665 | resize(defaultSize); | ||
666 | } else { | ||
667 | resize(calcSize(columns, lines)); | ||
668 | // notifySize(lines,columns); // set menu items (strange arg order !) | ||
669 | } | ||
670 | } | 1081 | } |
671 | 1082 | ||
672 | /* | 1083 | /* |
673 | void Konsole::setFont(int fontno) | 1084 | void Konsole::setFont(int fontno) |
674 | { | 1085 | { |
675 | QFont f; | 1086 | QFont f; |
676 | if (fontno == 0) | 1087 | if (fontno == 0) |
677 | f = defaultFont = QFont( "Helvetica", 12 ); | 1088 | f = defaultFont = QFont( "Helvetica", 12 ); |
@@ -692,485 +1103,816 @@ void Konsole::setFont(int fontno) | |||
692 | if (se) se->setFontNo(fontno); | 1103 | if (se) se->setFontNo(fontno); |
693 | te->setVTFont(f); | 1104 | te->setVTFont(f); |
694 | n_font = fontno; | 1105 | n_font = fontno; |
695 | } | 1106 | } |
696 | */ | 1107 | */ |
697 | 1108 | ||
698 | // --| color selection |------------------------------------------------------- | 1109 | // --| color selection |------------------------------------------------------- |
699 | 1110 | ||
700 | void Konsole::changeColumns(int columns) | 1111 | void Konsole::changeColumns(int /*columns*/) |
701 | { | 1112 | { //FIXME this seems to cause silliness when reset command is executed |
702 | //FIXME this seems to cause silliness when reset command is executed | 1113 | // qDebug("change columns"); |
703 | // qDebug("change columns"); | 1114 | // TEWidget* te = getTe(); |
704 | // TEWidget* te = getTe(); | 1115 | // if (te != 0) { |
705 | // if (te != 0) { | 1116 | // setColLin(columns,te->Lines()); |
706 | // setColLin(columns,te->Lines()); | 1117 | // te->update(); |
707 | // te->update(); | 1118 | // } |
708 | // } | ||
709 | } | 1119 | } |
710 | 1120 | ||
711 | //FIXME: If a child dies during session swap, | 1121 | //FIXME: If a child dies during session swap, |
712 | // this routine might be called before | 1122 | // this routine might be called before |
713 | // session swap is completed. | 1123 | // session swap is completed. |
714 | 1124 | ||
715 | void Konsole::doneSession(TESession*, int ) | 1125 | void Konsole::doneSession(TEWidget* te, int ) |
716 | { | 1126 | { |
717 | TEWidget *te = getTe(); | 1127 | // TEWidget *te = NULL; |
718 | if (te != 0) { | 1128 | // if (sess->currentSession == tab->currentPage()) { |
719 | te->currentSession->setConnect(FALSE); | 1129 | // printf("done current session\n"); |
720 | tab->removeTab(te); | 1130 | // te = getTe(); |
721 | delete te->currentSession; | 1131 | // } else { |
722 | delete te; | 1132 | // int currentPage = tab->currentPageIndex(); |
723 | nsessions--; | 1133 | // printf("done not current session\n"); |
724 | } | 1134 | // for(int i = 0; i < nsessions; i++) { |
1135 | // tab->setCurrentPage(i); | ||
1136 | // printf("find session %d tab page %x session %x\n", | ||
1137 | // i, tab->currentPage(), sess->currentSession); | ||
1138 | // if (tab->currentPage() == sess->currentSession) { | ||
1139 | // printf("found session %d\n", i); | ||
1140 | // te = tab->currentPage(); | ||
1141 | // break; | ||
1142 | // } | ||
1143 | // } | ||
1144 | // tab->setCurrentPage(currentPage); | ||
1145 | // } | ||
1146 | if (te != 0) | ||
1147 | { | ||
1148 | te->currentSession->setConnect(FALSE); | ||
1149 | tab->removeTab(te); | ||
1150 | delete te->currentSession; | ||
1151 | delete te; | ||
1152 | sessionList->removeItem(nsessions); | ||
1153 | nsessions--; | ||
1154 | } | ||
1155 | if (nsessions == 0) | ||
1156 | { | ||
1157 | close(); | ||
1158 | } | ||
1159 | } | ||
725 | 1160 | ||
726 | if (nsessions == 0) { | 1161 | void Konsole::changeTitle(TEWidget* te, QString newTitle ) |
727 | close(); | 1162 | { |
728 | } | 1163 | if (te == getTe()) |
1164 | { | ||
1165 | setCaption(newTitle + " - QKonsole"); | ||
1166 | } | ||
729 | } | 1167 | } |
730 | 1168 | ||
731 | void Konsole::newSession() { | ||
732 | if(nsessions < 15) { // seems to be something weird about 16 tabs on the Zaurus.... memory? | ||
733 | TEWidget* te = new TEWidget(tab); | ||
734 | Config c("Konsole"); | ||
735 | c.setGroup("Menubar"); | ||
736 | te->useBeep=c.readBoolEntry("useBeep",0); | ||
737 | 1169 | ||
738 | // te->setBackgroundMode(PaletteBase); //we want transparent!! | 1170 | void Konsole::newSession() |
1171 | { | ||
1172 | if(nsessions < 15) | ||
1173 | { // seems to be something weird about 16 tabs on the Zaurus.... memory? | ||
1174 | TEWidget* te = new TEWidget(tab); | ||
1175 | Config cfg("Qkonsole"); | ||
1176 | cfg.setGroup("Menubar"); | ||
1177 | |||
1178 | // FIXME use more defaults from config file | ||
1179 | te->useBeep=cfg.readBoolEntry("useBeep",0); | ||
1180 | |||
1181 | // te->setBackgroundMode(PaletteBase); //we want transparent!! | ||
1182 | |||
1183 | cfg.setGroup("Font"); | ||
1184 | QString sn = "Session" + QString::number(nsessions+1); | ||
1185 | printf("read font session %s\n", sn.latin1()); | ||
1186 | QString fontName = cfg.readEntry("FontName"+sn, | ||
1187 | cfg.readEntry("FontName", | ||
1188 | fonts.at(cfont)->getFamily())); | ||
1189 | int fontSize = cfg.readNumEntry("FontSize"+sn, | ||
1190 | cfg.readNumEntry("FontSize", | ||
1191 | fonts.at(cfont)->getSize())); | ||
1192 | cfont = findFont(fontName, fontSize, false); | ||
1193 | printf("lookup font %s size %d got %d\n", fontName.latin1(), fontSize, cfont); | ||
1194 | if (cfont < 0) | ||
1195 | cfont = 0; | ||
739 | te->setVTFont(fonts.at(cfont)->getFont()); | 1196 | te->setVTFont(fonts.at(cfont)->getFont()); |
1197 | |||
740 | tab->addTab(te); | 1198 | tab->addTab(te); |
741 | TESession* se = new TESession(this, te, se_pgm, se_args, "xterm"); | 1199 | TESession* se = new TESession(this, te, se_pgm, se_args, "xterm"); |
742 | te->currentSession = se; | 1200 | te->currentSession = se; |
743 | connect( se, SIGNAL(done(TESession*,int)), this, SLOT(doneSession(TESession*,int)) ); | 1201 | connect( se, SIGNAL(done(TEWidget*,int)), this, SLOT(doneSession(TEWidget*,int)) ); |
1202 | connect( se, SIGNAL(changeTitle(TEWidget*,QString)), this, | ||
1203 | SLOT(changeTitle(TEWidget*,QString)) ); | ||
1204 | connect(te, SIGNAL(changeFontSize(int)), this, SLOT(changeFontSize(int))); | ||
1205 | connect(te, SIGNAL(changeSession(int)), this, SLOT(changeSession(int))); | ||
1206 | connect(te, SIGNAL(newSession()), this, SLOT(newSession())); | ||
1207 | connect(te, SIGNAL(toggleFullScreen()), this, SLOT(toggleFullScreen())); | ||
1208 | connect(te, SIGNAL(setFullScreen(bool)), this, SLOT(setFullScreen(bool))); | ||
744 | se->run(); | 1209 | se->run(); |
745 | se->setConnect(TRUE); | 1210 | se->setConnect(TRUE); |
746 | se->setHistory(b_scroll); | 1211 | se->setHistory(b_scroll); |
747 | tab->setCurrentPage(nsessions); | ||
748 | nsessions++; | 1212 | nsessions++; |
1213 | sessionList->insertItem(QString::number(nsessions), nsessions); | ||
1214 | sessionListSelected(nsessions); | ||
749 | doWrap(); | 1215 | doWrap(); |
750 | setColor(); | 1216 | setColor(nsessions-1); |
751 | } | 1217 | } |
752 | } | 1218 | } |
753 | 1219 | ||
754 | TEWidget* Konsole::getTe() { | 1220 | TEWidget* Konsole::getTe() |
755 | if (nsessions) { | 1221 | { |
756 | return (TEWidget *) tab->currentPage(); | 1222 | if (nsessions) |
757 | } else { | 1223 | { |
758 | return 0; | 1224 | return (TEWidget *) tab->currentPage(); |
759 | } | 1225 | } |
1226 | else | ||
1227 | { | ||
1228 | return 0; | ||
1229 | } | ||
760 | } | 1230 | } |
761 | 1231 | ||
762 | void Konsole::switchSession(QWidget* w) { | 1232 | void Konsole::sessionListSelected(int id) |
763 | TEWidget* te = (TEWidget *) w; | 1233 | { |
1234 | if (id < 0) | ||
1235 | { | ||
1236 | return; | ||
1237 | } | ||
1238 | QString selected = sessionList->text(id); | ||
1239 | EKNumTabBar *tabBar = tab->getTabBar(); | ||
764 | 1240 | ||
765 | QFont teFnt = te->getVTFont(); | 1241 | int n = 0; |
766 | for(uint i = 0; i < fonts.count(); i++) { | 1242 | for(int i = 0; n < tabBar->count(); i++) |
767 | VTFont *fnt = fonts.at(i); | 1243 | { |
768 | bool cf = fnt->getFont() == teFnt; | 1244 | if (tabBar->tab(i)) |
769 | fontList->setItemChecked(i, cf); | 1245 | { |
770 | if (cf) { | 1246 | // printf("selected = %s tab %d = %s\n", selected.latin1(), |
771 | cfont = i; | 1247 | // i, tabBar->tab(i)->text().latin1()); |
1248 | if (tabBar->tab(i)->text() == selected) | ||
1249 | { | ||
1250 | tab->setCurrentPage(i); | ||
1251 | break; | ||
1252 | } | ||
1253 | n++; | ||
1254 | } | ||
772 | } | 1255 | } |
773 | } | ||
774 | } | 1256 | } |
775 | 1257 | ||
776 | void Konsole::colorMenuIsSelected(int iD) { | 1258 | |
1259 | void Konsole::changeSession(int delta) | ||
1260 | { | ||
1261 | printf("delta session %d\n", delta); | ||
1262 | QTabBar *tabBar = tab->getTabBar(); | ||
1263 | int i = tabBar->tab(tabBar->currentTab())->text().toInt() - 1; | ||
1264 | i += delta; | ||
1265 | if (i < 0) | ||
1266 | i += tabBar->count(); | ||
1267 | if (i >= tabBar->count()) | ||
1268 | i -= tabBar->count(); | ||
1269 | |||
1270 | QString selected = QString::number(i+1); | ||
1271 | int n = 0; | ||
1272 | for(int i = 0; n < tabBar->count(); i++) | ||
1273 | { | ||
1274 | if (tabBar->tab(i)) | ||
1275 | { | ||
1276 | printf("selected = %s tab %d = %s\n", selected.latin1(), | ||
1277 | i, tabBar->tab(i)->text().latin1()); | ||
1278 | if (tabBar->tab(i)->text() == selected) | ||
1279 | { | ||
1280 | tab->setCurrentPage(i); | ||
1281 | break; | ||
1282 | } | ||
1283 | n++; | ||
1284 | } | ||
1285 | } | ||
1286 | } | ||
1287 | |||
1288 | void Konsole::switchSession(QWidget* w) | ||
1289 | { | ||
1290 | TEWidget* te = (TEWidget *) w; | ||
1291 | QFont teFnt = te->getVTFont(); | ||
1292 | int familyNum = -1; | ||
1293 | |||
1294 | for(uint i = 0; i < fonts.count(); i++) | ||
1295 | { | ||
1296 | VTFont *fnt = fonts.at(i); | ||
1297 | bool cf = fnt->getFont() == teFnt; | ||
1298 | fontList->setItemChecked(i, cf); | ||
1299 | if (cf) | ||
1300 | { | ||
1301 | cfont = i; | ||
1302 | familyNum = fnt->getFamilyNum(); | ||
1303 | } | ||
1304 | } | ||
1305 | for(int i = 0; i < (int)fontList->count(); i++) | ||
1306 | { | ||
1307 | fontList->setItemChecked(i + 1000, i == familyNum); | ||
1308 | } | ||
1309 | if (! te->currentSession->Title().isEmpty() ) | ||
1310 | { | ||
1311 | setCaption(te->currentSession->Title() + " - QKonsole"); | ||
1312 | } | ||
1313 | else | ||
1314 | { | ||
1315 | setCaption( "Qkonsole" ); | ||
1316 | } | ||
1317 | // colorMenuSelected(te->color_menu_item); | ||
1318 | } | ||
1319 | |||
1320 | |||
1321 | void Konsole::toggleFullScreen() | ||
1322 | { | ||
1323 | setFullScreen(! fullscreen); | ||
1324 | } | ||
1325 | |||
1326 | void Konsole::setFullScreen ( bool b ) | ||
1327 | { | ||
1328 | static QSize normalsize; | ||
1329 | static bool listHidden; | ||
1330 | |||
1331 | if (b == fullscreen) | ||
1332 | { | ||
1333 | return; | ||
1334 | } | ||
1335 | |||
1336 | fullscreen = b; | ||
1337 | |||
1338 | if ( b ) | ||
1339 | { | ||
1340 | if ( !normalsize. isValid ( )) | ||
1341 | { | ||
1342 | normalsize = size ( ); | ||
1343 | } | ||
1344 | |||
1345 | setFixedSize ( qApp-> desktop ( )-> size ( )); | ||
1346 | showNormal ( ); | ||
1347 | reparent ( 0, WStyle_Customize | WStyle_NoBorder, | ||
1348 | QPoint ( 0, 0 )); | ||
1349 | showFullScreen ( ); | ||
1350 | |||
1351 | menuToolBar->hide(); | ||
1352 | toolBar->hide(); | ||
1353 | listHidden = secondToolBar->isHidden(); | ||
1354 | secondToolBar->hide(); | ||
1355 | // commonCombo->hide(); | ||
1356 | tab->getTabBar()->hide(); | ||
1357 | tab->setMargin(tab->margin()); | ||
1358 | |||
1359 | if (show_fullscreen_msg) | ||
1360 | { | ||
1361 | fullscreen_msg-> move(tab->x() + tab->width()/2 - fullscreen_msg->width()/2, | ||
1362 | qApp->desktop()->height()/16 - fullscreen_msg->height()/2); | ||
1363 | fullscreen_msg->show(); | ||
1364 | fullscreen_timer->start(3000, true); | ||
1365 | show_fullscreen_msg = false; | ||
1366 | } | ||
1367 | } | ||
1368 | else | ||
1369 | { | ||
1370 | showNormal ( ); | ||
1371 | reparent ( 0, WStyle_Customize, QPoint ( 0, 0 )); | ||
1372 | resize ( normalsize ); | ||
1373 | showMaximized ( ); | ||
1374 | normalsize = QSize ( ); | ||
1375 | |||
1376 | menuToolBar->show(); | ||
1377 | toolBar->show(); | ||
1378 | if(! listHidden) | ||
1379 | { | ||
1380 | secondToolBar->show(); | ||
1381 | } | ||
1382 | // commonCombo->show(); | ||
1383 | menuToolBar->show(); | ||
1384 | if (tabPos != tm_hidden) | ||
1385 | { | ||
1386 | tab->getTabBar()->show(); | ||
1387 | } | ||
1388 | } | ||
1389 | tab->setMargin(tab->margin()); // cause setup to run | ||
1390 | } | ||
1391 | |||
1392 | |||
1393 | void Konsole::fullscreenTimeout() | ||
1394 | { | ||
1395 | fullscreen_msg->hide(); | ||
1396 | } | ||
1397 | |||
1398 | void Konsole::colorMenuIsSelected(int iD) | ||
1399 | { | ||
777 | fromMenu = TRUE; | 1400 | fromMenu = TRUE; |
778 | colorMenuSelected(iD); | 1401 | colorMenuSelected(iD); |
779 | } | 1402 | } |
780 | 1403 | ||
781 | /// ------------------------------- some new stuff by L.J. Potter | 1404 | /// ------------------------------- some new stuff by L.J. Potter |
1405 | |||
1406 | |||
782 | void Konsole::colorMenuSelected(int iD) | 1407 | void Konsole::colorMenuSelected(int iD) |
783 | { // this is NOT pretty, elegant or anything else besides functional | 1408 | { |
784 | // QString temp; | 1409 | // this is NOT pretty, elegant or anything else besides functional |
785 | // qDebug( temp.sprintf("colormenu %d", iD)); | 1410 | // QString temp; |
1411 | // qDebug( temp.sprintf("colormenu %d", iD)); | ||
786 | 1412 | ||
787 | TEWidget* te = getTe(); | 1413 | TEWidget* te = getTe(); |
788 | Config cfg("Konsole"); | 1414 | Config cfg("Qkonsole"); |
789 | cfg.setGroup("Colors"); | 1415 | cfg.setGroup("Colors"); |
790 | // QColor foreground; | 1416 | |
791 | // QColor background; | ||
792 | colorMenu->setItemChecked(lastSelectedMenu,FALSE); | ||
793 | ColorEntry m_table[TABLE_COLORS]; | 1417 | ColorEntry m_table[TABLE_COLORS]; |
794 | const ColorEntry * defaultCt=te->getdefaultColorTable(); | 1418 | const ColorEntry * defaultCt=te->getdefaultColorTable(); |
795 | /////////// fore back | 1419 | |
796 | int i; | 1420 | int i; |
797 | if(iD==-9) { // default default | 1421 | |
798 | for (i = 0; i < TABLE_COLORS; i++) { | 1422 | // te->color_menu_item = iD; |
1423 | |||
1424 | colorMenu->setItemChecked(cm_ab,FALSE); | ||
1425 | colorMenu->setItemChecked(cm_bb,FALSE); | ||
1426 | colorMenu->setItemChecked(cm_wc,FALSE); | ||
1427 | colorMenu->setItemChecked(cm_cw,FALSE); | ||
1428 | colorMenu->setItemChecked(cm_mb,FALSE); | ||
1429 | colorMenu->setItemChecked(cm_bm,FALSE); | ||
1430 | colorMenu->setItemChecked(cm_gy,FALSE); | ||
1431 | colorMenu->setItemChecked(cm_rb,FALSE); | ||
1432 | colorMenu->setItemChecked(cm_br,FALSE); | ||
1433 | colorMenu->setItemChecked(cm_wb,FALSE); | ||
1434 | colorMenu->setItemChecked(cm_bw,FALSE); | ||
1435 | colorMenu->setItemChecked(cm_gb,FALSE); | ||
1436 | |||
1437 | if(iD==cm_default) | ||
1438 | { // default default | ||
1439 | printf("default colors\n"); | ||
1440 | for (i = 0; i < TABLE_COLORS; i++) | ||
1441 | { | ||
799 | m_table[i].color = defaultCt[i].color; | 1442 | m_table[i].color = defaultCt[i].color; |
800 | if(i==1 || i == 11) | 1443 | if(i==1 || i == 11) |
801 | m_table[i].transparent=1; | 1444 | m_table[i].transparent=1; |
802 | cfg.writeEntry("Schema","9"); | 1445 | colorMenu->setItemChecked(cm_default,TRUE); |
803 | colorMenu->setItemChecked(-9,TRUE); | ||
804 | } | ||
805 | } else { | ||
806 | if(iD==-6) { // green black | ||
807 | foreground.setRgb(0x18,255,0x18); | ||
808 | background.setRgb(0x00,0x00,0x00); | ||
809 | cfg.writeEntry("Schema","6"); | ||
810 | colorMenu->setItemChecked(-6,TRUE); | ||
811 | } | ||
812 | if(iD==-7) { // black white | ||
813 | foreground.setRgb(0x00,0x00,0x00); | ||
814 | background.setRgb(0xFF,0xFF,0xFF); | ||
815 | cfg.writeEntry("Schema","7"); | ||
816 | colorMenu->setItemChecked(-7,TRUE); | ||
817 | } | ||
818 | if(iD==-8) { // white black | ||
819 | foreground.setRgb(0xFF,0xFF,0xFF); | ||
820 | background.setRgb(0x00,0x00,0x00); | ||
821 | cfg.writeEntry("Schema","8"); | ||
822 | colorMenu->setItemChecked(-8,TRUE); | ||
823 | } | ||
824 | if(iD==-10) {// Black, Red | ||
825 | foreground.setRgb(0x00,0x00,0x00); | ||
826 | background.setRgb(0xB2,0x18,0x18); | ||
827 | cfg.writeEntry("Schema","10"); | ||
828 | colorMenu->setItemChecked(-10,TRUE); | ||
829 | } | ||
830 | if(iD==-11) {// Red, Black | ||
831 | foreground.setRgb(230,31,31); //0xB2,0x18,0x18 | ||
832 | background.setRgb(0x00,0x00,0x00); | ||
833 | cfg.writeEntry("Schema","11"); | ||
834 | colorMenu->setItemChecked(-11,TRUE); | ||
835 | } | ||
836 | if(iD==-12) {// Green, Yellow - is ugly | ||
837 | // foreground.setRgb(0x18,0xB2,0x18); | ||
838 | foreground.setRgb(36,139,10); | ||
839 | // background.setRgb(0xB2,0x68,0x18); | ||
840 | background.setRgb(255,255,0); | ||
841 | cfg.writeEntry("Schema","12"); | ||
842 | colorMenu->setItemChecked(-12,TRUE); | ||
843 | } | ||
844 | if(iD==-13) {// Blue, Magenta | ||
845 | foreground.setRgb(0x18,0xB2,0xB2); | ||
846 | background.setRgb(0x18,0x18,0xB2); | ||
847 | cfg.writeEntry("Schema","13"); | ||
848 | colorMenu->setItemChecked(-13,TRUE); | ||
849 | } | ||
850 | if(iD==-14) {// Magenta, Blue | ||
851 | foreground.setRgb(0x18,0x18,0xB2); | ||
852 | background.setRgb(0x18,0xB2,0xB2); | ||
853 | cfg.writeEntry("Schema","14"); | ||
854 | colorMenu->setItemChecked(-14,TRUE); | ||
855 | } | ||
856 | if(iD==-15) {// Cyan, White | ||
857 | foreground.setRgb(0x18,0xB2,0xB2); | ||
858 | background.setRgb(0xFF,0xFF,0xFF); | ||
859 | cfg.writeEntry("Schema","15"); | ||
860 | colorMenu->setItemChecked(-15,TRUE); | ||
861 | } | ||
862 | if(iD==-16) {// White, Cyan | ||
863 | background.setRgb(0x18,0xB2,0xB2); | ||
864 | foreground.setRgb(0xFF,0xFF,0xFF); | ||
865 | cfg.writeEntry("Schema","16"); | ||
866 | colorMenu->setItemChecked(-16,TRUE); | ||
867 | } | ||
868 | if(iD==-17) {// Black, Blue | ||
869 | background.setRgb(0x00,0x00,0x00); | ||
870 | foreground.setRgb(0x18,0xB2,0xB2); | ||
871 | cfg.writeEntry("Schema","17"); | ||
872 | colorMenu->setItemChecked(-17,TRUE); | ||
873 | } | ||
874 | if(iD==-18) {// Black, Gold | ||
875 | background.setRgb(0x00,0x00,0x00); | ||
876 | foreground.setRgb(255,215,0); | ||
877 | cfg.writeEntry("Schema","18"); | ||
878 | colorMenu->setItemChecked(-18,TRUE); | ||
879 | } | 1446 | } |
1447 | te->setColorTable(m_table); | ||
1448 | } | ||
1449 | if(iD==cm_gb) | ||
1450 | { // green black | ||
1451 | foreground.setRgb(100,255,100); // (0x18,255,0x18); | ||
1452 | background.setRgb(0x00,0x00,0x00); | ||
1453 | colorMenu->setItemChecked(cm_gb,TRUE); | ||
1454 | } | ||
1455 | if(iD==cm_bw) | ||
1456 | { // black white | ||
1457 | foreground.setRgb(0x00,0x00,0x00); | ||
1458 | background.setRgb(0xFF,0xFF,0xFF); | ||
1459 | colorMenu->setItemChecked(cm_bw,TRUE); | ||
1460 | } | ||
1461 | if(iD==cm_wb) | ||
1462 | { // white black | ||
1463 | foreground.setRgb(0xFF,0xFF,0xFF); | ||
1464 | background.setRgb(0x00,0x00,0x00); | ||
1465 | colorMenu->setItemChecked(cm_wb,TRUE); | ||
1466 | } | ||
1467 | if(iD==cm_br) | ||
1468 | {// Black, Red | ||
1469 | foreground.setRgb(0x00,0x00,0x00); | ||
1470 | background.setRgb(255,85,85); //(0xB2,0x18,0x18); | ||
1471 | colorMenu->setItemChecked(cm_br,TRUE); | ||
1472 | } | ||
1473 | if(iD==cm_rb) | ||
1474 | {// Red, Black | ||
1475 | foreground.setRgb(255,85,85); | ||
1476 | background.setRgb(0x00,0x00,0x00); | ||
1477 | colorMenu->setItemChecked(cm_rb,TRUE); | ||
1478 | } | ||
1479 | if(iD==cm_gy) | ||
1480 | {// Green, Yellow - is ugly | ||
1481 | // foreground.setRgb(0x18,0xB2,0x18); | ||
1482 | foreground.setRgb(15,115,0); | ||
1483 | // background.setRgb(0xB2,0x68,0x18); | ||
1484 | background.setRgb(255,255,0); | ||
1485 | colorMenu->setItemChecked(cm_gy,TRUE); | ||
1486 | } | ||
1487 | if(iD==cm_bm) | ||
1488 | {// Blue, Magenta | ||
1489 | foreground.setRgb(3,24,132); | ||
1490 | background.setRgb(225,2,255); | ||
1491 | colorMenu->setItemChecked(cm_bm,TRUE); | ||
1492 | } | ||
1493 | if(iD==cm_mb) | ||
1494 | {// Magenta, Blue | ||
1495 | foreground.setRgb(225,2,255); | ||
1496 | background.setRgb(3,24,132); | ||
1497 | colorMenu->setItemChecked(cm_mb,TRUE); | ||
1498 | } | ||
1499 | if(iD==cm_cw) | ||
1500 | {// Cyan, White | ||
1501 | foreground.setRgb(8,91,129); | ||
1502 | background.setRgb(0xFF,0xFF,0xFF); | ||
1503 | colorMenu->setItemChecked(cm_cw,TRUE); | ||
1504 | } | ||
1505 | if(iD==cm_wc) | ||
1506 | {// White, Cyan | ||
1507 | background.setRgb(8,91,129); | ||
1508 | foreground.setRgb(0xFF,0xFF,0xFF); | ||
1509 | colorMenu->setItemChecked(cm_wc,TRUE); | ||
1510 | } | ||
1511 | if(iD==cm_bb) | ||
1512 | {// Black, Blue | ||
1513 | background.setRgb(0x00,0x00,0x00); | ||
1514 | foreground.setRgb(127,147,225); | ||
1515 | colorMenu->setItemChecked(cm_bb,TRUE); | ||
1516 | } | ||
1517 | if(iD==cm_ab) | ||
1518 | {// Black, Gold | ||
1519 | background.setRgb(0x00,0x00,0x00); | ||
1520 | foreground.setRgb(255,215,105); | ||
1521 | colorMenu->setItemChecked(cm_ab,TRUE); | ||
1522 | } | ||
880 | #ifdef QT_QWS_OPIE | 1523 | #ifdef QT_QWS_OPIE |
881 | if(iD==-19) { | 1524 | if(iD==-19) |
882 | // Custom | 1525 | { |
883 | qDebug("do custom"); | 1526 | // Custom |
884 | if(fromMenu) { | 1527 | qDebug("do custom"); |
1528 | if(fromMenu) | ||
1529 | { | ||
885 | OColorPopupMenu* penColorPopupMenu = new OColorPopupMenu(Qt::black, this, "foreground color"); | 1530 | OColorPopupMenu* penColorPopupMenu = new OColorPopupMenu(Qt::black, this, "foreground color"); |
886 | connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, | 1531 | connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, |
887 | SLOT(changeForegroundColor(const QColor&))); | 1532 | SLOT(changeForegroundColor(const QColor&))); |
888 | penColorPopupMenu->exec(); | 1533 | penColorPopupMenu->exec(); |
889 | } | ||
890 | cfg.writeEntry("Schema","19"); | ||
891 | if(!fromMenu) { | ||
892 | foreground.setNamedColor(cfg.readEntry("foreground","")); | ||
893 | background.setNamedColor(cfg.readEntry("background","")); | ||
894 | } | ||
895 | fromMenu=FALSE; | ||
896 | colorMenu->setItemChecked(-19,TRUE); | ||
897 | } | 1534 | } |
898 | #endif | 1535 | if(!fromMenu) |
899 | for (i = 0; i < TABLE_COLORS; i++) { | 1536 | { |
900 | if(i==0 || i == 10) { | 1537 | foreground.setNamedColor(cfg.readEntry("foreground","")); |
901 | m_table[i].color = foreground; | 1538 | background.setNamedColor(cfg.readEntry("background","")); |
902 | } | ||
903 | else if(i==1 || i == 11) { | ||
904 | m_table[i].color = background; m_table[i].transparent=0; | ||
905 | } | ||
906 | else | ||
907 | m_table[i].color = defaultCt[i].color; | ||
908 | } | 1539 | } |
1540 | fromMenu=FALSE; | ||
1541 | colorMenu->setItemChecked(-19,TRUE); | ||
909 | } | 1542 | } |
1543 | #endif | ||
1544 | |||
910 | lastSelectedMenu = iD; | 1545 | lastSelectedMenu = iD; |
911 | te->setColorTable(m_table); | 1546 | |
1547 | setColors(foreground, background); | ||
1548 | |||
1549 | QTabBar *tabBar = tab->getTabBar(); | ||
1550 | QString ss = QString("Session%1").arg(tabBar->currentTab()); | ||
1551 | // printf("current tab = %d\n", tabBar->currentTab()); | ||
1552 | |||
1553 | if (tabBar->currentTab() == 0) | ||
1554 | { | ||
1555 | cfg.writeEntry("foregroundRed",QString::number(foreground.red())); | ||
1556 | cfg.writeEntry("foregroundGreen",QString::number(foreground.green())); | ||
1557 | cfg.writeEntry("foregroundBlue",QString::number(foreground.blue())); | ||
1558 | cfg.writeEntry("backgroundRed",QString::number(background.red())); | ||
1559 | cfg.writeEntry("backgroundGreen",QString::number(background.green())); | ||
1560 | cfg.writeEntry("backgroundBlue",QString::number(background.blue())); | ||
1561 | } | ||
1562 | cfg.writeEntry("foregroundRed"+ss,QString::number(foreground.red())); | ||
1563 | cfg.writeEntry("foregroundGreen"+ss,QString::number(foreground.green())); | ||
1564 | cfg.writeEntry("foregroundBlue"+ss,QString::number(foreground.blue())); | ||
1565 | cfg.writeEntry("backgroundRed"+ss,QString::number(background.red())); | ||
1566 | cfg.writeEntry("backgroundGreen"+ss,QString::number(background.green())); | ||
1567 | cfg.writeEntry("backgroundBlue"+ss,QString::number(background.blue())); | ||
1568 | |||
912 | update(); | 1569 | update(); |
1570 | } | ||
913 | 1571 | ||
1572 | void Konsole::setColors(QColor foreground, QColor background) | ||
1573 | { | ||
1574 | int i; | ||
1575 | ColorEntry m_table[TABLE_COLORS]; | ||
1576 | TEWidget* te = getTe(); | ||
1577 | const ColorEntry * defaultCt=te->getdefaultColorTable(); | ||
1578 | |||
1579 | for (i = 0; i < TABLE_COLORS; i++) | ||
1580 | { | ||
1581 | if(i==0 || i == 10) | ||
1582 | { | ||
1583 | m_table[i].color = foreground; | ||
1584 | } | ||
1585 | else if(i==1 || i == 11) | ||
1586 | { | ||
1587 | m_table[i].color = background; | ||
1588 | m_table[i].transparent=0; | ||
1589 | } | ||
1590 | else | ||
1591 | m_table[i].color = defaultCt[i].color; | ||
1592 | } | ||
1593 | te->setColorTable(m_table); | ||
914 | } | 1594 | } |
915 | 1595 | ||
1596 | void Konsole::tabMenuSelected(int id) | ||
1597 | { | ||
1598 | Config cfg("Qkonsole"); | ||
1599 | cfg.setGroup("Tabs"); | ||
1600 | tabMenu->setItemChecked(tabPos, false); | ||
1601 | if (id == tm_bottom) | ||
1602 | { | ||
1603 | printf("set bottom tab\n"); | ||
1604 | tab->getTabBar()->show(); | ||
1605 | tab->setTabPosition(QTabWidget::Bottom); | ||
1606 | tab->getTabBar()->show(); | ||
1607 | cfg.writeEntry("Position","Bottom"); | ||
1608 | } | ||
1609 | else if (id == tm_top) | ||
1610 | { | ||
1611 | printf("set top tab\n"); | ||
1612 | tab->getTabBar()->show(); | ||
1613 | tab->setTabPosition(QTabWidget::Bottom); | ||
1614 | tab->setTabPosition(QTabWidget::Top); | ||
1615 | tab->getTabBar()->show(); | ||
1616 | cfg.writeEntry("Position","Top"); | ||
1617 | } | ||
1618 | else if (id == tm_hidden) | ||
1619 | { | ||
1620 | tab->getTabBar()->hide(); | ||
1621 | tab->setMargin(tab->margin()); | ||
1622 | cfg.writeEntry("Position","Hidden"); | ||
1623 | } | ||
1624 | tabMenu->setItemChecked(id, true); | ||
1625 | tabPos = id; | ||
1626 | } | ||
1627 | |||
1628 | |||
916 | void Konsole::configMenuSelected(int iD) | 1629 | void Konsole::configMenuSelected(int iD) |
917 | { | 1630 | { |
918 | // QString temp; | 1631 | // QString temp; |
919 | // qDebug( temp.sprintf("configmenu %d",iD)); | 1632 | // qDebug( temp.sprintf("configmenu %d",iD)); |
920 | 1633 | ||
921 | TEWidget* te = getTe(); | 1634 | TEWidget* te = getTe(); |
922 | Config cfg("Konsole"); | 1635 | Config cfg("Qkonsole"); |
923 | cfg.setGroup("Menubar"); | 1636 | cfg.setGroup("Menubar"); |
924 | int i,j; | 1637 | if(iD == cm_wrap) |
925 | #ifdef QT_QWS_OPIE | 1638 | { |
926 | i=-29;j=-30; | 1639 | cfg.setGroup("ScrollBar"); |
927 | #else | 1640 | bool b=cfg.readBoolEntry("HorzScroll",0); |
928 | i=-28;j=-29; | 1641 | b=!b; |
929 | #endif | 1642 | cfg.writeEntry("HorzScroll", b ); |
930 | 1643 | cfg.write(); | |
931 | if(iD == -4) { | 1644 | doWrap(); |
932 | cfg.setGroup("Tabs"); | 1645 | if(cfg.readNumEntry("Position",2) == 0) |
933 | QString tmp=cfg.readEntry("Position","Bottom"); | 1646 | { |
934 | 1647 | te->setScrollbarLocation(1); | |
935 | if(tmp=="Top") { | 1648 | } |
936 | tab->setTabPosition(QTabWidget::Bottom); | 1649 | else |
937 | configMenu->changeItem( iD, tr("Tabs on Top")); | 1650 | { |
938 | cfg.writeEntry("Position","Bottom"); | 1651 | te->setScrollbarLocation(0); |
939 | } else { | 1652 | } |
940 | tab->setTabPosition(QTabWidget::Top); | 1653 | te->setScrollbarLocation( cfg.readNumEntry("Position",2)); |
941 | configMenu->changeItem( iD, tr("Tabs on Bottom")); | 1654 | } |
942 | cfg.writeEntry("Position","Top"); | 1655 | if(iD == cm_beep) |
943 | } | 1656 | { |
944 | } | 1657 | cfg.setGroup("Menubar"); |
945 | if(iD == i) { | 1658 | bool b=cfg.readBoolEntry("useBeep",0); |
946 | cfg.setGroup("ScrollBar"); | 1659 | b=!b; |
947 | bool b=cfg.readBoolEntry("HorzScroll",0); | 1660 | cfg.writeEntry("useBeep", b ); |
948 | b=!b; | 1661 | cfg.write(); |
949 | cfg.writeEntry("HorzScroll", b ); | 1662 | configMenu->setItemChecked(cm_beep,b); |
950 | cfg.write(); | 1663 | te->useBeep=b; |
951 | doWrap(); | 1664 | } |
952 | if(cfg.readNumEntry("Position",2) == 0) { | ||
953 | te->setScrollbarLocation(1); | ||
954 | } else { | ||
955 | te->setScrollbarLocation(0); | ||
956 | } | ||
957 | te->setScrollbarLocation( cfg.readNumEntry("Position",2)); | ||
958 | } | ||
959 | if(iD == j) { | ||
960 | cfg.setGroup("Menubar"); | ||
961 | bool b=cfg.readBoolEntry("useBeep",0); | ||
962 | b=!b; | ||
963 | cfg.writeEntry("useBeep", b ); | ||
964 | cfg.write(); | ||
965 | configMenu->setItemChecked(j,b); | ||
966 | te->useBeep=b; | ||
967 | } | ||
968 | } | 1665 | } |
969 | 1666 | ||
970 | void Konsole::changeCommand(const QString &text, int c) | 1667 | void Konsole::changeCommand(const QString &text, int c) |
971 | { | 1668 | { |
972 | Config cfg("Konsole"); | 1669 | Config cfg("Qkonsole"); |
973 | cfg.setGroup("Commands"); | 1670 | cfg.setGroup("Commands"); |
974 | if(commonCmds[c] != text) { | 1671 | if(commonCmds[c] != text) |
1672 | { | ||
975 | cfg.writeEntry(QString::number(c),text); | 1673 | cfg.writeEntry(QString::number(c),text); |
976 | commonCombo->clearEdit(); | 1674 | commonCombo->clearEdit(); |
977 | commonCombo->setCurrentItem(c); | 1675 | commonCombo->setCurrentItem(c); |
978 | } | 1676 | } |
979 | } | 1677 | } |
980 | 1678 | ||
981 | void Konsole::setColor() | 1679 | void Konsole::setColor(int sess) |
982 | { | 1680 | { |
983 | Config cfg("Konsole"); | 1681 | Config cfg("Qkonsole"); |
984 | cfg.setGroup("Colors"); | 1682 | cfg.setGroup("Colors"); |
985 | int scheme = cfg.readNumEntry("Schema",1); | 1683 | QColor foreground, background; |
986 | if(scheme != 1) colorMenuSelected( -scheme); | 1684 | QString ss = QString("Session") + QString::number(sess); |
1685 | foreground.setRgb(cfg.readNumEntry("foregroundRed"+ss, | ||
1686 | cfg.readNumEntry("foregroundRed",0xff)), | ||
1687 | cfg.readNumEntry("foregroundGreen"+ss, | ||
1688 | cfg.readNumEntry("foregroundGreen",0xff)), | ||
1689 | cfg.readNumEntry("foregroundBlue"+ss, | ||
1690 | cfg.readNumEntry("foregroundBlue",0xff))); | ||
1691 | background.setRgb(cfg.readNumEntry("backgroundRed"+ss, | ||
1692 | cfg.readNumEntry("backgroundRed",0)), | ||
1693 | cfg.readNumEntry("backgroundGreen"+ss, | ||
1694 | cfg.readNumEntry("backgroundGreen",0)), | ||
1695 | cfg.readNumEntry("backgroundBlue"+ss, | ||
1696 | cfg.readNumEntry("backgroundBlue",0))); | ||
1697 | setColors(foreground, background); | ||
987 | } | 1698 | } |
988 | 1699 | ||
989 | void Konsole::scrollMenuSelected(int index) | 1700 | void Konsole::scrollMenuSelected(int index) |
990 | { | 1701 | { |
991 | // qDebug( "scrollbar menu %d",index); | 1702 | // qDebug( "scrollbar menu %d",index); |
992 | 1703 | ||
993 | TEWidget* te = getTe(); | 1704 | TEWidget* te = getTe(); |
994 | Config cfg("Konsole"); | 1705 | Config cfg("Qkonsole"); |
995 | cfg.setGroup("ScrollBar"); | 1706 | cfg.setGroup("ScrollBar"); |
996 | int i,j,k; | ||
997 | #ifdef QT_QWS_OPIE | ||
998 | i=-25;j=-26;k=-27; | ||
999 | #else | ||
1000 | i=-24;j=-25;k=-26; | ||
1001 | #endif | ||
1002 | if(index == i) { | ||
1003 | |||
1004 | te->setScrollbarLocation(0); | ||
1005 | cfg.writeEntry("Position",0); | ||
1006 | } else if(index == j) { | ||
1007 | |||
1008 | te->setScrollbarLocation(1); | ||
1009 | cfg.writeEntry("Position",1); | ||
1010 | } else if(index == k) { | ||
1011 | 1707 | ||
1012 | te->setScrollbarLocation(2); | 1708 | if(index == sm_none) |
1013 | cfg.writeEntry("Position",2); | 1709 | { |
1014 | } | 1710 | te->setScrollbarLocation(0); |
1711 | cfg.writeEntry("Position",0); | ||
1712 | } | ||
1713 | else if(index == sm_left) | ||
1714 | { | ||
1715 | te->setScrollbarLocation(1); | ||
1716 | cfg.writeEntry("Position",1); | ||
1717 | } | ||
1718 | else if(index == sm_right) | ||
1719 | { | ||
1720 | te->setScrollbarLocation(2); | ||
1721 | cfg.writeEntry("Position",2); | ||
1722 | } | ||
1723 | scrollMenu->setItemChecked(sm_none, index == sm_none); | ||
1724 | scrollMenu->setItemChecked(sm_left, index == sm_left); | ||
1725 | scrollMenu->setItemChecked(sm_right, index == sm_right); | ||
1726 | } | ||
1015 | 1727 | ||
1016 | // case -29: { | 1728 | // case -29: { |
1017 | // bool b=cfg.readBoolEntry("HorzScroll",0); | 1729 | // bool b=cfg.readBoolEntry("HorzScroll",0); |
1018 | // cfg.writeEntry("HorzScroll", !b ); | 1730 | // cfg.writeEntry("HorzScroll", !b ); |
1019 | // cfg.write(); | 1731 | // cfg.write(); |
1020 | // if(cfg.readNumEntry("Position",2) == 0) { | 1732 | // if(cfg.readNumEntry("Position",2) == 0) { |
1021 | // te->setScrollbarLocation(1); | 1733 | // te->setScrollbarLocation(1); |
1022 | // te->setWrapAt(0); | 1734 | // te->setWrapAt(0); |
1023 | // } else { | 1735 | // } else { |
1024 | // te->setScrollbarLocation(0); | 1736 | // te->setScrollbarLocation(0); |
1025 | // te->setWrapAt(120); | 1737 | // te->setWrapAt(120); |
1026 | // } | 1738 | // } |
1027 | // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); | 1739 | // te->setScrollbarLocation( cfg.readNumEntry("Position",2)); |
1028 | // } | 1740 | // } |
1029 | // break; | 1741 | // break; |
1030 | } | ||
1031 | 1742 | ||
1032 | void Konsole::editCommandListMenuSelected(int iD) | 1743 | void Konsole::editCommandListMenuSelected(int iD) |
1033 | { | 1744 | { |
1034 | // QString temp; | 1745 | // QString temp; |
1035 | // qDebug( temp.sprintf("edit command list %d",iD)); | 1746 | // qDebug( temp.sprintf("edit command list %d",iD)); |
1747 | |||
1748 | // FIXME: more cleanup needed here | ||
1749 | |||
1750 | |||
1036 | TEWidget* te = getTe(); | 1751 | TEWidget* te = getTe(); |
1037 | Config cfg("Konsole"); | 1752 | Config cfg("Qkonsole"); |
1038 | cfg.setGroup("Menubar"); | 1753 | cfg.setGroup("Menubar"); |
1039 | if( iD == -3) { | 1754 | if( iD == ec_cmdlist) |
1040 | if(!secondToolBar->isHidden()) { | 1755 | { |
1756 | if(!secondToolBar->isHidden()) | ||
1757 | { | ||
1041 | secondToolBar->hide(); | 1758 | secondToolBar->hide(); |
1042 | configMenu->changeItem( iD,tr( "Show Command List" )); | 1759 | configMenu->changeItem( iD,tr( "Show Command List" )); |
1043 | cfg.writeEntry("Hidden","TRUE"); | 1760 | cfg.writeEntry("Hidden","TRUE"); |
1044 | configMenu->setItemEnabled(-23 ,FALSE); | 1761 | configMenu->setItemEnabled(ec_edit ,FALSE); |
1045 | } else { | 1762 | configMenu->setItemEnabled(ec_quick ,FALSE); |
1763 | } | ||
1764 | else | ||
1765 | { | ||
1046 | secondToolBar->show(); | 1766 | secondToolBar->show(); |
1047 | configMenu->changeItem( iD,tr( "Hide Command List" )); | 1767 | configMenu->changeItem( iD,tr( "Hide Command List" )); |
1048 | cfg.writeEntry("Hidden","FALSE"); | 1768 | cfg.writeEntry("Hidden","FALSE"); |
1049 | configMenu->setItemEnabled(-23 ,TRUE); | 1769 | configMenu->setItemEnabled(ec_edit ,TRUE); |
1770 | configMenu->setItemEnabled(ec_quick ,TRUE); | ||
1050 | 1771 | ||
1051 | if(cfg.readEntry("EditEnabled","FALSE")=="TRUE") { | 1772 | if(cfg.readEntry("EditEnabled","FALSE")=="TRUE") |
1052 | configMenu->setItemChecked(-23,TRUE); | 1773 | { |
1774 | configMenu->setItemChecked(ec_edit,TRUE); | ||
1053 | commonCombo->setEditable( TRUE ); | 1775 | commonCombo->setEditable( TRUE ); |
1054 | } else { | 1776 | } |
1055 | configMenu->setItemChecked(-23,FALSE); | 1777 | else |
1778 | { | ||
1779 | configMenu->setItemChecked(ec_edit,FALSE); | ||
1056 | commonCombo->setEditable( FALSE ); | 1780 | commonCombo->setEditable( FALSE ); |
1057 | } | 1781 | } |
1058 | } | 1782 | } |
1059 | } | 1783 | } |
1060 | if( iD == -23) { | 1784 | if( iD == ec_quick) |
1785 | { | ||
1061 | cfg.setGroup("Commands"); | 1786 | cfg.setGroup("Commands"); |
1062 | // qDebug("enableCommandEdit"); | 1787 | // qDebug("enableCommandEdit"); |
1063 | if( !configMenu->isItemChecked(iD) ) { | 1788 | if( !configMenu->isItemChecked(iD) ) |
1789 | { | ||
1064 | commonCombo->setEditable( TRUE ); | 1790 | commonCombo->setEditable( TRUE ); |
1065 | configMenu->setItemChecked(iD,TRUE); | 1791 | configMenu->setItemChecked(iD,TRUE); |
1066 | commonCombo->setCurrentItem(0); | 1792 | commonCombo->setCurrentItem(0); |
1067 | cfg.writeEntry("EditEnabled","TRUE"); | 1793 | cfg.writeEntry("EditEnabled","TRUE"); |
1068 | } else { | 1794 | } |
1795 | else | ||
1796 | { | ||
1069 | commonCombo->setEditable( FALSE ); | 1797 | commonCombo->setEditable( FALSE ); |
1070 | configMenu->setItemChecked(iD,FALSE); | 1798 | configMenu->setItemChecked(iD,FALSE); |
1071 | cfg.writeEntry("EditEnabled","FALSE"); | 1799 | cfg.writeEntry("EditEnabled","FALSE"); |
1072 | commonCombo->setFocusPolicy(QWidget::NoFocus); | 1800 | commonCombo->setFocusPolicy(QWidget::NoFocus); |
1073 | te->setFocus(); | 1801 | te->setFocus(); |
1074 | } | 1802 | } |
1075 | } | 1803 | } |
1076 | if(iD == -24) { | 1804 | if(iD == ec_edit) |
1077 | // "edit commands" | 1805 | { |
1078 | CommandEditDialog *m = new CommandEditDialog(this); | 1806 | // "edit commands" |
1079 | connect(m,SIGNAL(commandsEdited()),this,SLOT(initCommandList())); | 1807 | CommandEditDialog *m = new CommandEditDialog(this); |
1080 | QPEApplication::showDialog( m ); | 1808 | connect(m,SIGNAL(commandsEdited()),this,SLOT(initCommandList())); |
1809 | m->showMaximized(); | ||
1081 | } | 1810 | } |
1082 | 1811 | ||
1083 | } | 1812 | } |
1084 | 1813 | ||
1085 | // $QPEDIR/bin/qcop QPE/Application/embeddedkonsole 'setDocument(QString)' 'ssh -V' | 1814 | // $QPEDIR/bin/qcop QPE/Application/embeddedkonsole 'setDocument(QString)' 'ssh -V' |
1086 | void Konsole::setDocument( const QString &cmd) { | 1815 | void Konsole::setDocument( const QString &cmd) |
1816 | { | ||
1087 | newSession(); | 1817 | newSession(); |
1088 | TEWidget* te = getTe(); | 1818 | TEWidget* te = getTe(); |
1089 | if(cmd.find("-e", 0, TRUE) != -1) { | 1819 | if(cmd.find("-e", 0, TRUE) != -1) |
1820 | { | ||
1090 | QString cmd2; | 1821 | QString cmd2; |
1091 | cmd2=cmd.right(cmd.length()-3)+" &"; | 1822 | cmd2=cmd.right(cmd.length()-3)+" &"; |
1092 | system(cmd2.latin1()); | 1823 | system(cmd2.latin1()); |
1093 | if(startUp <= 1 && nsessions < 2) { | 1824 | if(startUp <= 1 && nsessions < 2) |
1094 | doneSession(getTe()->currentSession, 0); | 1825 | { |
1826 | doneSession(getTe(), 0); | ||
1095 | exit(0); | 1827 | exit(0); |
1096 | } else | 1828 | } |
1097 | doneSession(getTe()->currentSession, 0); | 1829 | else |
1098 | } else { | 1830 | doneSession(getTe(), 0); |
1099 | if (te != 0) { | 1831 | } |
1832 | else | ||
1833 | { | ||
1834 | if (te != 0) | ||
1835 | { | ||
1100 | te->emitText(cmd+"\r"); | 1836 | te->emitText(cmd+"\r"); |
1101 | } | 1837 | } |
1102 | } | 1838 | } |
1103 | startUp++; | 1839 | startUp++; |
1104 | } | 1840 | } |
1105 | 1841 | ||
1106 | void Konsole::parseCommandLine() { | 1842 | |
1843 | // what is the point of this when you can just | ||
1844 | // run commands by using the shell directly?? | ||
1845 | void Konsole::parseCommandLine() | ||
1846 | { | ||
1107 | QString cmd; | 1847 | QString cmd; |
1108 | // newSession(); | 1848 | // newSession(); |
1109 | for (int i=1;i< qApp->argc();i++) { | 1849 | for (int i=1;i< qApp->argc();i++) |
1110 | if( QString(qApp->argv()[i]) == "-e") { | 1850 | { |
1851 | if( QString(qApp->argv()[i]) == "-e") | ||
1852 | { | ||
1111 | i++; | 1853 | i++; |
1112 | for ( int j=i;j< qApp->argc();j++) { | 1854 | for ( int j=i;j< qApp->argc();j++) |
1855 | { | ||
1113 | cmd+=QString(qApp->argv()[j])+" "; | 1856 | cmd+=QString(qApp->argv()[j])+" "; |
1114 | } | 1857 | } |
1115 | cmd.stripWhiteSpace(); | 1858 | cmd.stripWhiteSpace(); |
1116 | system(cmd.latin1()); | 1859 | system(cmd.latin1()); |
1117 | exit(0);//close(); | 1860 | exit(0);//close(); |
1118 | } // end -e switch | 1861 | } // end -e switch |
1119 | } | 1862 | } |
1120 | startUp++; | 1863 | startUp++; |
1121 | } | 1864 | } |
1122 | 1865 | ||
1123 | void Konsole::changeForegroundColor(const QColor &color) { | 1866 | void Konsole::changeForegroundColor(const QColor &color) |
1124 | Config cfg("Konsole"); | 1867 | { |
1868 | Config cfg("Qkonsole"); | ||
1125 | cfg.setGroup("Colors"); | 1869 | cfg.setGroup("Colors"); |
1126 | int r, g, b; | 1870 | int r, g, b; |
1127 | color.rgb(&r,&g,&b); | 1871 | color.rgb(&r,&g,&b); |
1128 | foreground.setRgb(r,g,b); | 1872 | foreground.setRgb(r,g,b); |
1129 | 1873 | ||
1130 | cfg.writeEntry("foreground",color.name()); | 1874 | cfg.writeEntry("foreground",color.name()); |
1131 | qDebug("foreground "+color.name()); | 1875 | qDebug("foreground "+color.name()); |
1132 | cfg.write(); | 1876 | cfg.write(); |
1133 | 1877 | ||
1134 | qDebug("do other dialog"); | 1878 | qDebug("do other dialog"); |
1135 | #ifdef QT_QWS_OPIE | 1879 | #ifdef QT_QWS_OPIE |
1136 | 1880 | ||
1137 | OColorPopupMenu* penColorPopupMenu2 = new OColorPopupMenu(Qt::black, this,"background color"); | 1881 | OColorPopupMenu* penColorPopupMenu2 = new OColorPopupMenu(Qt::black, this,"background color"); |
1138 | connect(penColorPopupMenu2, SIGNAL(colorSelected(const QColor&)), this, | 1882 | connect(penColorPopupMenu2, SIGNAL(colorSelected(const QColor&)), this, |
1139 | SLOT(changeBackgroundColor(const QColor&))); | 1883 | SLOT(changeBackgroundColor(const QColor&))); |
1140 | penColorPopupMenu2->exec(); | 1884 | penColorPopupMenu2->exec(); |
1141 | #endif | 1885 | #endif |
1142 | } | 1886 | } |
1143 | 1887 | ||
1144 | void Konsole::changeBackgroundColor(const QColor &color) { | 1888 | void Konsole::changeBackgroundColor(const QColor &color) |
1889 | { | ||
1145 | 1890 | ||
1146 | qDebug("Change background"); | 1891 | qDebug("Change background"); |
1147 | Config cfg("Konsole"); | 1892 | Config cfg("Qkonsole"); |
1148 | cfg.setGroup("Colors"); | 1893 | cfg.setGroup("Colors"); |
1149 | int r, g, b; | 1894 | int r, g, b; |
1150 | color.rgb(&r,&g,&b); | 1895 | color.rgb(&r,&g,&b); |
1151 | background.setRgb(r,g,b); | 1896 | background.setRgb(r,g,b); |
1152 | cfg.writeEntry("background",color.name()); | 1897 | cfg.writeEntry("background",color.name()); |
1153 | qDebug("background "+color.name()); | 1898 | qDebug("background "+color.name()); |
1154 | cfg.write(); | 1899 | cfg.write(); |
1155 | } | 1900 | } |
1156 | 1901 | ||
1157 | void Konsole::doWrap() { | 1902 | void Konsole::doWrap() |
1158 | int i; | 1903 | { |
1159 | #ifdef QT_QWS_OPIE | 1904 | Config cfg("Qkonsole"); |
1160 | i=-29; | ||
1161 | #else | ||
1162 | i=-28; | ||
1163 | #endif | ||
1164 | |||
1165 | Config cfg("Konsole"); | ||
1166 | cfg.setGroup("ScrollBar"); | 1905 | cfg.setGroup("ScrollBar"); |
1167 | TEWidget* te = getTe(); | 1906 | TEWidget* te = getTe(); |
1168 | if( !cfg.readBoolEntry("HorzScroll",0)) { | 1907 | if( !cfg.readBoolEntry("HorzScroll",0)) |
1908 | { | ||
1169 | te->setWrapAt(0); | 1909 | te->setWrapAt(0); |
1170 | configMenu->setItemChecked( i,TRUE); | 1910 | configMenu->setItemChecked( cm_wrap,TRUE); |
1171 | } else { | 1911 | } |
1172 | // te->setWrapAt(90); | 1912 | else |
1913 | { | ||
1914 | // te->setWrapAt(90); | ||
1173 | te->setWrapAt(120); | 1915 | te->setWrapAt(120); |
1174 | configMenu->setItemChecked( i,FALSE); | 1916 | configMenu->setItemChecked( cm_wrap,FALSE); |
1175 | } | 1917 | } |
1176 | } | 1918 | } |
diff --git a/core/apps/embeddedkonsole/konsole.h b/core/apps/embeddedkonsole/konsole.h index 7d5a908..37babbb 100644 --- a/core/apps/embeddedkonsole/konsole.h +++ b/core/apps/embeddedkonsole/konsole.h | |||
@@ -41,104 +41,166 @@ | |||
41 | 41 | ||
42 | class EKNumTabWidget; | 42 | class EKNumTabWidget; |
43 | 43 | ||
44 | class Konsole : public QMainWindow | 44 | class Konsole : public QMainWindow |
45 | { | 45 | { |
46 | Q_OBJECT | 46 | Q_OBJECT |
47 | 47 | ||
48 | public: | 48 | public: |
49 | static QString appName() { return QString::fromLatin1("embeddedkonsole"); } | 49 | |
50 | 50 | static QString appName() | |
51 | Konsole(QWidget* parent = 0, const char* name = 0, WFlags fl = 0); | 51 | { |
52 | ~Konsole(); | 52 | return QString::fromLatin1("embeddedkonsole"); |
53 | void setColLin(int columns, int lines); | 53 | } |
54 | QToolBar *secondToolBar; | 54 | |
55 | void show(); | 55 | Konsole(QWidget* parent = 0, const char* name = 0, WFlags fl = 0); |
56 | void setColor(); | 56 | Konsole(const char * name, const char* pgm, QStrList & _args, int histon); |
57 | int lastSelectedMenu; | 57 | ~Konsole(); |
58 | int startUp; | 58 | void setColLin(int columns, int lines); |
59 | QToolBar *secondToolBar; | ||
60 | void show(); | ||
61 | void setColor(int); | ||
62 | int lastSelectedMenu; | ||
63 | int startUp; | ||
64 | |||
65 | public slots: | ||
66 | void changeFontSize(int); | ||
67 | void toggleFullScreen(); | ||
68 | void setFullScreen(bool); | ||
69 | void changeSession(int); | ||
70 | void cycleZoom(); | ||
71 | void newSession(); | ||
72 | |||
59 | private slots: | 73 | private slots: |
60 | void setDocument(const QString &); | 74 | void setDocument(const QString &); |
61 | void doneSession(TESession*,int); | 75 | void doneSession(TEWidget*,int); |
62 | void changeColumns(int); | 76 | void changeTitle(TEWidget*,QString); |
63 | void fontChanged(int); | 77 | void changeColumns(int); |
64 | void configMenuSelected(int ); | 78 | void setFont(int); |
65 | void colorMenuSelected(int); | 79 | // void fontChanged(int); |
66 | void colorMenuIsSelected(int); | 80 | void configMenuSelected(int ); |
67 | void enterCommand(int); | 81 | void colorMenuSelected(int); |
68 | void hitEnter(); | 82 | void colorMenuIsSelected(int); |
69 | void hitSpace(); | 83 | void tabMenuSelected(int); |
70 | void hitTab(); | 84 | void sessionListSelected(int); |
71 | void hitPaste(); | 85 | |
72 | void hitUp(); | 86 | void enterCommand(int); |
73 | void hitDown(); | 87 | void hitEnter(); |
74 | void switchSession(QWidget *); | 88 | void hitSpace(); |
75 | void newSession(); | 89 | void hitTab(); |
76 | void changeCommand(const QString &, int); | 90 | void hitPaste(); |
77 | void initCommandList(); | 91 | void hitUp(); |
78 | void scrollMenuSelected(int); | 92 | void hitDown(); |
79 | void editCommandListMenuSelected(int); | 93 | void switchSession(QWidget *); |
80 | void parseCommandLine(); | 94 | void changeCommand(const QString &, int); |
95 | void initCommandList(); | ||
96 | void scrollMenuSelected(int); | ||
97 | void editCommandListMenuSelected(int); | ||
98 | void parseCommandLine(); | ||
81 | void changeForegroundColor(const QColor &); | 99 | void changeForegroundColor(const QColor &); |
82 | void changeBackgroundColor(const QColor &); | 100 | void changeBackgroundColor(const QColor &); |
101 | |||
102 | void historyDialog(); | ||
103 | void fullscreenTimeout(); | ||
104 | |||
83 | private: | 105 | private: |
84 | void doWrap(); | 106 | void doWrap(); |
85 | void init(const char* _pgm, QStrList & _args); | 107 | void init(const char* _pgm, QStrList & _args); |
86 | void initSession(const char* _pgm, QStrList & _args); | 108 | void initSession(const char* _pgm, QStrList & _args); |
87 | void runSession(TESession* s); | 109 | void runSession(TESession* s); |
88 | void setColorPixmaps(); | 110 | void setColorPixmaps(); |
89 | void setHistory(bool); | 111 | void setHistory(bool); |
90 | QSize calcSize(int columns, int lines); | 112 | void setColors(QColor foreground, QColor background); |
91 | TEWidget* getTe(); | 113 | int findFont(QString name, int size, bool exact = false); |
92 | QStringList commands; | 114 | QSize calcSize(int columns, int lines); |
93 | QLabel * msgLabel; | 115 | TEWidget* getTe(); |
94 | QColor foreground, background; | 116 | QStringList commands; |
95 | bool fromMenu; | 117 | QLabel * msgLabel; |
96 | private: | 118 | QColor foreground, background; |
97 | class VTFont | 119 | bool fromMenu; |
98 | { | 120 | |
99 | public: | 121 | bool fullscreen; |
100 | VTFont(QString name, QFont& font) | ||
101 | { | ||
102 | this->name = name; | ||
103 | this->font = font; | ||
104 | } | ||
105 | |||
106 | QFont& getFont() | ||
107 | { | ||
108 | return font; | ||
109 | } | ||
110 | 122 | ||
111 | QString getName() | 123 | private: |
124 | class VTFont | ||
112 | { | 125 | { |
113 | return name; | 126 | public: |
114 | } | 127 | VTFont(QString name, QFont& font, QString family, int familyNum, int size) |
115 | 128 | { | |
116 | private: | 129 | this->name = name; |
117 | QString name; | 130 | this->font = font; |
118 | QFont font; | 131 | this->family = family; |
119 | }; | 132 | this->size = size; |
133 | this->familyNum = familyNum; | ||
134 | } | ||
135 | |||
136 | QFont& getFont() | ||
137 | { | ||
138 | return font; | ||
139 | } | ||
140 | QString getName() | ||
141 | { | ||
142 | return name; | ||
143 | } | ||
144 | int getSize() | ||
145 | { | ||
146 | return(size); | ||
147 | } | ||
148 | QString getFamily() | ||
149 | { | ||
150 | return(family); | ||
151 | } | ||
152 | int getFamilyNum() | ||
153 | { | ||
154 | return(familyNum); | ||
155 | } | ||
156 | |||
157 | private: | ||
158 | QFont font; | ||
159 | QString name; | ||
160 | QString family; | ||
161 | int familyNum; | ||
162 | int size; | ||
163 | }; | ||
164 | |||
165 | EKNumTabWidget* tab; | ||
166 | int tabPos; | ||
167 | int nsessions; | ||
168 | QList<VTFont> fonts; | ||
169 | int cfont; | ||
170 | QCString se_pgm; | ||
171 | QStrList se_args; | ||
172 | |||
173 | QToolBar *menuToolBar; | ||
174 | QToolBar *toolBar; | ||
175 | QComboBox *commonCombo; | ||
176 | |||
177 | QPopupMenu *fontList,*configMenu,*colorMenu,*scrollMenu,*editCommandListMenu; | ||
178 | QPopupMenu *sessionList, *tabMenu; | ||
179 | |||
180 | int sm_none, sm_left, sm_right; | ||
181 | int cm_beep, cm_wrap; | ||
182 | int cm_default; | ||
183 | int cm_bw, cm_wb, cm_gb, cm_bt, cm_br, cm_rb, cm_gy, cm_bm, cm_mb, cm_cw, cm_wc, cm_bb, cm_ab; | ||
184 | int tm_top, tm_bottom, tm_hidden; | ||
185 | int ec_edit, ec_cmdlist, ec_quick; | ||
186 | |||
187 | bool show_fullscreen_msg; | ||
188 | QTimer *fullscreen_timer; | ||
189 | QLabel *fullscreen_msg; | ||
120 | 190 | ||
121 | EKNumTabWidget* tab; | ||
122 | int nsessions; | ||
123 | QList<VTFont> fonts; | ||
124 | int cfont; | ||
125 | QCString se_pgm; | ||
126 | QStrList se_args; | ||
127 | 191 | ||
128 | QPopupMenu *fontList,*configMenu,*colorMenu,*scrollMenu,*editCommandListMenu; | ||
129 | QComboBox *commonCombo; | ||
130 | // history scrolling I think | 192 | // history scrolling I think |
131 | bool b_scroll; | 193 | bool b_scroll; |
132 | 194 | ||
133 | int n_keytab; | 195 | int n_keytab; |
134 | int n_scroll; | 196 | int n_scroll; |
135 | int n_render; | 197 | int n_render; |
136 | QString pmPath; // pixmap path | 198 | QString pmPath; // pixmap path |
137 | QString dropText; | 199 | QString dropText; |
138 | QFont defaultFont; | 200 | QFont defaultFont; |
139 | QSize defaultSize; | 201 | QSize defaultSize; |
140 | 202 | ||
141 | }; | 203 | }; |
142 | 204 | ||
143 | #endif | 205 | #endif |
144 | 206 | ||
diff --git a/core/apps/embeddedkonsole/main.cpp b/core/apps/embeddedkonsole/main.cpp index f77fe24..a6a079c 100644 --- a/core/apps/embeddedkonsole/main.cpp +++ b/core/apps/embeddedkonsole/main.cpp | |||
@@ -31,8 +31,9 @@ | |||
31 | #include <stdlib.h> | 31 | #include <stdlib.h> |
32 | 32 | ||
33 | #include <pwd.h> | 33 | #include <pwd.h> |
34 | #include <sys/types.h> | 34 | #include <sys/types.h> |
35 | 35 | ||
36 | 36 | ||
37 | /* --| main |------------------------------------------------------ */ | 37 | /* --| main |------------------------------------------------------ */ |
38 | OPIE_EXPORT_APP( OApplicationFactory<Konsole> ) | 38 | OPIE_EXPORT_APP( OApplicationFactory<Konsole> ) |
39 | |||
diff --git a/core/apps/embeddedkonsole/session.cpp b/core/apps/embeddedkonsole/session.cpp index 520af86..17acb8c 100644 --- a/core/apps/embeddedkonsole/session.cpp +++ b/core/apps/embeddedkonsole/session.cpp | |||
@@ -18,24 +18,25 @@ | |||
18 | Sessions are combinations of TEPTy and Emulations. | 18 | Sessions are combinations of TEPTy and Emulations. |
19 | 19 | ||
20 | The stuff in here does not belong to the terminal emulation framework, | 20 | The stuff in here does not belong to the terminal emulation framework, |
21 | but to main.C. It serves it's duty by providing a single reference | 21 | but to main.C. It serves it's duty by providing a single reference |
22 | to TEPTy/Emulation pairs. In fact, it is only there to demonstrate one | 22 | to TEPTy/Emulation pairs. In fact, it is only there to demonstrate one |
23 | of the abilities of the framework - multible sessions. | 23 | of the abilities of the framework - multible sessions. |
24 | */ | 24 | */ |
25 | 25 | ||
26 | TESession::TESession(QMainWindow* main, TEWidget* te, const char* _pgm, QStrList & _args, const char *_term) : schema_no(0), font_no(3), pgm(_pgm), args(_args) | 26 | TESession::TESession(QMainWindow* main, TEWidget* _te, const char* _pgm, QStrList & _args, const char *_term) : schema_no(0), font_no(3), pgm(_pgm), args(_args) |
27 | { | 27 | { |
28 | te = _te; | ||
29 | term = _term; | ||
30 | |||
28 | // sh = new TEPty(); | 31 | // sh = new TEPty(); |
29 | sh = new MyPty(); | 32 | sh = new MyPty(); |
30 | em = new TEmuVt102(te); | 33 | em = new TEmuVt102(te); |
31 | 34 | ||
32 | term = _term; | ||
33 | |||
34 | sh->setSize(te->Lines(),te->Columns()); // not absolutely nessesary | 35 | sh->setSize(te->Lines(),te->Columns()); // not absolutely nessesary |
35 | QObject::connect( sh,SIGNAL(block_in(const char*,int)), | 36 | QObject::connect( sh,SIGNAL(block_in(const char*,int)), |
36 | em,SLOT(onRcvBlock(const char*,int)) ); | 37 | em,SLOT(onRcvBlock(const char*,int)) ); |
37 | QObject::connect( em,SIGNAL(ImageSizeChanged(int,int)), | 38 | QObject::connect( em,SIGNAL(ImageSizeChanged(int,int)), |
38 | sh,SLOT(setSize(int,int))); | 39 | sh,SLOT(setSize(int,int))); |
39 | 40 | ||
40 | // 'main' should do those connects itself, somehow. | 41 | // 'main' should do those connects itself, somehow. |
41 | // These aren't KTMW's slots, but konsole's.(David) | 42 | // These aren't KTMW's slots, but konsole's.(David) |
@@ -43,20 +44,22 @@ TESession::TESession(QMainWindow* main, TEWidget* te, const char* _pgm, QStrList | |||
43 | /* | 44 | /* |
44 | QObject::connect( em,SIGNAL(ImageSizeChanged(int,int)), | 45 | QObject::connect( em,SIGNAL(ImageSizeChanged(int,int)), |
45 | main,SLOT(notifySize(int,int))); | 46 | main,SLOT(notifySize(int,int))); |
46 | */ | 47 | */ |
47 | QObject::connect( em,SIGNAL(sndBlock(const char*,int)), | 48 | QObject::connect( em,SIGNAL(sndBlock(const char*,int)), |
48 | sh,SLOT(send_bytes(const char*,int)) ); | 49 | sh,SLOT(send_bytes(const char*,int)) ); |
49 | QObject::connect( em,SIGNAL(changeColumns(int)), | 50 | QObject::connect( em,SIGNAL(changeColumns(int)), |
50 | main,SLOT(changeColumns(int)) ); | 51 | main,SLOT(changeColumns(int)) ); |
51 | /* | 52 | |
53 | |||
54 | |||
52 | QObject::connect( em,SIGNAL(changeTitle(int, const QString&)), | 55 | QObject::connect( em,SIGNAL(changeTitle(int, const QString&)), |
53 | main,SLOT(changeTitle(int, const QString&)) ); | 56 | this,SLOT(changeTitle(int, const QString&)) ); |
54 | */ | 57 | |
55 | QObject::connect( sh,SIGNAL(done(int)), this,SLOT(done(int)) ); | 58 | QObject::connect( sh,SIGNAL(done(int)), this,SLOT(done(int)) ); |
56 | } | 59 | } |
57 | 60 | ||
58 | 61 | ||
59 | 62 | ||
60 | void TESession::run() | 63 | void TESession::run() |
61 | { | 64 | { |
62 | //kdDebug() << "Running the session!" << pgm << "\n"; | 65 | //kdDebug() << "Running the session!" << pgm << "\n"; |
@@ -78,17 +81,17 @@ TESession::~TESession() | |||
78 | 81 | ||
79 | void TESession::setConnect(bool c) | 82 | void TESession::setConnect(bool c) |
80 | { | 83 | { |
81 | em->setConnect(c); | 84 | em->setConnect(c); |
82 | } | 85 | } |
83 | 86 | ||
84 | void TESession::done(int status) | 87 | void TESession::done(int status) |
85 | { | 88 | { |
86 | emit done(this,status); | 89 | emit done(te,status); |
87 | } | 90 | } |
88 | 91 | ||
89 | void TESession::terminate() | 92 | void TESession::terminate() |
90 | { | 93 | { |
91 | delete this; | 94 | delete this; |
92 | } | 95 | } |
93 | 96 | ||
94 | TEmulation* TESession::getEmulation() | 97 | TEmulation* TESession::getEmulation() |
@@ -129,19 +132,20 @@ void TESession::setKeymapNo(int kn) | |||
129 | em->setKeytrans(kn); | 132 | em->setKeytrans(kn); |
130 | } | 133 | } |
131 | 134 | ||
132 | void TESession::setFontNo(int fn) | 135 | void TESession::setFontNo(int fn) |
133 | { | 136 | { |
134 | font_no = fn; | 137 | font_no = fn; |
135 | } | 138 | } |
136 | 139 | ||
137 | void TESession::setTitle(const QString& title) | 140 | void TESession::changeTitle(int, const QString& title) |
138 | { | 141 | { |
139 | this->title = title; | 142 | this->title = title; |
143 | emit changeTitle(te, title); | ||
140 | } | 144 | } |
141 | 145 | ||
142 | const QString& TESession::Title() | 146 | const QString& TESession::Title() |
143 | { | 147 | { |
144 | return title; | 148 | return title; |
145 | } | 149 | } |
146 | 150 | ||
147 | void TESession::setHistory(bool on) | 151 | void TESession::setHistory(bool on) |
diff --git a/core/apps/embeddedkonsole/session.h b/core/apps/embeddedkonsole/session.h index 4a61569..f399e96 100644 --- a/core/apps/embeddedkonsole/session.h +++ b/core/apps/embeddedkonsole/session.h | |||
@@ -51,28 +51,29 @@ public: | |||
51 | const QString& Title(); | 51 | const QString& Title(); |
52 | bool history(); | 52 | bool history(); |
53 | int keymap(); | 53 | int keymap(); |
54 | 54 | ||
55 | void setHistory(bool on); | 55 | void setHistory(bool on); |
56 | void setSchemaNo(int sn); | 56 | void setSchemaNo(int sn); |
57 | void setKeymapNo(int kn); | 57 | void setKeymapNo(int kn); |
58 | void setFontNo(int fn); | 58 | void setFontNo(int fn); |
59 | void setTitle(const QString& title); | ||
60 | void kill(int signal); | 59 | void kill(int signal); |
61 | 60 | ||
62 | public slots: | 61 | public slots: |
63 | 62 | ||
64 | void run(); | 63 | void run(); |
65 | void done(int status); | 64 | void done(int status); |
66 | void terminate(); | 65 | void terminate(); |
66 | void changeTitle(int, const QString& title); | ||
67 | 67 | ||
68 | signals: | 68 | signals: |
69 | 69 | ||
70 | void done(TESession*, int); | 70 | void done(TEWidget*, int); |
71 | void changeTitle(TEWidget*, QString); | ||
71 | 72 | ||
72 | private: | 73 | private: |
73 | 74 | ||
74 | // TEPty* sh; | 75 | // TEPty* sh; |
75 | MyPty* sh; | 76 | MyPty* sh; |
76 | TEWidget* te; | 77 | TEWidget* te; |
77 | TEmulation* em; | 78 | TEmulation* em; |
78 | 79 | ||