# Browser

The browser displays HTML (.html), Markdown (.md), Gemini (.gmi), and
Text (.txt) files.

Limitations of the current version:

* HTML support is very rudimentary
* Text rendering is limited to Code page 437 by default but can be extended with
  custom code page definitions.

# Quickstart

- Start the browser
- Press G to type in the URL of the website you want to visit
- Type in the full URL, i.e. https://slashbinbash.de
- Press ENTER to visit the website
- To scroll press the UP or DOWN arrow key, or scroll using the mouse wheel
- To follow links press N to select a link and ENTER to follow it, or use the
  mouse to click on a link

# Controls

## Keyboard

Open new browser window

    CTRL+N

Toggle fullscreen mode

    F11

Zoom in

    CTRL+PLUS

Zoom out

    CTRL+MINUS

### Page

Scroll down

    J
    DOWN

Scroll up

    K
    UP

Scroll home

    HOME
    SHIFT+H

Scroll end

    END
    SHIFT+L

Scroll page down

    SPACE
    PAGEDOWN
    SHIFT+J

Scroll page up

    SHIFT+SPACE
    PAGEUP
    SHIFT+K

### Links

Select next link

    N
    TAB

Select previous link

    SHIFT+N
    SHIFT+TAB

Copy selected link

    CTRL+C

Set command to download the file at the selected link

    CTRL+D

Set command to download and open the file at the selected link

    CTRL+SHIFT+D

### Navigation

Goto URL

    G
    F6

Goto previous page

    H
    LEFT

Goto selected link

    RETURN
    L
    RIGHT
    F12

Open selected link in new window

    CTRL+RETURN
    CTRL+L
    CTRL+RIGHT
    CTRL+F12

Reload page

    R
    F5

### Find

Find word

    '/'
    CTRL+F
    F3

Find next word

    F
    F3

Find previous word

    SHIFT+F
    SHIFT+F3

# Commands

You enter the command mode by typing ':'.

Quit the application

    :q

Change the page width in number of characters.

    :page NUM_CHARS

    :page 80

Copy the URL of the currently displayed document to the clipboard

    :copy url

Copy the page content to the clipboard

    :copy text

Download file to disk

    :dl URL_TO_FILE

    :dl https://slashbinbash.de/index.html

Download file to disk and open with default application

    :dlopen URL_TO_FILE

    :dlopen https://slashbinbash.de/index.html

Open file on disk with default application

    :open PATH_TO_FILE

    :open Downloads/image.png

Show the browser history

    :history

Clear the browser history and visited sites

    :history clear

Open new browser window

    :new

Open new browser window and goto URL

    :new URL_TO_PAGE

    :new https://slashbinbash.de

# Command Line

Start the program

    browser

Start the program and load a website

    browser https://slashbinbash.de

Output the file to the standard output

    cli -o https://slashbinbash.de/index.html

Download the file to disk
    
    cli -d https://slashbinbash.de/index.html Downloads/output.html

Get HTTP header information
    
    cli -r https://slashbinbash.de/index.html

# Configuration

You can make changes to the browser appearance by editing the config.txt file.

Change the window size.

    window WIDTH HEIGHT

    window 800 600

Change the default font mode (cga: Cp437 IBM CGA, vga: Cp437 IBM VGA)

    mode MODE_ID
    
    mode cga
    mode vga

Change the character grid size. By providing a grid size, you can add more
spacing between the individual glyphs of the font. 

    char WIDTH HEIGHT

    char 16 20

Change the scale of the font on the screen

    fontscale NUMBER

    fontscale 2

Change the background color of the page

    bgcolor RED GREEN BLUE

    bgcolor 30 30 30

Change the font color

    fgcolor RED GREEN BLUE

    fgcolor 216 207 192

Change the background color of all links

    linkbgcol RED GREEN BLUE

    linkbgcol 81 96 103

Change the background color of the selected link

    linkbgsel RED GREEN BLUE

    linkbgsel 167 74 67

Change the background color of the search result

    findbgcol RED GREEN BLUE

    findbgcol 0 128 128

Change the background color of the status bar

    statusbgcol RED GREEN BLUE

    statusbgcol 0 0 0

Change the download directory

    dldir PATH

    dldir C:\Users\foobar\Downloads

Use the predefined code page 437 mapping and a custom bitmap font:

    codepage CPID BMP_IMAGE FONT_WIDTH FONT_HEIGHT

    codepage cp437 custom.bmp 8 16

The bitmap font must be a 16x16 grid of characters. The font color must be
white. The background color must be black.

Define a code point range and a custom bitmap font:

    codepage rng RNG_START RNG_END BMP_IMAGE FONT_WIDTH FONT_HEIGHT

    codepage rng 0 256 latin.bmp 8 8
    codepage rng U+0400 U+0500 cyrillic.bmp 8 8

Use a bmfont generated .fnt file (text) and bitmap file:

    codepage bmfont consolas_latin.fnt
    codepage bmfont consolas_cyrillic.fnt

# Creating fonts with BMFont

- Download the Bitmap Font Generator (BMFont)
  https://www.angelcode.com/products/bmfont/
- Configure your font in the Font settings
- Select the pages that you want to export
- Open the Export settings
  - For the Font descriptor select "Text"
  - For the Textures select "png".
  - Save the bitmap font
  - Check that the generated image file has a white font and a black background
- Convert the PNG image to a BMP image
  - If possible, select the bitmap format to be 8-bit indexed

You can generate multiple files for different pages of the same font and load
them in the browser. The pages must not overlap.