From 1fa490b066606e95c0e3d84d1a012cecfa54b2a5 Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Fri, 5 Jan 2024 03:13:51 +0100 Subject: [PATCH] some fixes on numerical cursor adjustments (for log X scales) --- src/callback.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/callback.c b/src/callback.c index 4f2c7eb5..5f657df9 100644 --- a/src/callback.c +++ b/src/callback.c @@ -418,10 +418,12 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int /* Numerically set cursor position */ if( (xctx->graph_flags & 2) && fabs(xctx->mousex - W_X(xctx->graph_cursor1_x)) < 10) { if(gr->logx) { - double pos = pow(xctx->graph_cursor1_x, 10); + double pos = pow(10., xctx->graph_cursor1_x); tclvareval("input_line {Pos:} {} ", dtoa_eng(pos), NULL); - pos = mylog10(atof_eng(tclresult())); - tclvareval("xschem set cursor1_x ", dtoa(pos), NULL); + if(tclresult()[0]) { + pos = mylog10(atof_eng(tclresult())); + tclvareval("xschem set cursor1_x ", dtoa(pos), NULL); + } } else { tclvareval("input_line {Pos:} {xschem set cursor1_x} ", dtoa_eng(xctx->graph_cursor1_x), NULL); } @@ -430,10 +432,12 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int } if( (xctx->graph_flags & 4) && fabs(xctx->mousex - W_X(xctx->graph_cursor2_x)) < 10) { if(gr->logx) { - double pos = pow(xctx->graph_cursor2_x, 10); + double pos = pow(10., xctx->graph_cursor2_x); tclvareval("input_line {Pos:} {} ", dtoa_eng(pos), NULL); - pos = mylog10(atof_eng(tclresult())); - tclvareval("xschem set cursor2_x ", dtoa(pos), NULL); + if(tclresult()[0]) { + pos = mylog10(atof_eng(tclresult())); + tclvareval("xschem set cursor2_x ", dtoa(pos), NULL); + } } else { tclvareval("input_line {Pos:} {xschem set cursor2_x} ", dtoa_eng(xctx->graph_cursor2_x), NULL); }