Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mRemoteNG/PuTTYNG.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2020-02-29 20:11:01 +0300
committerSimon Tatham <anakin@pobox.com>2020-03-01 23:09:01 +0300
commitd711cc849c38b6dd9d74a212efb0c8b765cebe59 (patch)
treec57034aec857a5544f10efa62532c5354fd8077a /cmdgen.c
parentcfa3f8b1929b6f954582d3820b246587878e728d (diff)
Add linear mode to the new progress reporting system.
The old system I removed in commit 79d3c1783b had both linear and exponential phase types, but the new one only had exponential, because at that point I'd just thrown away all the clients of the linear phase type. But I'm going to add another one shortly, so I have to put it back in.
Diffstat (limited to 'cmdgen.c')
-rw-r--r--cmdgen.c38
1 files changed, 35 insertions, 3 deletions
diff --git a/cmdgen.c b/cmdgen.c
index d48b3166..12d34065 100644
--- a/cmdgen.c
+++ b/cmdgen.c
@@ -16,8 +16,36 @@
#include "sshkeygen.h"
#include "mpint.h"
-FILE *progress_fp = NULL;
+static FILE *progress_fp = NULL;
+static bool linear_progress_phase;
+static unsigned last_progress_col;
+static ProgressPhase cmdgen_progress_add_linear(
+ ProgressReceiver *prog, double c)
+{
+ ProgressPhase ph = { .n = 0 };
+ return ph;
+}
+
+static ProgressPhase cmdgen_progress_add_probabilistic(
+ ProgressReceiver *prog, double c, double p)
+{
+ ProgressPhase ph = { .n = 1 };
+ return ph;
+}
+
+static void cmdgen_progress_start_phase(ProgressReceiver *prog,
+ ProgressPhase p)
+{
+ linear_progress_phase = (p.n == 0);
+ last_progress_col = 0;
+}
+static void cmdgen_progress_report(ProgressReceiver *prog, double p)
+{
+ unsigned new_col = p * 64 + 0.5;
+ for (; last_progress_col < new_col; last_progress_col++)
+ fputc('+', progress_fp);
+}
static void cmdgen_progress_report_attempt(ProgressReceiver *prog)
{
if (progress_fp) {
@@ -27,6 +55,8 @@ static void cmdgen_progress_report_attempt(ProgressReceiver *prog)
}
static void cmdgen_progress_report_phase_complete(ProgressReceiver *prog)
{
+ if (linear_progress_phase)
+ cmdgen_progress_report(prog, 1.0);
if (progress_fp) {
fputc('\n', progress_fp);
fflush(progress_fp);
@@ -34,9 +64,11 @@ static void cmdgen_progress_report_phase_complete(ProgressReceiver *prog)
}
static const ProgressReceiverVtable cmdgen_progress_vt = {
- null_progress_add_probabilistic,
+ cmdgen_progress_add_linear,
+ cmdgen_progress_add_probabilistic,
null_progress_ready,
- null_progress_start_phase,
+ cmdgen_progress_start_phase,
+ cmdgen_progress_report,
cmdgen_progress_report_attempt,
cmdgen_progress_report_phase_complete,
};