mirror of
https://github.com/lihop/godot-xterm.git
synced 2024-11-23 02:00:25 +01:00
0d4e10f5ab
Most notably: - Reflow is now working. Terminal size will fill the window and cols/rows will be resized/calculated based on window and font size. - Added support for different fonts (i.e. bold, italic, bolditalic). - Enabled blinking characters. - Adde more tests and caught a few subtle bugs. - Removed renderer code (which was part of xterm.js) and just doing naive rendering in terminal.gd, but it seems to perform a lot faster. Still not working completely: - vim (some weirdness going on). - vttest (more weirdness). Todo: - Fix the above. - Draw the cursor! - Improve performance. Performance is still not great. The terminal becomes unusable when running `yes` or `cmatrix -r`.
69 lines
1.9 KiB
GDScript
69 lines
1.9 KiB
GDScript
# Copyright (c) 2017 The xterm.js authors. All rights reserved.
|
|
# Ported to GDScript by the GodotXterm authors.
|
|
# License MIT
|
|
extends Reference
|
|
|
|
const Buffer = preload("res://addons/godot_xterm/buffer/buffer.gd")
|
|
|
|
signal buffer_activated(active_buffer, inactive_buffer)
|
|
|
|
var normal
|
|
var alt
|
|
var active
|
|
|
|
|
|
func _init(options_service, buffer_service):
|
|
normal = Buffer.new(true, options_service, buffer_service)
|
|
normal.fill_viewport_rows()
|
|
|
|
# The alt buffer should never have scrollback.
|
|
# See http://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h2-The-Alternate-Screen-Buffer
|
|
alt = Buffer.new(false, options_service, buffer_service)
|
|
active = normal
|
|
|
|
setup_tab_stops()
|
|
|
|
|
|
# Sets the normal Bufer of the BufferSet as its currently active Buffer.
|
|
func activate_normal_buffer() -> void:
|
|
if active == normal:
|
|
return
|
|
|
|
normal.x = alt.x
|
|
normal.y = alt.y
|
|
|
|
# The alt buffer should always be cleared when we switch to the normal
|
|
# buffer. This frees up memory since the alt buffer should always be new
|
|
# when activated.
|
|
alt.clear()
|
|
active = normal
|
|
emit_signal("buffer_activated", normal, alt)
|
|
|
|
|
|
# Sets the alt Buffer of the BufferSet as its currently active Buffer.
|
|
func activate_alt_buffer(fill_attr = null) -> void:
|
|
if active == alt:
|
|
return
|
|
|
|
# Since the alt buffer is always cleared when the normal buffer is
|
|
# activated, we want to fill it when switching to it.
|
|
alt.fill_viewport_rows(fill_attr)
|
|
alt.x = normal.x
|
|
alt.y = normal.y
|
|
active = alt
|
|
emit_signal("buffer_activated", alt, normal)
|
|
|
|
|
|
# Resizes both normal and alt buffers, adjusting their data accordingly.
|
|
# @param new_cols The new number of columns.
|
|
# @param new_rows The new number of rows.
|
|
func resize(new_cols: int, new_rows: int) -> void:
|
|
normal.resize(new_cols, new_rows)
|
|
alt.resize(new_cols, new_rows)
|
|
|
|
|
|
# Setup the tab stops.
|
|
# @param i The index to start setting up tab stops from.
|
|
func setup_tab_stops(i = null) -> void:
|
|
normal.setup_tab_stops(i)
|
|
alt.setup_tab_stops(i)
|