commit f78876521d3e93282ef194c6fd37ca0cc984cb29 Author: Bob Polis Date: Sat Dec 11 23:45:15 2021 +0100 first commit diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..0a19844 --- /dev/null +++ b/Makefile @@ -0,0 +1,34 @@ +LDLIBS := -lscterm + +BIN := $(shell basename $$(pwd)) + +SRCS := $(wildcard *.cpp) +OBJS := $(SRCS:.cpp=.o) +DEPS := $(SRCS:.cpp=.d) + +CXX ?= g++ +RM := /bin/rm -f + +CXXFLAGS += -Wshadow -Wall -Wpedantic -Wextra -g -std=c++17 +ifeq ($(DEBUG),1) + CXXFLAGS += -D DEBUG -O0 +else + CXXFLAGS += -D NDEBUG -O3 +endif + +.PHONY: all clean + +all: $(BIN) + +$(BIN): $(OBJS) $(DEPS) + $(CXX) $(LDFLAGS) $(LDLIBS) -o $(BIN) $(OBJS) + +%.o: %.cpp %.d + $(CXX) $(CXXFLAGS) -MMD -MP -MT $@ -MF $*.d -c $< + +-include *.d + +%.d: ; + +clean: + $(RM) $(OBJS) $(DEPS) $(BIN) diff --git a/progress.cpp b/progress.cpp new file mode 100644 index 0000000..32439eb --- /dev/null +++ b/progress.cpp @@ -0,0 +1,17 @@ +#include +#include +#include + +int main() { + sc::term term; + std::cout << term.rows() << " rows, " << term.cols() << " cols\n"; + sleep(1); + struct timespec tm; + tm.tv_nsec = 20000000; + tm.tv_sec = 0; + sc::cursor_hider ch; + for (int i = 0; i < 1000; ++i) { + term.progress(i, 1000); + nanosleep(&tm, nullptr); + } +}