Use "subclassing" to reduce redundancy and improve TermDrivers
Currently, there are two totally unrelated code paths, depending on whether TERM=xterm* or not. This has two notable downsides:
* Much more code duplication than is necessary, when the xterm driver re-implements the behaviour that a TI-driven one could have done itself
* The xterm driver isn't sensitive to local changes in the terminfo database for term=xterm, it will always use its hardcoded strings
I suggest instead a reshaping of the TermDriver model to more of the following:
* Have every driver operation method return a bool indicating whether it succeeded
* Store a pointer called 'parent' in the TermDriver struct, potentially pointing at another driver.
Then the xterm driver can use the plain TI driver as its parent. For each requested operation it can first ask the parent driver to perform it, and only if it fails it can then apply its hardcoded behaviour. This still lets the xterm driver perform all of the additional behaviours that TI can't represent, while allowing the existing TI driver to still get a chance first, per request.
Blueprint information
- Status:
- Not started
- Approver:
- None
- Priority:
- Medium
- Drafter:
- Paul "LeoNerd" Evans
- Direction:
- Needs approval
- Assignee:
- None
- Definition:
- Pending Approval
- Series goal:
- None
- Implementation:
- Not started
- Milestone target:
- None
- Started by
- Completed by
Related branches
Related bugs
Sprints
Whiteboard
Alternate suggestion: Expose the driver interface to library users and let the driver be chosen in the library constructor. This would make it possible to use libtickit even in environments that it doesn't support directly.