From: Paul K. <pki...@ja...> - 2002-09-20 03:38:12
|
Hi all, I've been thinking about what we need for our semi-annual release of octave-forge. Clean support for 2.1.36 and the upcoming 2.1.37 are definite show-stoppers. I'm not comfortable abandoning the older versions though. The changes required for .cc files we could do through configure by testing for certain functions which changed since 2.1.35. The alternative is to test against specific octave version numbers in the code. E.g., #define _VERSION(a,b,c) (((a)<<16) + ((b)<<8) + (c)) #define OCTAVE_VERSION _VERSION(OCTAVE_MAJOR,OCTAVE_MINOR,OCTAVE_PATCHLEVEL) #if (OCTAVE_VERSION > _VERSION(2,1,35) ... #else /* OCTAVE_VERSION <= 2.1.35 */ ... #endif I'm in favour of the latter because it will be easier to implement. Off the top of my head, struct/*.cc and FIXES/fsolve.cc are broken. A more difficult problem is that lo-sstream.h is missing from the octave installation so a lot more things look broken than really are. I suppose we could keep our own copy somewhere (e.g., in FIXES) and use -I$(TOPDIR)/FIXES if octave version is 2.1.36. Or we could just document the problem. Unfortunately m-files will also have to change: * replace ... with varargin/varargout * replace all_va_args with varargin{:} * for [v,k]=struct ... end now sets v to a list rather than a value * anything else? We could use version tests in our code. We could use a preprocessor and set up make to convert file.m.in to file.m. We could have file.m-2.1.35 for example for versions up to and including 2.1.35 and file.m for later versions. I'm in favour of using a preprocessor because I'm not very good at fixing the same bug in multiple files, and since I do not want the overhead of run time version checks. The preprocessor could either strip the conditional code that isn't used or it could comment it out. I prefer stripping it entirely as a way of reducing the cruft we present to the user. Anyone want to write this? Or could we use something like the C preprocessor or M4 directly? Note that a preprocessor will also be useful to those who are trying to support both octave and matlab from the same codebase (e.g., ode and tsa) --- you might want to consider this in the design. A number of functions from octave-forge have been incorporated into octave. We need to conditionally ignore them during build and install. Adding test support to the makefiles for all the directories and running all the existing tests during make check is a worthy goal, but I doubt I will get to it this time round. Anything else? Paul Kienzle pki...@us... |
From: Quentin S. <qsp...@ie...> - 2002-09-20 12:01:27
|
Hello All, I have written a function that approximates the functionality of the Matlab waitbar function, which shows a progress bar for lengthy calculations. I would like to submit it for inclusion in octave-forge, but first I have a couple of questions. First is licensing--is there a preferred or required license to use? My second question has to do with the function itself. It is written in C, to make it as fast and unobtrusive (CPU-wise) as possible, and has similar syntax to the Matlab version, but with some differences because it is text, rather than graphics based. Originally I used a row of ASCII "#" characters across the terminal (which will look familiar to Linux users who have used the rpm -ivh command), however I have since modified the function to use reverse-video spaces using color-changing commands such as "\033[7m" in the printf command. I like the look of it better, but this raises the question of whether it will work in all environments. If this is to be made available to a wide audience, it needs to work in all possible environments. Are these commands universally recognized by all terminal programs in use today? Is there a better way to implement this that uses libraries already linked to by Octave? Is there a way to detect whether smart terminals are available at compile time? regards, Quentin Spencer |
From: Paul K. <pki...@ja...> - 2002-09-20 13:24:54
|
On Fri, Sep 20, 2002 at 02:01:23PM +0200, Quentin Spencer wrote: > Hello All, > > I have written a function that approximates the functionality of the > Matlab waitbar function, which shows a progress bar for lengthy > calculations. I would like to submit it for inclusion in octave-forge, > but first I have a couple of questions. First is licensing--is there a > preferred or required license to use? Scripts must be freely redistributable with modifications. Either GPL, BSD or public domain is fine. For oct-files, the portion which interfaces with octave must be GPL (because the octave support routines are GPL) and the rest must be compatible with the GPL (because they are called by a GPL program). > > My second question has to do with the function itself. It is written in > C, to make it as fast and unobtrusive (CPU-wise) as possible, and has > similar syntax to the Matlab version, but with some differences because > it is text, rather than graphics based. Originally I used a row of ASCII > "#" characters across the terminal (which will look familiar to Linux > users who have used the rpm -ivh command), however I have since modified > the function to use reverse-video spaces using color-changing commands > such as "\033[7m" in the printf command. I like the look of it better, > but this raises the question of whether it will work in all > environments. If this is to be made available to a wide audience, it > needs to work in all possible environments. Are these commands > universally recognized by all terminal programs in use today? Is there a > better way to implement this that uses libraries already linked to by > Octave? Is there a way to detect whether smart terminals are available > at compile time? You might find something in the curses library (man ncurses on my box). You are going to need some configuration information in the form of a configure.add and Makeconf.add. You can model them after the ones in image for detecting the jpeg library. Check for both curses and ncurses, and if neither exist fall back to '#'. Note that octave already checks for these because readline needs them, but readline can also fall back to termio or termios which are no good to you. > > regards, > Quentin Spencer > > > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > Octave-dev mailing list > Oct...@li... > https://lists.sourceforge.net/lists/listinfo/octave-dev |
From: Quentin S. <qsp...@ie...> - 2002-11-07 00:58:42
Attachments:
waitbar.cc
|
Dear octave community, Attached is a waitbar function that I discussed in a earlier mail a few weeks ago. It approximates the Matlab command by the same name, but uses terminal functions rather than graphics, and attempts to use compatible syntax as much as possible. It has code for compilation both with and without the "term.h" system header by looking for the HAVE_TERM_H flag. I have not figured out how to generate the associated config.in files, as my knowledge of these tools is minimal. If someone is willing to do this, or can explain in a short e-mail how this is done, please do so. Also a second, unrelated question. Since upgrading my RedHat system to version 8.0 with GCC 3.2, and updating octave to 2.1.39, octave-forge does not compile. Is this a known problem? thanks, Quentin Spencer |
From: Etienne G. <et...@is...> - 2002-11-07 11:37:58
|
Hello, nice function! Nice in a gnome-terminal, at least. In a xterm, when the value spans [0,1], the displayed %NN starts in the middle and *moves left* until it reaches the edge. Then, the %NN disappears and the white bar progresses until it reaches the middle of the line. Will try to fix and see about $OF/configure.base and Makeconf.base. Cheers, Etienne On Thu, Nov 07, 2002 at 01:58:40AM +0100, Quentin Spencer wrote: # Dear octave community, # # Attached is a waitbar function that I discussed in a earlier mail a few # weeks ago. It approximates the Matlab command by the same name, but uses # terminal functions rather than graphics, and attempts to use compatible # syntax as much as possible. It has code for compilation both with and # without the "term.h" system header by looking for the HAVE_TERM_H flag. # I have not figured out how to generate the associated config.in files, # as my knowledge of these tools is minimal. If someone is willing to do # this, or can explain in a short e-mail how this is done, please do so. # # Also a second, unrelated question. Since upgrading my RedHat system to # version 8.0 with GCC 3.2, and updating octave to 2.1.39, octave-forge # does not compile. Is this a known problem? I think Paul mentioned this, but I did not look into it. # thanks, # Quentin Spencer # # # /************************************************************************** # * Waitbar function -- displays progress of lengthy calculations # * ------------------------------------------------------------- # * Copyright (c) 2002 Quentin Spencer (qsp...@ie...) # * # * This library is free software; you can redistribute it and/or # * modify it under the terms of the GNU Library General Public # * License as published by the Free Software Foundation; either # * version 2 of the License, or (at your option) any later version. # * # * This library is distributed in the hope that it will be useful, # * but WITHOUT ANY WARRANTY; without even the implied warranty of # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # * Library General Public License for more details. # * # * You should have received a copy of the GNU Library General Public # * License along with this library; if not, write to the Free # * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA # * 02111-1307 USA # * # * # *************************************************************************/ # # #include "octave/oct.h" # #if HAVE_TERM_H # #include "term.h" # #endif # # #define BUF_SIZE 256 # #define MAX_LEN 240 # #define DEFAULT_LEN 50 # #define BAR_CHAR '#' # # DEFUN_DLD(waitbar, args, nargout, # "waitbar(...);\n\ # WAITBAR displays a text-based wait bar. This function\n\ # is similar to the Matlab waitbar command, but it is\n\ # a text, rather than graphical function.\n\n\ # A typical usage of WAITBAR in a lengthy computation\n\ # (inside a FOR loop, for example) is as follows:\n\n\ # for i=1:1000\n\ # ## computation\n\ # waitbar(i/1000);\n\ # end\n\n\ # WAITBAR(X), where 0 <= X <= 1, sets the position of the\n\ # waitbar to the fractional length X. Values of X exactly equal\n\ # to 0 or 1 clear the waitbar.\n\n\ # If Octave is running in a smart terminal, the width is\n\ # automatically detected. Otherwise, it is initialized to a\n\ # default of 50 characters, or it can be set to N characters\n\ # with WAITBAR(0,N). If no terminal is detected (such as when\n\ # Octave is run in batch mode and output is redirected), no\n\ # output is generated.\n\n\ # For compatibility with the Matlab version of this function\n\ # (which is graphical rather than text-based), additional\n\ # arguments are ignored, but there are no guarantees of perfect\n\ # compatibility.") # { # static char print_buf[BUF_SIZE]; # static int n_chars_old; # static int pct_int_old; # static int length; # #if HAVE_TERM_H # static char term_buffer[1024]; # static char *begin_rv, *end_rv; # static int brvlen, ervlen; # static bool smart_term; # int j; # #endif # static char *term; # static bool init; # # Matrix arg; # float pct; # int i; # # octave_value_list retval; # int nargin = args.length(); # if (nargin < 1) { # print_usage("waitbar"); # return retval; # } # # if(no_terminal) # return retval; # # arg = args(0).matrix_value(); # pct = arg(0,0); # if(pct>1.0) pct = 1.0; // to prevent overflow # # if(pct==0.0 || pct==1.0) # { # init = true; # term = getenv("TERM"); # if(!term) # { # no_terminal = true; # return retval; # } # #if HAVE_TERM_H # i = tgetnum("co"); # smart_term = i ? true : false; # #endif # if(nargin==1) # #if HAVE_TERM_H # length = smart_term ? i-1 : DEFAULT_LEN; # #else # length = DEFAULT_LEN; # #endif # else # { # length = args(1).int_value(); # if(length>MAX_LEN) length = MAX_LEN; # if(length<=0) length = DEFAULT_LEN; # } # #if HAVE_TERM_H # if(smart_term) # { # // get terminal strings # char* buf_ptr = term_buffer; # begin_rv = tgetstr("so", &buf_ptr); # end_rv = tgetstr("se", &buf_ptr); # brvlen = 0; buf_ptr = begin_rv; # while(buf_ptr[brvlen]) brvlen++; # ervlen = 0; buf_ptr = end_rv; # while(buf_ptr[ervlen]) ervlen++; # # // initialize print buffer # for(i=0; i<BUF_SIZE; ++i) # print_buf[i] = ' '; # print_buf[length+brvlen+ervlen+1] = '\r'; # print_buf[length+brvlen+ervlen+2] = '\0'; # for(i=0; i<brvlen; ++i) # print_buf[i] = begin_rv[i]; # for(i=0; i<ervlen; ++i) # print_buf[i+brvlen] = end_rv[i]; # printf(print_buf); # } # else # { # #endif # for(i=0; i<BUF_SIZE; ++i) # print_buf[i] = ' '; # print_buf[length+8] = '\r'; # print_buf[length+9] = '\0'; # printf(print_buf); # print_buf[0] = '['; # print_buf[length+1] = ']'; # #if HAVE_TERM_H # } # #endif # n_chars_old = 0; # fflush(stdout); # return retval; # } # else # { # // calculate position # int n_chars=(int)(pct*length+0.5); # int pct_int=(int)(pct*100.0+0.5); # # // check to see if we got this far without initialization # if(init==false) # { # Fwaitbar(0.0,0); # printf(print_buf); # fflush(stdout); # } # # // check to see of output needs to be updated # if(n_chars!=n_chars_old || pct_int!=pct_int_old) # { # #if HAVE_TERM_H # if(smart_term) # { # static char pct_str[6]; # int half = length/2-1; # sprintf(pct_str,"%3i%%%%",pct_int); # # // Clear old percentage string # for(i=half, j=0; j<5; ++i, ++j) # if(i>n_chars_old) # print_buf[i+brvlen+ervlen] = ' '; # else # print_buf[i+brvlen] = ' '; # # // Clear old and insert new end of bold stuff # for(i=n_chars_old+brvlen+1; i<n_chars_old+brvlen+ervlen+1; ++i) # print_buf[i] = ' '; # for(i=n_chars+brvlen+1, j=0; i<n_chars+brvlen+ervlen+1; ++i, ++j) # print_buf[i] = end_rv[j]; # # // Insert the percentage string # for(i=half, j=0; j<5; ++i, ++j) # if(i>n_chars) # print_buf[i+brvlen+ervlen] = pct_str[j]; # else # print_buf[i+brvlen] = pct_str[j]; # } # else # { # #endif # if(n_chars>=n_chars_old) # for(int i=n_chars_old+1; i<=n_chars; ++i) # print_buf[i] = BAR_CHAR; # else # for(int i=n_chars+1; i<=n_chars_old; ++i) # print_buf[i] = ' '; # sprintf(&(print_buf[length+3])," %3i%%\r",pct_int); # #if HAVE_TERM_H # } # #endif # printf(print_buf); # fflush(stdout); # n_chars_old = n_chars; # pct_int_old = pct_int; # } # } # return retval; # } # -- Etienne Grossmann ------ http://www.isr.ist.utl.pt/~etienne |
From: Quentin S. <qsp...@ie...> - 2002-11-07 17:48:44
|
I recall someone recently on one of these lists looking for that "Da Coda Al Fine" document from the now-defunct hammersmith-consulting.com. I just found a copy of it in some of my old archives. If the maintainer (whichever one of you it is) is interested in putting this link back on the main octave.sf.net page, contact me and I'll send you the file. Quentin Spencer |
From: Paul K. <pki...@ja...> - 2002-11-07 18:07:14
|
Sure, send it my way. Paul Kienzle pki...@us... On Thu, Nov 07, 2002 at 06:09:14PM +0100, Quentin Spencer wrote: > I recall someone recently on one of these lists looking for that "Da > Coda Al Fine" document from the now-defunct hammersmith-consulting.com. > I just found a copy of it in some of my old archives. If the maintainer > (whichever one of you it is) is interested in putting this link back on > the main octave.sf.net page, contact me and I'll send you the file. > > Quentin Spencer > > > > > ------------------------------------------------------- > This sf.net email is sponsored by: See the NEW Palm > Tungsten T handheld. Power & Color in a compact size! > http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0001en > _______________________________________________ > Octave-dev mailing list > Oct...@li... > https://lists.sourceforge.net/lists/listinfo/octave-dev |
From: Quentin S. <qsp...@ie...> - 2002-11-11 23:59:22
Attachments:
waitbar.cc
|
Hello, Here's my fix to the waitbar function. If you can figure out the configure stuff, go ahead and put it into octave-forge. The problem was some escape characters that weren't being cleared and it seems xterm reacts to this differently than the KDE and GNOME terminals. cheers, Quentin Etienne Grossmann wrote: > Hello, > >nice function! Nice in a gnome-terminal, at least. In a xterm, when >the value spans [0,1], the displayed %NN starts in the middle and >*moves left* until it reaches the edge. Then, the %NN disappears and >the white bar progresses until it reaches the middle of the line. > > Will try to fix and see about $OF/configure.base and Makeconf.base. > > Cheers, > > Etienne > |
From: Etienne G. <et...@is...> - 2002-11-12 15:41:05
|
Hello, just to say that I commited Quentin Spencer's waitbar.cc on octave-forge, in main/miscellaneous. I also added main/miscellaneous/(Makeconf.add|configure.add|Makefile) so that the header file term.h be searched for when ./configure is run. I inspired myself from the files in main/image/ for this purpose. Could people check that all is ok? (don't forget to do ./autogen.sh so that ./configure be generated). ./autogen.sh # Generate ./configure ./configure # Should give a message about term.h make # Should build waitbar.cc and then check that, in octave, N=50; for i=0:N ; waitbar (i/N); sleep(2/N); end produces a progressing waitbar? Cheers, Etienne On Tue, Nov 12, 2002 at 12:59:16AM +0100, Quentin Spencer wrote: # Hello, # # Here's my fix to the waitbar function. If you can figure out the # configure stuff, go ahead and put it into octave-forge. The problem was # some escape characters that weren't being cleared and it seems xterm # reacts to this differently than the KDE and GNOME terminals. # # cheers, # Quentin # # # # Etienne Grossmann wrote: # # > Hello, # > # >nice function! Nice in a gnome-terminal, at least. In a xterm, when # >the value spans [0,1], the displayed %NN starts in the middle and # >*moves left* until it reaches the edge. Then, the %NN disappears and # >the white bar progresses until it reaches the middle of the line. # > # > Will try to fix and see about $OF/configure.base and Makeconf.base. # > # > Cheers, # > # > Etienne # > # # # /************************************************************************** # * Waitbar function -- displays progress of lengthy calculations # * ------------------------------------------------------------- # * Copyright (c) 2002 Quentin Spencer (qsp...@ie...) # * # * This library is free software; you can redistribute it and/or # * modify it under the terms of the GNU Library General Public # * License as published by the Free Software Foundation; either # * version 2 of the License, or (at your option) any later version. # * # * This library is distributed in the hope that it will be useful, # * but WITHOUT ANY WARRANTY; without even the implied warranty of # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # * Library General Public License for more details. # * # * You should have received a copy of the GNU Library General Public # * License along with this library; if not, write to the Free # * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA # * 02111-1307 USA # * # * # *************************************************************************/ # # #include "octave/oct.h" # #define HAVE_TERM_H 1 # #if HAVE_TERM_H # #include "term.h" # #endif # # #define BUF_SIZE 256 # #define MAX_LEN 240 # #define DEFAULT_LEN 50 # #define BAR_CHAR '#' # # static bool no_terminal=false; # # DEFUN_DLD(waitbar, args, nargout, # "waitbar(...);\n\ # WAITBAR displays a text-based wait bar. This function\n\ # is similar to the Matlab waitbar command, but it is\n\ # a text, rather than graphical function.\n\n\ # A typical usage of WAITBAR in a lengthy computation\n\ # (inside a FOR loop, for example) is as follows:\n\n\ # for i=1:1000\n\ # ## computation\n\ # waitbar(i/1000);\n\ # end\n\n\ # WAITBAR(X), where 0 <= X <= 1, sets the position of the\n\ # waitbar to the fractional length X. Values of X exactly equal\n\ # to 0 or 1 clear the waitbar.\n\n\ # If Octave is running in a smart terminal, the width is\n\ # automatically detected. Otherwise, it is initialized to a\n\ # default of 50 characters, or it can be set to N characters\n\ # with WAITBAR(0,N). If no terminal is detected (such as when\n\ # Octave is run in batch mode and output is redirected), no\n\ # output is generated.\n\n\ # For compatibility with the Matlab version of this function\n\ # (which is graphical rather than text-based), additional\n\ # arguments are ignored, but there are no guarantees of perfect\n\ # compatibility.") # { # static char print_buf[BUF_SIZE]; # static int n_chars_old; # static int pct_int_old; # static int length; # #if HAVE_TERM_H # static char term_buffer[1024]; # static char *begin_rv, *end_rv; # static int brvlen, ervlen; # static bool smart_term; # int j; # #endif # static char *term; # static bool init; # # Matrix arg; # float pct; # int i; # # octave_value_list retval; # int nargin = args.length(); # if (nargin < 1) { # print_usage("waitbar"); # return retval; # } # # if(no_terminal) # return retval; # # arg = args(0).matrix_value(); # pct = arg(0,0); # if(pct>1.0) pct = 1.0; // to prevent overflow # # if(pct==0.0 || pct==1.0) # { # init = true; # term = getenv("TERM"); # if(!term) # { # no_terminal = true; # return retval; # } # #if HAVE_TERM_H # i = tgetnum("co"); # smart_term = i ? true : false; # #endif # if(nargin==1) # #if HAVE_TERM_H # length = smart_term ? i-1 : DEFAULT_LEN; # #else # length = DEFAULT_LEN; # #endif # else # { # length = args(1).int_value(); # if(length>MAX_LEN) length = MAX_LEN; # if(length<=0) length = DEFAULT_LEN; # } # #if HAVE_TERM_H # if(smart_term) # { # // get terminal strings ("rv"="reverse video") # char* buf_ptr = term_buffer; # begin_rv = tgetstr("so", &buf_ptr); # end_rv = tgetstr("se", &buf_ptr); # brvlen = 0; buf_ptr = begin_rv; # while(buf_ptr[++brvlen]); # ervlen = 0; buf_ptr = end_rv; # while(buf_ptr[++ervlen]); # # // initialize print buffer # for(i=0; i<BUF_SIZE; ++i) # print_buf[i] = ' '; # print_buf[length+brvlen+ervlen+1] = '\r'; # print_buf[length+brvlen+ervlen+2] = '\0'; # for(i=0; i<brvlen; ++i) # print_buf[i] = begin_rv[i]; # for(i=0; i<ervlen; ++i) # print_buf[i+brvlen] = end_rv[i]; # printf(print_buf); # } # else # { # #endif # for(i=0; i<BUF_SIZE; ++i) # print_buf[i] = ' '; # print_buf[length+8] = '\r'; # print_buf[length+9] = '\0'; # printf(print_buf); # print_buf[0] = '['; # print_buf[length+1] = ']'; # #if HAVE_TERM_H # } # #endif # n_chars_old = 0; # fflush(stdout); # return retval; # } # else # { # // calculate position # int n_chars=(int)(pct*length+0.5); # int pct_int=(int)(pct*100.0+0.5); # # // check to see if we got this far without initialization # if(init==false) # { # Fwaitbar(0.0,0); # printf(print_buf); # fflush(stdout); # } # # // check to see of output needs to be updated # if(n_chars!=n_chars_old || pct_int!=pct_int_old) # { # #if HAVE_TERM_H # if(smart_term) # { # static char pct_str[6]; # int half = length/2-1; # sprintf(pct_str,"%3i%%%%",pct_int); # # // Clear old percentage string # for(i=half, j=0; j<5; ++i, ++j) # if(i>=n_chars_old) # print_buf[i+brvlen+ervlen] = ' '; # else # print_buf[i+brvlen] = ' '; # # // Clear old and insert new end of reverse video # for(i=n_chars_old+brvlen; i<n_chars_old+brvlen+ervlen; ++i) # print_buf[i] = ' '; # for(i=n_chars+brvlen, j=0; j<ervlen; ++i, ++j) # print_buf[i] = end_rv[j]; # # // Insert the percentage string # for(i=half, j=0; j<5; ++i, ++j) # if(i>=n_chars) # print_buf[i+brvlen+ervlen] = pct_str[j]; # else # print_buf[i+brvlen] = pct_str[j]; # } # else # { # #endif # if(n_chars>=n_chars_old) # for(int i=n_chars_old+1; i<=n_chars; ++i) # print_buf[i] = BAR_CHAR; # else # for(int i=n_chars+1; i<=n_chars_old; ++i) # print_buf[i] = ' '; # sprintf(&(print_buf[length+3])," %3i%%\r",pct_int); # #if HAVE_TERM_H # } # #endif # printf(print_buf); # fflush(stdout); # n_chars_old = n_chars; # pct_int_old = pct_int; # } # } # return retval; # } -- Etienne Grossmann ------ http://www.isr.ist.utl.pt/~etienne |
From: Paul K. <pki...@ja...> - 2002-11-13 14:41:18
|
I twiddled the build files for waitbar a little so that it will at least compile on cygwin. Unfortunately octave core dumps when I try to run it. Please try my changes on your configuration. As Etienne says, do ./autogen.sh; ./configure; from the octave-forge directory before doing make. - Paul On Tue, Nov 12, 2002 at 03:51:03PM +0000, Etienne Grossmann wrote: > > Hello, > > just to say that I commited Quentin Spencer's waitbar.cc on > octave-forge, in main/miscellaneous. > > I also added > > main/miscellaneous/(Makeconf.add|configure.add|Makefile) > > so that the header file term.h be searched for when ./configure is > run. I inspired myself from the files in main/image/ for this purpose. > > Could people check that all is ok? (don't forget to do ./autogen.sh > so that ./configure be generated). > > ./autogen.sh # Generate ./configure > ./configure # Should give a message about term.h > make # Should build waitbar.cc > > and then check that, in octave, > > N=50; for i=0:N ; waitbar (i/N); sleep(2/N); end > > produces a progressing waitbar? > > Cheers, > > Etienne > > > On Tue, Nov 12, 2002 at 12:59:16AM +0100, Quentin Spencer wrote: > # Hello, > # > # Here's my fix to the waitbar function. If you can figure out the > # configure stuff, go ahead and put it into octave-forge. The problem was > # some escape characters that weren't being cleared and it seems xterm > # reacts to this differently than the KDE and GNOME terminals. > # > # cheers, > # Quentin > # > # > # > # Etienne Grossmann wrote: > # > # > Hello, > # > > # >nice function! Nice in a gnome-terminal, at least. In a xterm, when > # >the value spans [0,1], the displayed %NN starts in the middle and > # >*moves left* until it reaches the edge. Then, the %NN disappears and > # >the white bar progresses until it reaches the middle of the line. > # > > # > Will try to fix and see about $OF/configure.base and Makeconf.base. > # > > # > Cheers, > # > > # > Etienne > # > > # > # > > # /************************************************************************** > # * Waitbar function -- displays progress of lengthy calculations > # * ------------------------------------------------------------- > # * Copyright (c) 2002 Quentin Spencer (qsp...@ie...) > # * > # * This library is free software; you can redistribute it and/or > # * modify it under the terms of the GNU Library General Public > # * License as published by the Free Software Foundation; either > # * version 2 of the License, or (at your option) any later version. > # * > # * This library is distributed in the hope that it will be useful, > # * but WITHOUT ANY WARRANTY; without even the implied warranty of > # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > # * Library General Public License for more details. > # * > # * You should have received a copy of the GNU Library General Public > # * License along with this library; if not, write to the Free > # * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA > # * 02111-1307 USA > # * > # * > # *************************************************************************/ > # > # #include "octave/oct.h" > # #define HAVE_TERM_H 1 > # #if HAVE_TERM_H > # #include "term.h" > # #endif > # > # #define BUF_SIZE 256 > # #define MAX_LEN 240 > # #define DEFAULT_LEN 50 > # #define BAR_CHAR '#' > # > # static bool no_terminal=false; > # > # DEFUN_DLD(waitbar, args, nargout, > # "waitbar(...);\n\ > # WAITBAR displays a text-based wait bar. This function\n\ > # is similar to the Matlab waitbar command, but it is\n\ > # a text, rather than graphical function.\n\n\ > # A typical usage of WAITBAR in a lengthy computation\n\ > # (inside a FOR loop, for example) is as follows:\n\n\ > # for i=1:1000\n\ > # ## computation\n\ > # waitbar(i/1000);\n\ > # end\n\n\ > # WAITBAR(X), where 0 <= X <= 1, sets the position of the\n\ > # waitbar to the fractional length X. Values of X exactly equal\n\ > # to 0 or 1 clear the waitbar.\n\n\ > # If Octave is running in a smart terminal, the width is\n\ > # automatically detected. Otherwise, it is initialized to a\n\ > # default of 50 characters, or it can be set to N characters\n\ > # with WAITBAR(0,N). If no terminal is detected (such as when\n\ > # Octave is run in batch mode and output is redirected), no\n\ > # output is generated.\n\n\ > # For compatibility with the Matlab version of this function\n\ > # (which is graphical rather than text-based), additional\n\ > # arguments are ignored, but there are no guarantees of perfect\n\ > # compatibility.") > # { > # static char print_buf[BUF_SIZE]; > # static int n_chars_old; > # static int pct_int_old; > # static int length; > # #if HAVE_TERM_H > # static char term_buffer[1024]; > # static char *begin_rv, *end_rv; > # static int brvlen, ervlen; > # static bool smart_term; > # int j; > # #endif > # static char *term; > # static bool init; > # > # Matrix arg; > # float pct; > # int i; > # > # octave_value_list retval; > # int nargin = args.length(); > # if (nargin < 1) { > # print_usage("waitbar"); > # return retval; > # } > # > # if(no_terminal) > # return retval; > # > # arg = args(0).matrix_value(); > # pct = arg(0,0); > # if(pct>1.0) pct = 1.0; // to prevent overflow > # > # if(pct==0.0 || pct==1.0) > # { > # init = true; > # term = getenv("TERM"); > # if(!term) > # { > # no_terminal = true; > # return retval; > # } > # #if HAVE_TERM_H > # i = tgetnum("co"); > # smart_term = i ? true : false; > # #endif > # if(nargin==1) > # #if HAVE_TERM_H > # length = smart_term ? i-1 : DEFAULT_LEN; > # #else > # length = DEFAULT_LEN; > # #endif > # else > # { > # length = args(1).int_value(); > # if(length>MAX_LEN) length = MAX_LEN; > # if(length<=0) length = DEFAULT_LEN; > # } > # #if HAVE_TERM_H > # if(smart_term) > # { > # // get terminal strings ("rv"="reverse video") > # char* buf_ptr = term_buffer; > # begin_rv = tgetstr("so", &buf_ptr); > # end_rv = tgetstr("se", &buf_ptr); > # brvlen = 0; buf_ptr = begin_rv; > # while(buf_ptr[++brvlen]); > # ervlen = 0; buf_ptr = end_rv; > # while(buf_ptr[++ervlen]); > # > # // initialize print buffer > # for(i=0; i<BUF_SIZE; ++i) > # print_buf[i] = ' '; > # print_buf[length+brvlen+ervlen+1] = '\r'; > # print_buf[length+brvlen+ervlen+2] = '\0'; > # for(i=0; i<brvlen; ++i) > # print_buf[i] = begin_rv[i]; > # for(i=0; i<ervlen; ++i) > # print_buf[i+brvlen] = end_rv[i]; > # printf(print_buf); > # } > # else > # { > # #endif > # for(i=0; i<BUF_SIZE; ++i) > # print_buf[i] = ' '; > # print_buf[length+8] = '\r'; > # print_buf[length+9] = '\0'; > # printf(print_buf); > # print_buf[0] = '['; > # print_buf[length+1] = ']'; > # #if HAVE_TERM_H > # } > # #endif > # n_chars_old = 0; > # fflush(stdout); > # return retval; > # } > # else > # { > # // calculate position > # int n_chars=(int)(pct*length+0.5); > # int pct_int=(int)(pct*100.0+0.5); > # > # // check to see if we got this far without initialization > # if(init==false) > # { > # Fwaitbar(0.0,0); > # printf(print_buf); > # fflush(stdout); > # } > # > # // check to see of output needs to be updated > # if(n_chars!=n_chars_old || pct_int!=pct_int_old) > # { > # #if HAVE_TERM_H > # if(smart_term) > # { > # static char pct_str[6]; > # int half = length/2-1; > # sprintf(pct_str,"%3i%%%%",pct_int); > # > # // Clear old percentage string > # for(i=half, j=0; j<5; ++i, ++j) > # if(i>=n_chars_old) > # print_buf[i+brvlen+ervlen] = ' '; > # else > # print_buf[i+brvlen] = ' '; > # > # // Clear old and insert new end of reverse video > # for(i=n_chars_old+brvlen; i<n_chars_old+brvlen+ervlen; ++i) > # print_buf[i] = ' '; > # for(i=n_chars+brvlen, j=0; j<ervlen; ++i, ++j) > # print_buf[i] = end_rv[j]; > # > # // Insert the percentage string > # for(i=half, j=0; j<5; ++i, ++j) > # if(i>=n_chars) > # print_buf[i+brvlen+ervlen] = pct_str[j]; > # else > # print_buf[i+brvlen] = pct_str[j]; > # } > # else > # { > # #endif > # if(n_chars>=n_chars_old) > # for(int i=n_chars_old+1; i<=n_chars; ++i) > # print_buf[i] = BAR_CHAR; > # else > # for(int i=n_chars+1; i<=n_chars_old; ++i) > # print_buf[i] = ' '; > # sprintf(&(print_buf[length+3])," %3i%%\r",pct_int); > # #if HAVE_TERM_H > # } > # #endif > # printf(print_buf); > # fflush(stdout); > # n_chars_old = n_chars; > # pct_int_old = pct_int; > # } > # } > # return retval; > # } > > > -- > Etienne Grossmann ------ http://www.isr.ist.utl.pt/~etienne > > > ------------------------------------------------------- > This sf.net email is sponsored by: > To learn the basics of securing your web site with SSL, > click here to get a FREE TRIAL of a Thawte Server Certificate: > http://www.gothawte.com/rd522.html > _______________________________________________ > Octave-dev mailing list > Oct...@li... > https://lists.sourceforge.net/lists/listinfo/octave-dev |
From: Etienne G. <et...@is...> - 2002-09-20 15:34:59
|
Hi all On Thu, Sep 19, 2002 at 11:37:56PM -0400, Paul Kienzle wrote: # Hi all, # [snip] # # Off the top of my head, struct/*.cc and FIXES/fsolve.cc are broken. A more ^^ In 2.1.37, you mean? # difficult problem is that lo-sstream.h is missing from the octave installation # so a lot more things look broken than really are. I suppose we could # keep our own copy somewhere (e.g., in FIXES) and use -I$(TOPDIR)/FIXES if # octave version is 2.1.36. Or we could just document the problem. # # Unfortunately m-files will also have to change: # * replace ... with varargin/varargout # * replace all_va_args with varargin{:} # * for [v,k]=struct ... end now sets v to a list rather than a value # * anything else? # # We could use version tests in our code. ^^ Can that do 'function foo (x,...)' and 'function foo (x,varargin)' # We could use a preprocessor and set up make to convert file.m.in to file.m. # We could have file.m-2.1.35 for example for versions up to and including # 2.1.35 and file.m for later versions. # # I'm in favour of using a preprocessor because I'm not very good at fixing I prefer the preprocessor option too. [snip] # Anything else? What about supporting 2.1.36, and the day 2.1.37 comes out, we fix things (duration : a few weeks) and release a new octave-forge when it's done. No worries until 2.1.37, none one month after it comes either. Or am I over-optimistic? Cheers, Etienne # Paul Kienzle # pki...@us... |
From: Paul K. <pki...@ja...> - 2002-09-20 15:51:05
|
On Fri, Sep 20, 2002 at 04:43:53PM +0100, Etienne Grossmann wrote: > > Hi all > > On Thu, Sep 19, 2002 at 11:37:56PM -0400, Paul Kienzle wrote: > # Hi all, > # > [snip] > # > # Off the top of my head, struct/*.cc and FIXES/fsolve.cc are broken. A more > ^^ > In 2.1.37, you mean? Perhaps. I've built from CVS so it's not clear what version I'm working with. > > # > # Unfortunately m-files will also have to change: > # * replace ... with varargin/varargout > # * replace all_va_args with varargin{:} > # * for [v,k]=struct ... end now sets v to a list rather than a value > # * anything else? > # > # We could use version tests in our code. > > ^^ > Can that do 'function foo (x,...)' and 'function foo (x,varargin)' Good point. Preprocessor it is. [snip] > # Anything else? > > What about supporting 2.1.36, and the day 2.1.37 comes out, we fix > things (duration : a few weeks) and release a new octave-forge when > it's done. No worries until 2.1.37, none one month after it comes > either. Or am I over-optimistic? Okay, so 2.1.37 is not a show stopper for this release, but 2.1.36 issues are. No reason not to try supporting 2.1.37 if like me you are building from CVS since it will have to be done eventually. - Paul |
From: Etienne G. <et...@is...> - 2002-09-20 16:37:08
|
Hello, On Fri, Sep 20, 2002 at 11:51:00AM -0400, Paul Kienzle wrote: # On Fri, Sep 20, 2002 at 04:43:53PM +0100, Etienne Grossmann wrote: # > # > Hi all # > # > On Thu, Sep 19, 2002 at 11:37:56PM -0400, Paul Kienzle wrote: # > # Hi all, # > # # > [snip] # > # # > # Off the top of my head, struct/*.cc and FIXES/fsolve.cc are broken. A more # > ^^ # > In 2.1.37, you mean? # # Perhaps. I've built from CVS so it's not clear what version I'm working with. Iirc, CVS says 2.1.37. When I used it, it broke more things than I was willing to fix (I needed a working octave to do some work), so I put 2.1.36 back. [snip] # # Okay, so 2.1.37 is not a show stopper for this release, but 2.1.36 issues # are. No reason not to try supporting 2.1.37 if like me you are building My hope is that 2.1.37 will break less things than CVS. I prefer focus on debugging and smoothing corners in octave-forge+octave-2.1.36 first; also because I cannot spend too much time on octave-forge. Sorry for not being of more help. Etienne PS : However, I can take care of changing all the is_XXX into isXXX. # from CVS since it will have to be done eventually. # # - Paul # # -- Etienne Grossmann ------ http://www.isr.ist.utl.pt/~etienne |