Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
_build/
build/
15 changes: 15 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
message(STATUS "reading ${CMAKE_CURRENT_LIST_FILE}")
project(tqdm_test)

if (NOT DEFINED CMAKE_DEBUG_POSTFIX)
set(CMAKE_DEBUG_POSTFIX "_d")
include(GNUInstallDirs)
endif()

add_executable(${PROJECT_NAME} "")
set_target_properties(${PROJECT_NAME} PROPERTIES DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX})

target_sources(${PROJECT_NAME}
PRIVATE
test.cpp
)
8 changes: 8 additions & 0 deletions test.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
#include "tqdm.h"

#if _MSC_VER
#include <thread>
void usleep(int usec)
{
std::this_thread::sleep_for(std::chrono::microseconds(usec));
}
#endif

int main() {

int N = 2000;
Expand Down
7 changes: 6 additions & 1 deletion tqdm.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#ifndef TQDM_H
#define TQDM_H
#if _MSC_VER
#include <io.h>
#define isatty _isatty
#else
#include <unistd.h>
#endif
#include <chrono>
#include <ctime>
#include <numeric>
Expand Down Expand Up @@ -160,7 +165,7 @@ class tqdm {
}
}
for (int i = 0; i < ifills; i++) std::cout << bars[8];
if (!in_screen and (curr != tot)) printf("%s",bars[(int)(8.0*(fills-ifills))]);
if (!in_screen && (curr != tot)) printf("%s",bars[(int)(8.0*(fills-ifills))]);
for (int i = 0; i < width-ifills-1; i++) std::cout << bars[0];
printf("%s ", right_pad.c_str());
if (use_colors) printf("\033[1m\033[31m");
Expand Down