summaryrefslogtreecommitdiff
path: root/Meta/CMake
diff options
context:
space:
mode:
authorDaniel Bertalan <dani@danielbertalan.dev>2021-05-08 20:37:43 +0200
committerAndreas Kling <kling@serenityos.org>2021-05-16 11:50:56 +0200
commitbe519022c3326f7d5cec964b6d3b72d419b0f522 (patch)
treee8d4698840276142443a0d0b1c99022bc6ccb2cf /Meta/CMake
parent1b347298f118e4e78e7cef41096623913c9e640e (diff)
downloadserenity-be519022c3326f7d5cec964b6d3b72d419b0f522.zip
LibVT: Implement new ANSI escape sequence parser
This commit replaces the former, hand-written parser with a new one that can be generated automatically according to a state change diagram. The new `EscapeSequenceParser` class provides a more ergonomic interface to dealing with escape sequences. This interface has been inspired by Alacritty's [vte library](https://github.com/alacritty/vte/). I tried to avoid changing the application logic inside the `Terminal` class. While this code has not been thoroughly tested, I can't find regressions in the basic command line utilities or `vttest`. `Terminal` now displays nicer debug messages when it encounters an unknown escape sequence. Defensive programming and bounds checks have been added where we access parameters, and as a result, we can now endure 4-5 seconds of `cat /dev/urandom`. :D We generate EscapeSequenceStateMachine.h when building the in-kernel LibVT, and we assume that the file is already in place when the userland library is being built. This will probably cause problems later on, but I can't find a way to do it nicely.
Diffstat (limited to 'Meta/CMake')
-rw-r--r--Meta/CMake/all_the_debug_macros.cmake1
-rw-r--r--Meta/CMake/utils.cmake12
2 files changed, 13 insertions, 0 deletions
diff --git a/Meta/CMake/all_the_debug_macros.cmake b/Meta/CMake/all_the_debug_macros.cmake
index 5e729b1168..644dab935d 100644
--- a/Meta/CMake/all_the_debug_macros.cmake
+++ b/Meta/CMake/all_the_debug_macros.cmake
@@ -159,6 +159,7 @@ set(STORAGE_DEVICE_DEBUG ON)
set(TCP_DEBUG ON)
set(TERMCAP_DEBUG ON)
set(TERMINAL_DEBUG ON)
+set(ESCAPE_SEQUENCE_DEBUG ON)
set(UCI_DEBUG ON)
set(UDP_DEBUG ON)
set(UHCI_VERBOSE_DEBUG ON)
diff --git a/Meta/CMake/utils.cmake b/Meta/CMake/utils.cmake
index 396375bfbd..150d169f6c 100644
--- a/Meta/CMake/utils.cmake
+++ b/Meta/CMake/utils.cmake
@@ -154,3 +154,15 @@ function(embed_resource target section file)
)
target_sources("${target}" PRIVATE "${asm_file}")
endfunction()
+
+function(generate_state_machine source header)
+ set(source ${CMAKE_CURRENT_SOURCE_DIR}/${source})
+ add_custom_command(
+ OUTPUT ${header}
+ COMMAND ${write_if_different} ${header} ${CMAKE_BINARY_DIR}/Userland/DevTools/StateMachineGenerator/StateMachineGenerator ${source} > ${header}
+ VERBATIM
+ DEPENDS StateMachineGenerator
+ MAIN_DEPENDENCY ${source}
+ )
+ get_filename_component(output_name ${header} NAME)
+endfunction()