---
name: "tty"
section: "3bobcat"
platform: "linux"
package: "libbobcat-dev"
version: "6.07.01-2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/tty/3bobcat"
---

# tty(3bobcat)

Controls echoing of characters entered at the terminal

## NAME

FBB::Tty - Controls echoing of characters entered at the terminal

## SYNOPSIS

**#include \<bobcat/tty\>**\
 Linking option: *-lbobcat*

## DESCRIPTION

**Tty**(3bobcat) objects can be used to control the echoing of characters entered at the terminal (usually at */dev/tty*). Directly reading from */dev/tty* allows programs to read information (e.g., passwords or pass phrases) even if the standard input stream is redirected to a file. Unless redirected, *std::cin* is connected to */dev/tty*.

**Tty**(3bobcat) objects may be used as stand-alone objects or (usually anonymous) **Tty**(3bobcat) objects may be inserted into or extracted from streams. When inserting or extracting objects the involved streams are not affected; only the echoing of characters entered at */dev/tty* is manipulated.

**Tty**(3bobcat)’s destructor does not reset the echo-state of */dev/tty* to its original value. If that is required a **Tty**(3bobcat) object must be created first, calling its **echo(Tty::RESET)** member at the appropriate time.

## NAMESPACE

**FBB**\
 All constructors, members, operators and manipulators, mentioned in this man-page, are defined in the namespace **FBB**.

## INHERITS FROM

\-

## ENUM

The *enum EchoType* requests the type of echo-handling:

- o

  **RESET** is used to reset */dev/tty*’s state to the actual state when a **Tty**(3bobcat) object was constructed

- o

  **ON** is used to activate echoing of characters entered at */dev/tty*.

- o

  **OFF** is used to suppress echoing of characters entered at */dev/tty*.

## CONSTRUCTORS

- o

  **Tty()**:\
   The current state of */dev/tty* is saved.

-

  - o

  **Tty(EchoType type)**:\
   The current state of */dev/tty* is saved, and the object’s member *echo(type)* is called.

Copy and move constructors (and assignment operators) are available.

## OVERLOADED OPERATORS

- o

  **std::istream &operator\>\>(std::istream &in, Tty const &tty)**:\
   The extraction operator does not affect *in*, but */dev/tty*’s state is set according to the way the *tty* object was constructed.

-

  - o

  **std::ostream &operator\<\<(std::ostream &out, Tty const &tty)**:\
   The insertion operator does not affect *out*, but */dev/tty*’s state is set according to the way the *tty* object was constructed.

## MEMBER FUNCTION

- o

  **echo(EchoType type)**:\
   */Dev/tty*’s state is set according to the *EchoType* value that is passed to this member.

## EXAMPLE

```
#include <iostream>
#include <string>
#include <bobcat/tty>
using namespace std;
using namespace FBB;
int main()
{
    cout << "Enter some text (not echoed): " << Tty(Tty::OFF);
    string line;
    getline(cin, line);
    cout << "\n"
            "You entered: `" << line << "’\n";
    cout << "Enter some text (echoed): ";
    getline(cin >> Tty(Tty::ON), line);
    cout << "You entered: `" << line << "’\n";
}
```

## FILES

*bobcat/tty* - defines the class interface

## SEE ALSO

[**bobcat**(7)](/bobcat/7.md), [**onekey**(3bobcat)](/onekey/3bobcat.md)

## BUGS

None Reported.

## BOBCAT PROJECT FILES

- o

  *https://fbb-git.gitlab.io/bobcat/*: gitlab project page;

Debian Bobcat project files:

- o

  *libbobcat6*: debian package containing the shared library, changelog and copyright note;

- o

  *libbobcat-dev*: debian package containing the static library, headers, manual pages, and developer info;

## BOBCAT

Bobcat is an acronym of \`Brokken’s Own Base Classes And Templates’.

## COPYRIGHT

This is free software, distributed under the terms of the GNU General Public License (GPL).

## AUTHOR

Frank B. Brokken (**f.b.brokken@rug.nl**).
