mudlet/src/TMxpDestTagHandler.h
Mike Conley f39a8015ae
Add: MXP FRAME and DEST tag support for multi-window layouts (#8577)
#### Brief overview of PR changes/additions

Implements MXP `<FRAME>` and `<DEST>` tag support, allowing MUD servers
to create custom windows and redirect output to them. Games can now
define dedicated windows for different content types (chat channels,
combat logs, room descriptions, maps, etc.) and control which window
receives specific output.

**Key additions:**
- `TMxpFrameManager` - manages frame lifecycle and hierarchy
- `TMxpFrameTagHandler` - processes `<FRAME>` tags for window creation
- `TMxpDestTagHandler` - processes `<DEST>` tags for output routing
- Modified `cTelnet::postData()` to route output to destination frames
- Support for floating/docked windows, tabs, and nested frame
hierarchies
- Unit tests covering tag parsing and handler behavior

**Supported features:**
- Frame attributes: name, title, position, size, floating/docking,
scrolling
- Output routing with EOL (clear current line) and EOF (clear buffer)
flags
- Parent-child frame relationships with automatic cleanup
- Maximum 20 frames per profile to prevent resource exhaustion

Documentation: [Area
51](https://wiki.mudlet.org/w/Area_51#MXP_FRAME_and_DEST_Tags.2C_PR_.238577)

#### Motivation for adding to Mudlet

Enables server-controlled multi-window layouts, improving information
organization and readability. Players get dedicated windows for
different game systems without manual configuration. This capability is
standard in other MUD clients (MUSHclient, zMUD) and addresses a
long-standing gap in Mudlet's MXP implementation.

#### Other info (issues closed, discussion etc)

Closes #8573

---

### Architecture Overview

```mermaid
graph TB
    Server[MUD Server] -->|MXP Tags| Telnet[cTelnet]
    Telnet --> MxpProc[TMxpProcessor]
    MxpProc --> TagParser[TMxpTagParser]
    TagParser --> FrameHandler[TMxpFrameTagHandler]
    TagParser --> DestHandler[TMxpDestTagHandler]
    
    FrameHandler --> Client[TMxpMudlet]
    DestHandler --> Client
    
    Client --> FrameMgr[TMxpFrameManager]
    
    FrameMgr -->|Creates| DockWidget[TDockWidget]
    FrameMgr -->|Creates| TabWidget[QTabWidget]
    FrameMgr -->|Creates| Console[TConsole]
    
    FrameMgr -->|Routes Output| ActiveConsole[Active Destination Console]
    
    DockWidget --> MainWindow[QMainWindow]
    TabWidget --> MainWindow
    
    style FrameMgr stroke:#2e7d32,stroke-width:3px
    style Client stroke:#1976d2,stroke-width:3px
    style Server stroke:#c62828,stroke-width:3px
```
---

<img width="1728" height="1013" alt="Screenshot 2025-12-06 at 12 34
24 PM"
src="https://github.com/user-attachments/assets/ed26c581-6b7c-467f-bf35-951586d114b4"
/>
2025-12-28 22:31:42 +00:00

42 lines
2.1 KiB
C++

#ifndef MUDLET_TMXPDESTTAGHANDLER_H
#define MUDLET_TMXPDESTTAGHANDLER_H
/***************************************************************************
* Copyright (C) 2025 by Mike Conley - mike.conley@stickmud.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "TMxpTagHandler.h"
// Handles MXP <DEST> tag for redirecting output to frames
// Usage: <DEST frameName EOF>output here</DEST>
class TMxpDestTagHandler : public TMxpTagHandler
{
public:
TMxpDestTagHandler() = default;
bool supports(TMxpContext& ctx, TMxpClient& client, MxpTag* tag) override;
TMxpTagHandlerResult handleStartTag(TMxpContext& ctx, TMxpClient& client, MxpStartTag* tag) override;
TMxpTagHandlerResult handleEndTag(TMxpContext& ctx, TMxpClient& client, MxpEndTag* tag) override;
private:
QString extractFrameName(MxpStartTag* tag);
bool hasEOL(MxpStartTag* tag);
bool hasEOF(MxpStartTag* tag);
};
#endif // MUDLET_TMXPDESTTAGHANDLER_H