# Window naming conventions

KVIrc window structure and the window naming conventions

## Introduction

Starting from the release 3.0.0 KVIrc window structure has grown in complexity. Older releases allowed one connetion per "frame window" and thus had a dedicated command parser for each connection. Finding a window in that scenario was quite easy: it was enough to designate it by "name" (that was exactly the text displayed in the window caption). It was sufficient to have an "unique" name for ever window; condition that was granted by the underlying IRC protocol and by the KVIrc core design.
In this version, the unique window names are impossible to be granted.

## Scenario

The command parser is now "global" to the application. There can be two or more consoles in each frame and the user is able to join the same channel with two different nicknames using two separate connections.

- Application (Unique command parser)
  - Frame X
    - Console M (irc context)
      - Channel windows
      - Query windows
      - Other connection related windows
    - Console N (irc context)
      - Channel windows
      - Query windows
      - Other connection related windows
    - Other windows
    - ...
  - Frame Y
    - Console O (irc context)
      - Channel windows
      - Query windows
      - Other connection related windows
    - Console P (irc context)
      - Channel windows
      - Query windows
      - Other connection related windows
    - Other windows
    - ...
  - ...

A naming convention has becomed necessary to resolve ambiguities.

## Basic assumptions

Every KVIrc window has four main properties:
-an unique numeric identifier
-the logical name
-the type identifier
-the caption text
The numeric identifier is unique to the whole application, and is the one returned by the $window function.
The identifier is assigned by KVirc when the window is created and is not changed until the window is destroyed. This identifier will be referred as window id.
The logical name is a property of some kind of windows. It usually corresponds to the first part of the window caption. For example, for channel windows it is the channel name, for queries it is the list of the targets. For some other windows the logical name corresponds to the caption text. This will be discussed later.
The type identifier describes the properties of a certain window. For channel windows the type identifier is "channel" , for query windows is "query" , for console windows it is "console", etc..

## Irc contexts

The KVirc frame windows are numbered starting from 0 and named "frame_<number>". Each frame can contain an unlimited number of consoles.
Each console is bound to an irc context. (The part "is bound to" could be substituted by "defines" or "is contained in").
An irc context is a set of resources that can deal with a single IRC connection.
The association between an irc context and a console is bijective: each irc context is associated to a single console window.
An irc context can be in connected or not-connected state. When in connected state, it contains a set of windows beside the console: mainly channels and query windows. The channels and query windows can exist ONLY if the associated irc context exists.
Channels and queries have unique names inside a connection so there is no way to confuse it. (Theoretically there can be more than one query window with the same name, but in fact all the windows refer to the same target so they are instances of the same resource). All this creates a sort of namespace: the channels and queries can be identified as "bound" to a specific irc context.
An irc context can "contain" other windows, such as the "links" window or the "list" window. KVIrc takes care of making them unique inside the irc context namespace.
Each irc context has its own UNIQUE irc context id (see $context).
Since to a single irc context may correspond only a single irc connection, when in connected state, the irc context may be referred also as connection or connection context, and the associated irc context id can be referred as connection id or connection context id.
There are classes of windows that are not bound to any irc context: this includes user created windows, DCC windows, browsers etc.
KVIrc will try to keep that windows with unique logical names.

## How to identify a window

So what we have until now is:

- Each window has its own unique window id: we will refer windows always using this identifier.
- Each window has a set of properties including: window type, logical name.
- Subsets of windows are bound to a single irc context

The simplest (but also the less significant) method of looking for a window is to finding it by caption.
The $window function finds the first KVIrc window matching the "caption text" and returns its window id.
This method will likely fail when there are more windows with the same caption text; for this reason several specific functions have been added to allow finding the correct window.
The $console finds a console window bound to a specified irc context.
The $channel finds a channel window matching the specified name and bound to a specified irc context.
The $query finds a query window that has a specified target and is bound to a specified irc context.

Main index, Language overview index

KVirc 3.0.0 documentation
Generated by root at Thu Apr 29 12:41:05 2004