Blame src/ColumnOutput.h

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