Skip to content

Commit b193c80

Browse files
authored
API documentation and naming convention (#395)
* added api documentation * api consistency improvement * fixed documentation typos * added pull request template
1 parent 5e8c038 commit b193c80

File tree

4 files changed

+282
-13
lines changed

4 files changed

+282
-13
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<!--- If this pull request is related to a change in the API, please --->
2+
<!--- remember to update the documentation accordingly in README.md --->
3+

README.md

Lines changed: 267 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
A terminal emulator widget for Qt 5.
66

77
QTermWidget is an open-source project originally based on the KDE4 Konsole application, but it took its own direction later on.
8-
The main goal of this project is to provide a unicode-enabled, embeddable Qt widget for using as a built-in console (or terminal emulation widget).
8+
The main goal of this project is to provide a Unicode-enabled, embeddable Qt widget for using as a built-in console (or terminal emulation widget).
99

1010
It is compatible with BSD, Linux and OS X.
1111

@@ -78,3 +78,269 @@ Translations can be done in [LXQt-Weblate](https://translate.lxqt-project.org/pr
7878
<img src="https://translate.lxqt-project.org/widgets/lxqt-desktop/-/qtermwidget/multi-auto.svg" alt="Translation status" />
7979
</a>
8080

81+
## API
82+
### Public Types
83+
Type | Variable
84+
| ---: | :---
85+
enum | ScrollBarPosition { NoScrollBar, ScrollBarLeft, ScrollBarRight }
86+
enum | KeyboardCursorShape { BlockCursor, UnderlineCursor, IBeamCursor }
87+
88+
### Properties
89+
* flowControlEnabled : bool
90+
* getPtySlaveFd : const int
91+
* getShellPID : int
92+
* getTerminalFont : QFont
93+
* historyLinesCount : int
94+
* icon : const QString
95+
* keyBindings : QString
96+
* screenColumnsCount : int
97+
* selectedText(bool _preserveLineBreaks_ = true) : QString
98+
* sizeHint : const QSize
99+
* terminalSizeHint : bool
100+
* title : const QString
101+
* workingDirectory : QString
102+
103+
### Public Functions
104+
Type | Function
105+
| ---: | :---
106+
| | QTermWidget(int _startnow_ = 1, QWidget *_parent_ = 0)
107+
virtual | ~QTermWidget()
108+
void | changeDir(const QString _&dir_)
109+
void | getSelectionEnd(int &_row_, int &_column_)
110+
void | getSelectionStart(int &_row_, int &_column_)
111+
void | scrollToEnd()
112+
void | sendText(QString &_text_)
113+
void | setArgs(QStringList &_args_)
114+
void | setAutoClose(bool _enabled_)
115+
void | setColorScheme(const QString &_name_)
116+
void | setEnvironment(const QStringList &_environment_)
117+
void | setFlowControlEnabled(bool _enabled_)
118+
void | setFlowControlWarningEnabled(bool _enabled_)
119+
void | setHistorySize(int _lines_)
120+
void | setKeyboardCursorShape(QTermWidget::KeyboardCursorShape _shape_)
121+
void | setMonitorActivity(bool _enabled_)
122+
void | setMonitorSilence(bool _enabled_)
123+
void | setMotionAfterPasting(int _action_)
124+
void | setScrollBarPosition(QTermWidget::ScrollBarPosition _pos_)
125+
void | setSelectionEnd(int _row_, int _column_)
126+
void | setSelectionStart(int _row_, int _column_)
127+
void | setShellProgram(const QString &_program_)
128+
void | setSilenceTimeout(int _seconds_)
129+
void | setTerminalFont(QFont &_font_)
130+
void | setTerminalOpacity(qreal _level_)
131+
void | setTerminalSizeHint(bool _enabled_)
132+
void | setTextCodec(QTextCodec *_codec_)
133+
void | setWorkingDirectory(const QString &_dir_)
134+
void | startShellProgram()
135+
void | startTerminalTeletype()
136+
137+
### Public Slots
138+
Type | Function
139+
| ---: | :---
140+
void | copyClipboard()
141+
void | pasteClipboard()
142+
void | pasteSelection()
143+
void | zoomIn()
144+
void | zoomOut()
145+
void | setSize(_const QSize &_)
146+
void | setKeyBindings(const QString &_kb_)
147+
void | clear()
148+
void | toggleShowSearchBar()
149+
150+
### Signals
151+
Type | Function
152+
| ---: | :---
153+
void | activity()
154+
void | bell(const QString &_message_)
155+
void | copyAvailable(bool)
156+
void | finished()
157+
void | profileChanged(const QString &_profile_)
158+
void | receivedData(const QString &_text_)
159+
void | sendData(const char*, int)
160+
void | silence()
161+
void | termGetFocus()
162+
void | termKeyPressed(QKeyEvent*)
163+
void | termLostFocus()
164+
void | titleChanged()
165+
void | urlActivated(const QUrl &, bool _fromContextMenu_)
166+
167+
### Static Public Members
168+
Type | Function
169+
| ---: | :---
170+
static QStringList | availableColorSchemes()
171+
static QStringList | availableKeyBindings()
172+
static void | addCustomColorSchemeDir(const QString &*custom_dir*)
173+
174+
### Protected Functions
175+
Type | Function
176+
| ---: | :---
177+
virtual void | resizeEvent(_QResizeEvent_*)
178+
179+
### Protected Slots
180+
Type | Function
181+
| ---: | :---
182+
void | sessionFinished()
183+
void | selectionChanged(bool _textSelected_)
184+
185+
### Member Type Documentation
186+
**enum QTermWidget::ScrollBarPosition**\
187+
This enum describes the location where the scroll bar is positioned in the display widget when calling QTermWidget::setScrollBarPosition().
188+
189+
Constant | Value | Description
190+
| --- | :---: | --- |
191+
QTermWidget::NoScrollBar | 0x0 | Do not show the scroll bar.
192+
QTermWidget::ScrollBarLeft | 0x1 | Show the scroll bar on the left side of the display.
193+
QTermWidget::ScrollBarRight | 0x2 | Show the scroll bar on the right side of the display.
194+
195+
\
196+
**enum QTermWidget::KeyboardCursorShape**\
197+
This enum describes the available shapes for the keyboard cursor when calling QTermWidget::setKeyboardCursorShape().
198+
199+
Constant | Value | Description
200+
| --- | :---: | --- |
201+
QTermWidget::BlockCursor | 0x0 | A rectangular block which covers the entire area of the cursor character.
202+
QTermWidget::UnderlineCursor | 0x1 | A single flat line which occupies the space at the bottom of the cursor character's area.
203+
QTermWidget::IBeamCursor | 0x2 | A cursor shaped like the capital letter 'I', similar to the IBeam cursor used in Qt/KDE text editors.
204+
205+
### Property Documentation
206+
**flowControlEnabled : bool**\
207+
Returns whether flow control is enabled.
208+
209+
**getPtySlaveFd : const int**\
210+
Returns a pty slave file descriptor. This can be used for display and control a remote terminal.
211+
212+
<!--**getShellPID : int**\-->
213+
<!--**getTerminalFont : QFont**\-->
214+
215+
**historyLinesCount : int**\
216+
Returns the number of lines in the history buffer.
217+
218+
<!--**icon : const QString**\-->
219+
220+
**keyBindings : QString**\
221+
Returns current key bindings.
222+
223+
<!--**screenColumnsCount : int**\-->
224+
225+
**selectedText(bool _preserveLineBreaks_ = true) : QString**\
226+
Returns the currently selected text.
227+
228+
<!--**sizeHint : const QSize**\-->
229+
<!--**terminalSizeHint : bool**\-->
230+
<!--**title : const QString**\-->
231+
<!--**workingDirectory : QString**\-->
232+
233+
### Member Function Documentation
234+
<!--__void activity()__\-->
235+
<!--__void bell(const QString &_message_)__\-->
236+
237+
__void changeDir(const QString _&dir_)__\
238+
Attempt to change shell directory (Linux only).
239+
240+
__void clear()__\
241+
Clear the terminal content and move to home position.
242+
243+
<!--__void copyAvailable(bool)__\-->
244+
245+
__void copyClipboard()__\
246+
Copy selection to clipboard.
247+
248+
<!--__void finished()__\-->
249+
<!--__void getSelectionEnd(int &_row_, int &_column_)__\-->
250+
<!--__void getSelectionStart(int &_row_, int &_column_)__\-->
251+
252+
__void pasteClipboard()__\
253+
Paste clipboard to terminal.
254+
255+
__void pasteSelection()__\
256+
Paste selection to terminal.
257+
258+
<!--__void profileChanged(const QString &_profile_)__\-->
259+
260+
__void receivedData(const QString &_text_)__\
261+
Signals that we received new data from the process running in the terminal emulator.
262+
263+
__void scrollToEnd()__\
264+
Wrapped, scroll to end of text.
265+
266+
__void sendData(const char*, int)__\
267+
Emitted when emulator send data to the terminal process (redirected for external recipient). It can be used for control and display the remote terminal.
268+
269+
__void sendText(QString &_text_)__\
270+
Send text to terminal.
271+
272+
__void setArgs(QStringList &_args_)__\
273+
Sets the shell program arguments, default is none.
274+
275+
__void setAutoClose(bool _enabled_)__\
276+
Automatically close the terminal session after the shell process exits or keep it running.
277+
278+
__void setColorScheme(const QString &_name_)__\
279+
Sets the color scheme, default is white on black.
280+
281+
__void setEnvironment(const QStringList &_environment_)__\
282+
Sets environment variables.
283+
284+
__void setFlowControlEnabled(bool _enabled_)__\
285+
Sets whether flow control is enabled.
286+
287+
__void setFlowControlWarningEnabled(bool _enabled_)__\
288+
Sets whether the flow control warning box should be shown when the flow control stop key (Ctrl+S) is pressed.
289+
290+
__void setHistorySize(int _lines_)__\
291+
History size for scrolling.
292+
293+
__void setKeyBindings(const QString &_kb_)__\
294+
Set named key binding for given widget.
295+
296+
__void setKeyboardCursorShape(QTermWidget::KeyboardCursorShape _shape_)__\
297+
Sets the shape of the keyboard cursor. This is the cursor drawn at the position in the terminal where keyboard input will appear.
298+
299+
<!--__void setMonitorActivity(bool _enabled_)__\-->
300+
<!--__void setMonitorSilence(bool _enabled_)__\-->
301+
<!--__void setMotionAfterPasting(int _action_)__\-->
302+
303+
__void setScrollBarPosition(QTermWidget::ScrollBarPosition _pos_)__\
304+
Sets presence and position of scrollbar.
305+
306+
<!--__void setSelectionEnd(int _row_, int _column_)__\-->
307+
<!--__void setSelectionStart(int _row_, int _column_)__\-->
308+
309+
__void setShellProgram(const QString &_program_)__\
310+
Sets the shell program, default is /bin/bash.
311+
312+
<!--__void setSilenceTimeout(int _seconds_)__\-->
313+
<!--__void setSize(_const QSize &_)__\-->
314+
315+
__void setTerminalFont(QFont &_font_)__\
316+
Sets terminal font. Default is application font with family Monospace, size 10. Beware of a performance penalty and display/alignment issues when using a proportional font.
317+
318+
<!--__void setTerminalOpacity(qreal _level_)__\-->
319+
320+
__void setTerminalSizeHint(bool _enabled_)__\
321+
Exposes TerminalDisplay::TerminalSizeHint.
322+
323+
__void setTextCodec(QTextCodec *_codec_)__\
324+
Sets text codec, default is UTF-8.
325+
326+
<!--__void setWorkingDirectory(const QString &_dir_)__\-->
327+
<!--__void silence()__\-->
328+
329+
__void startShellProgram()__\
330+
Starts shell program if it was not started in constructor.
331+
332+
__void startTerminalTeletype()__\
333+
Starts terminal teletype as is and redirect data for external recipient. It can be used for display and control a remote terminal.
334+
335+
<!--__void termGetFocus()__\-->
336+
<!--__void termKeyPressed(QKeyEvent*)__\-->
337+
<!--__void termLostFocus()__\-->
338+
<!--__void titleChanged()__\-->
339+
<!--__void toggleShowSearchBar()__\-->
340+
<!--__void urlActivated(const QUrl &, bool _fromContextMenu_)__\-->
341+
342+
__void zoomIn()__\
343+
Zooms in on the text.
344+
345+
__void zoomOut()__\
346+
Zooms out in on the text.

lib/qtermwidget.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,9 @@ QSize QTermWidget::sizeHint() const
227227
return size;
228228
}
229229

230-
void QTermWidget::setTerminalSizeHint(bool on)
230+
void QTermWidget::setTerminalSizeHint(bool enabled)
231231
{
232-
m_impl->m_terminalDisplay->setTerminalSizeHint(on);
232+
m_impl->m_terminalDisplay->setTerminalSizeHint(enabled);
233233
}
234234

235235
bool QTermWidget::terminalSizeHint()
@@ -379,11 +379,11 @@ void QTermWidget::setTerminalBackgroundMode(int mode)
379379
m_impl->m_terminalDisplay->setBackgroundMode((Konsole::BackgroundMode)mode);
380380
}
381381

382-
void QTermWidget::setShellProgram(const QString &progname)
382+
void QTermWidget::setShellProgram(const QString &program)
383383
{
384384
if (!m_impl->m_session)
385385
return;
386-
m_impl->m_session->setProgram(progname);
386+
m_impl->m_session->setProgram(program);
387387
}
388388

389389
void QTermWidget::setWorkingDirectory(const QString& dir)
@@ -689,14 +689,14 @@ QString QTermWidget::selectedText(bool preserveLineBreaks)
689689
return m_impl->m_terminalDisplay->screenWindow()->screen()->selectedText(preserveLineBreaks);
690690
}
691691

692-
void QTermWidget::setMonitorActivity(bool monitor)
692+
void QTermWidget::setMonitorActivity(bool enabled)
693693
{
694-
m_impl->m_session->setMonitorActivity(monitor);
694+
m_impl->m_session->setMonitorActivity(enabled);
695695
}
696696

697-
void QTermWidget::setMonitorSilence(bool monitor)
697+
void QTermWidget::setMonitorSilence(bool enabled)
698698
{
699-
m_impl->m_session->setMonitorSilence(monitor);
699+
m_impl->m_session->setMonitorSilence(enabled);
700700
}
701701

702702
void QTermWidget::setSilenceTimeout(int seconds)
@@ -767,9 +767,9 @@ bool QTermWidget::isTitleChanged() const
767767
return m_impl->m_session->isTitleChanged();
768768
}
769769

770-
void QTermWidget::setAutoClose(bool autoClose)
770+
void QTermWidget::setAutoClose(bool enabled)
771771
{
772-
m_impl->m_session->setAutoClose(autoClose);
772+
m_impl->m_session->setAutoClose(enabled);
773773
}
774774

775775
void QTermWidget::cursorChanged(Konsole::Emulation::KeyboardCursorShape cursorShape, bool blinkingCursorEnabled)

lib/qtermwidget.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class QTERMWIDGET_EXPORT QTermWidget : public QWidget {
6262
QSize sizeHint() const override;
6363

6464
// expose TerminalDisplay::TerminalSizeHint, setTerminalSizeHint
65-
void setTerminalSizeHint(bool on);
65+
void setTerminalSizeHint(bool enabled);
6666
bool terminalSizeHint();
6767

6868
//start shell program if it was not started in constructor
@@ -94,7 +94,7 @@ class QTERMWIDGET_EXPORT QTermWidget : public QWidget {
9494
void setEnvironment(const QStringList & environment);
9595

9696
// Shell program, default is /bin/bash
97-
void setShellProgram(const QString & progname);
97+
void setShellProgram(const QString & program);
9898

9999
//working directory
100100
void setWorkingDirectory(const QString & dir);

0 commit comments

Comments
 (0)