#!/usr/bin/env bash
. "$(dirname "$0")/../../share/hollywood/compat.sh"
#
# Copyright 2026 Dustin Kirkland <dustin.kirkland@gmail.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

command -v batcat >/dev/null 2>&1 || exit 1

trap hw_quit INT
while true; do
	f=$(find $HW_CODE_DIRS -name "*.py" -o -name "*.js" -o -name "*.c" -o -name "*.h" -o -name "*.sh" -o -name "*.pl" -o -name "*.rb" 2>/dev/null | sort -R | head -n1)
	[ -z "$f" ] && exit 1
	clear
	batcat --color=always --style=full --paging=never "$f" 2>/dev/null
	sleep 3
done
