• Stars
    star
    441
  • Rank 98,861 (Top 2 %)
  • Language
    C++
  • License
    GNU General Publi...
  • Created over 12 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

The terminal widget for QTerminal

QTermWidget

Overview

A terminal emulator widget for Qt 5.

QTermWidget is an open-source project originally based on the KDE4 Konsole application, but it took its own direction later on. 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).

It is compatible with BSD, Linux and OS X.

This project is licensed under the terms of the GPLv2 or any later version. See the LICENSE file for the full text of the license. Some files are published under compatible licenses:

Files: example/main.cpp
       lib/TerminalCharacterDecoder.cpp
       lib/TerminalCharacterDecoder.h
       lib/kprocess.cpp
       lib/kprocess.h
       lib/kpty.cpp
       lib/kpty.h
       lib/kpty_p.h
       lib/kptydevice.cpp
       lib/kptydevice.h
       lib/kptyprocess.cpp
       lib/kptyprocess.h
       lib/qtermwidget.cpp
       lib/qtermwidget.h
       lib/qtermwidget_interface.h
Copyright: Author Adriaan de Groot <[email protected]>
           2010, KDE e.V <[email protected]>
           2002-2007, Oswald Buddenhagen <[email protected]>
           2006-2008, Robert Knight <[email protected]>
           2002, Waldo Bastian <[email protected]>
           2008, e_k <[email protected]>
           2022, Francesc Martinez <[email protected]>
License: LGPL-2+

Files: cmake/FindUtf8Proc.cmake
Copyright: 2009-2011, Kitware, Inc
           2009-2011, Philip Lowman <[email protected]>
License: BSD-3-clause

Installation

Compiling sources

The only runtime dependency is qtbase ≥ 5.12.0. Build dependencies are as follows:

  • CMake ≥ 3.1.0 serves as the build system and therefore needs to be present to compile.
  • The latest lxqt-build-tools is also needed for compilation.
  • Git is needed to optionally pull latest VCS checkouts.

Code configuration is handled by CMake. CMake variable CMAKE_INSTALL_PREFIX will normally have to be set to /usr, depending on the way library paths are dealt with on 64bit systems. Variables like CMAKE_INSTALL_LIBDIR may have to be set as well.

To build, run make. To install, run make install which accepts variable DESTDIR as usual.

To build PyQt bindings, build this library first, and then invoke sip-wheel in pyqt/ directory. Environment variables CXXFLAGS and LDFLAGS can be used to specify non-installed or non-standard directories for headers and shared libraries, and the built Python wheel can be installed by standard tools like pip. See the CI script for a complete example.

Binary packages

The library is provided by all major Linux distributions. This includes Arch Linux, Debian, Fedora, openSUSE and all of their children, given they use the same package repositories. Just use the distributions' package managers to search for string qtermwidget.

Translation

Translations can be done in LXQt-Weblate

Translation status

API

Public Types

Type Variable
enum ScrollBarPosition { NoScrollBar, ScrollBarLeft, ScrollBarRight }
enum KeyboardCursorShape { BlockCursor, UnderlineCursor, IBeamCursor }

Properties

  • flowControlEnabled : bool
  • getPtySlaveFd : const int
  • getShellPID : int
  • getForegroundProcessId : int
  • getTerminalFont : QFont
  • historyLinesCount : int
  • icon : const QString
  • keyBindings : QString
  • screenColumnsCount : int
  • selectedText(bool preserveLineBreaks = true) : QString
  • sizeHint : const QSize
  • terminalSizeHint : bool
  • title : const QString
  • workingDirectory : QString

Public Functions

Type Function
QTermWidget(int startnow = 1, QWidget *parent = 0)
virtual ~QTermWidget()
void changeDir(const QString &dir)
void getSelectionEnd(int &row, int &column)
void getSelectionStart(int &row, int &column)
void scrollToEnd()
void sendText(QString &text)
void setArgs(QStringList &args)
void setAutoClose(bool enabled)
void setColorScheme(const QString &name)
void setEnvironment(const QStringList &environment)
void setFlowControlEnabled(bool enabled)
void setFlowControlWarningEnabled(bool enabled)
void setHistorySize(int lines)
void setKeyboardCursorShape(QTermWidget::KeyboardCursorShape shape)
void setMonitorActivity(bool enabled)
void setMonitorSilence(bool enabled)
void setMotionAfterPasting(int action)
void setScrollBarPosition(QTermWidget::ScrollBarPosition pos)
void setSelectionEnd(int row, int column)
void setSelectionStart(int row, int column)
void setShellProgram(const QString &program)
void setSilenceTimeout(int seconds)
void setTerminalFont(QFont &font)
void setTerminalOpacity(qreal level)
void setTerminalSizeHint(bool enabled)
void setTextCodec(QTextCodec *codec)
void setWorkingDirectory(const QString &dir)
void startShellProgram()
void startTerminalTeletype()
QStringList availableColorSchemes()

Public Slots

Type Function
void copyClipboard()
void pasteClipboard()
void pasteSelection()
void zoomIn()
void zoomOut()
void setSize(const QSize &)
void setKeyBindings(const QString &kb)
void clear()
void toggleShowSearchBar()

Signals

Type Function
void activity()
void bell(const QString &message)
void copyAvailable(bool)
void finished()
void profileChanged(const QString &profile)
void receivedData(const QString &text)
void sendData(const char*, int)
void silence()
void termGetFocus()
void termKeyPressed(QKeyEvent*)
void termLostFocus()
void titleChanged()
void urlActivated(const QUrl &, bool fromContextMenu)

Static Public Members

Type Function
static QStringList availableColorSchemes()
static QStringList availableKeyBindings()
static void addCustomColorSchemeDir(const QString &custom_dir)

Protected Functions

Type Function
virtual void resizeEvent(QResizeEvent*)

Protected Slots

Type Function
void sessionFinished()
void selectionChanged(bool textSelected)

Member Type Documentation

enum QTermWidget::ScrollBarPosition
This enum describes the location where the scroll bar is positioned in the display widget when calling QTermWidget::setScrollBarPosition().

Constant Value Description
QTermWidget::NoScrollBar 0x0 Do not show the scroll bar.
QTermWidget::ScrollBarLeft 0x1 Show the scroll bar on the left side of the display.
QTermWidget::ScrollBarRight 0x2 Show the scroll bar on the right side of the display.


enum QTermWidget::KeyboardCursorShape
This enum describes the available shapes for the keyboard cursor when calling QTermWidget::setKeyboardCursorShape().

Constant Value Description
QTermWidget::BlockCursor 0x0 A rectangular block which covers the entire area of the cursor character.
QTermWidget::UnderlineCursor 0x1 A single flat line which occupies the space at the bottom of the cursor character's area.
QTermWidget::IBeamCursor 0x2 A cursor shaped like the capital letter 'I', similar to the IBeam cursor used in Qt/KDE text editors.

Property Documentation

flowControlEnabled : bool
Returns whether flow control is enabled.

getPtySlaveFd : const int
Returns a pty slave file descriptor. This can be used for display and control a remote terminal.

getForegroundProcessId : int
Returns the PID of the foreground process. This is initially the same as processId() but can change as the user starts other programs inside the terminal. If there is a problem reading the foreground process id, 0 will be returned.

historyLinesCount : int
Returns the number of lines in the history buffer.

keyBindings : QString
Returns current key bindings.

selectedText(bool preserveLineBreaks = true) : QString
Returns the currently selected text.

Member Function Documentation

void changeDir(const QString &dir)
Attempt to change shell directory (Linux only).

void clear()
Clear the terminal content and move to home position.

void copyClipboard()
Copy selection to clipboard.

void pasteClipboard()
Paste clipboard to terminal.

void pasteSelection()
Paste selection to terminal.

void receivedData(const QString &text)
Signals that we received new data from the process running in the terminal emulator.

void scrollToEnd()
Wrapped, scroll to end of text.

void sendData(const char*, int)
Emitted when emulator send data to the terminal process (redirected for external recipient). It can be used for control and display the remote terminal.

void sendText(QString &text)
Send text to terminal.

void setArgs(QStringList &args)
Sets the shell program arguments, default is none.

void setAutoClose(bool enabled)
Automatically close the terminal session after the shell process exits or keep it running.

void setColorScheme(const QString &name)
Sets the color scheme, default is white on black.

void setEnvironment(const QStringList &environment)
Sets environment variables.

void setFlowControlEnabled(bool enabled)
Sets whether flow control is enabled.

void setFlowControlWarningEnabled(bool enabled)
Sets whether the flow control warning box should be shown when the flow control stop key (Ctrl+S) is pressed.

void setHistorySize(int lines)
History size for scrolling.

void setKeyBindings(const QString &kb)
Set named key binding for given widget.

void setKeyboardCursorShape(QTermWidget::KeyboardCursorShape shape)
Sets the shape of the keyboard cursor. This is the cursor drawn at the position in the terminal where keyboard input will appear.

void setScrollBarPosition(QTermWidget::ScrollBarPosition pos)
Sets presence and position of scrollbar.

void setShellProgram(const QString &program)
Sets the shell program, default is /bin/bash.

void setTerminalFont(QFont &font)
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.

void setTerminalSizeHint(bool enabled)
Exposes TerminalDisplay::TerminalSizeHint.

void setTextCodec(QTextCodec *codec)
Sets text codec, default is UTF-8.

void startShellProgram()
Starts shell program if it was not started in constructor.

void startTerminalTeletype()
Starts terminal teletype as is and redirect data for external recipient. It can be used for display and control a remote terminal.

void zoomIn()
Zooms in on the text.

void zoomOut()
Zooms out in on the text.

More Repositories

1

lxqt

Checkout all LXQt components at once by using git submodule.
Shell
1,497
star
2

qterminal

A lightweight Qt-based terminal emulator
C++
539
star
3

pcmanfm-qt

File manager and desktop icon manager (Qt port of PCManFM and libfm)
C++
342
star
4

lxqt-panel

The LXQt desktop panel
C++
164
star
5

compton-conf

GUI configuration tool for compton X composite manager
C++
135
star
6

pavucontrol-qt

A Pulseaudio mixer in Qt (port of pavucontrol)
C++
109
star
7

lximage-qt

The image viewer and screenshot tool for lxqt
C++
86
star
8

libfm-qt

Core library of PCManFM-Qt (Qt binding for libfm)
C++
73
star
9

lxqt-config

Tools to configure LXQt and the underlying operating system
C++
71
star
10

libqtxdg

Qt implementation of freedesktop.org xdg specs
C++
70
star
11

sddm-config-editor

SDDM Configuration Editor
QML
66
star
12

screengrab

Crossplatform tool for fast making screenshots.
C++
62
star
13

lxqt-notificationd

The LXQt notification daemon
C++
57
star
14

liblxqt

Core utility library for all LXQt components
C++
53
star
15

lxqt-session

The LXQt session manager
C++
47
star
16

lxqt-runner

Tool used to launch programs quickly by typing their names
C++
40
star
17

lxqt-archiver

A simple & lightweight desktop-agnostic Qt file archiver
C
37
star
18

lxqt-sudo

GUI frontend for sudo/su
C++
33
star
19

lxqt-globalkeys

Daemon used to register global keyboard shortcuts
C++
30
star
20

lxqt_wallet

create a kwallet like functionality for lxqt
C++
28
star
21

obconf-qt

The Qt port of obconf, the Openbox configuration tool
C++
26
star
22

lxqt-policykit

The LXQt PolicyKit agent
C++
26
star
23

lxqt-powermanagement

Power management module for LXQt
C++
25
star
24

lxqt-themes

Themes, graphics and icons for LXQt
CMake
25
star
25

lxqt-qtplugin

LXQt Qt platform integration plugin
C++
24
star
26

lxqt-build-tools

Various packaging tools and scripts for LXQt applications
CMake
24
star
27

lxqt-about

Dialogue window providing information about LXQt and the system it's running on
C++
24
star
28

lxqt-admin

LXQt system administration tool
C++
23
star
29

lxqt-connman-applet

System-tray applet for connman
C++
21
star
30

lxqt-l10n-deprecated

Deprecated Translations of LXQt - please use the repositories directly
CMake
21
star
31

lxqt-common-deprecated

Common files for LXQt
CMake
19
star
32

lxqt-openssh-askpass

GUI to query passwords on behalf of SSH agents.
C++
18
star
33

lxqt.github.io

LXQt website
JavaScript
16
star
34

xdg-desktop-portal-lxqt

A backend implementation for xdg-desktop-portal
C++
16
star
35

libsysstat

Library used to query system info and statistics
C++
14
star
36

organizer

Personal Information Manager
C++
11
star
37

qt-gtk-engine

Theming Gtk+ 3 programs with Qt styles
C++
10
star
38

lxqt-kcm-integration

Windowmanager integration for LXQt
Shell
6
star
39

lxqt-themes-extra

5
star
40

liblxqt-mount-deprecated

No longer supported - Use KF5 Solid instead.
C++
4
star
41

lxqt-release-foo

Release Scripts, Announcements, misc
Shell
4
star
42

lxqt-menu-data

Menu files for LXQt Panel, Configuration Center and PCManFM-Qt/libfm-qt
CMake
3
star
43

qtxdg-tools

libqtxdg user tools
C++
2
star
44

ci

Shell
1
star