Blame src/ColumnOutput.h

Packit 8f70b4
/*
Packit 8f70b4
 * lftp - file transfer program
Packit 8f70b4
 *
Packit 8f70b4
 * Copyright (c) 1996-2012 by Alexander V. Lukyanov (lav@yars.free.net)
Packit 8f70b4
 *
Packit 8f70b4
 * This program is free software; you can redistribute it and/or modify
Packit 8f70b4
 * it under the terms of the GNU General Public License as published by
Packit 8f70b4
 * the Free Software Foundation; either version 3 of the License, or
Packit 8f70b4
 * (at your option) any later version.
Packit 8f70b4
 *
Packit 8f70b4
 * This program is distributed in the hope that it will be useful,
Packit 8f70b4
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 8f70b4
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 8f70b4
 * GNU General Public License for more details.
Packit 8f70b4
 *
Packit 8f70b4
 * You should have received a copy of the GNU General Public License
Packit 8f70b4
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
Packit 8f70b4
 */
Packit 8f70b4
Packit 8f70b4
#ifndef DISPCOLUMNS_H
Packit 8f70b4
#define DISPCOLUMNS_H
Packit 8f70b4
Packit 8f70b4
#include "OutputJob.h"
Packit 8f70b4
#include "xarray.h"
Packit 8f70b4
Packit 8f70b4
class datum
Packit 8f70b4
{
Packit 8f70b4
   int ws, curwidth;
Packit 8f70b4
Packit 8f70b4
public:
Packit 8f70b4
   /* Each entry has a series of strings; each string has a color. */
Packit 8f70b4
   StringSet names;
Packit 8f70b4
   StringSet colors;
Packit 8f70b4
   datum() : ws(0), curwidth(0) {}
Packit 8f70b4
Packit 8f70b4
   void append(const char *name, const char *color);
Packit 8f70b4
Packit 8f70b4
   // get the total display width
Packit 8f70b4
   int width() const { return curwidth; }
Packit 8f70b4
Packit 8f70b4
   // print with or without color
Packit 8f70b4
   void print(const JobRef<OutputJob>& o, bool color, int skip,
Packit 8f70b4
	   const char *color_pref, const char *color_suf, const char *color_reset) const;
Packit 8f70b4
Packit 8f70b4
   /* count leading whitespace in the first name only. */
Packit 8f70b4
   int whitespace() const { return ws; }
Packit 8f70b4
};
Packit 8f70b4
Packit 8f70b4
class ColumnOutput {
Packit 8f70b4
   void get_print_info(unsigned width, xarray<int> &col_arr, xarray<int> &ws_arr, int &cols) const;
Packit 8f70b4
Packit 8f70b4
public:
Packit 8f70b4
   enum mode_t { VERT };
Packit 8f70b4
Packit 8f70b4
   void append();
Packit 8f70b4
   void add(const char *name, const char *color);
Packit 8f70b4
   void addf(const char *fmt, const char *color, ...);
Packit 8f70b4
Packit 8f70b4
   void SetWidth(unsigned width);
Packit 8f70b4
   void SetColor(bool color);
Packit 8f70b4
Packit 8f70b4
   void print(const JobRef<OutputJob>& o, unsigned width, bool color) const;
Packit 8f70b4
   void set_mode(mode_t m) { mode = m; }
Packit 8f70b4
Packit 8f70b4
private:
Packit 8f70b4
   RefArray<datum> lst;
Packit 8f70b4
Packit 8f70b4
   mode_t mode;
Packit 8f70b4
};
Packit 8f70b4
Packit 8f70b4
#endif