1
1
* get_ptr_file (WView *view, offset_type byte_index)
    * get_ptr_string (WView *view, offset_type byte_index)
    * get_ptr_growing_buffer (WView *view, offset_type byte_index)
    * get_utf (WView *view, offset_type byte_index, int *char_width)

    add: property 'utf' in the struct Wview

    Signed-off-by: Slava Zanko <slavazanko@gmail.com>
    Added temlate for splitting src/view.c into lot of
    smalest files (for better development and supporting).
Этот коммит содержится в:
Ilia Maslakov 2009-07-26 07:31:24 +00:00
родитель a83739a910
Коммит eb9a251dcc
13 изменённых файлов: 571 добавлений и 2 удалений

Просмотреть файл

@ -562,6 +562,7 @@ src/Makefile
src/mcconfig/Makefile
src/search/Makefile
src/tty/Makefile
src/viewer/Makefile
edit/Makefile
syntax/Makefile

Просмотреть файл

@ -1,4 +1,4 @@
SUBDIRS = mcconfig search tty
SUBDIRS = mcconfig search tty viewer
AM_CFLAGS = $(GLIB_CFLAGS) -I$(top_srcdir) $(PCRE_CFLAGS)

Просмотреть файл

@ -158,7 +158,6 @@ struct WView {
growing buffer */
gboolean growbuf_finished; /* TRUE when all data has been read. */
/* Editor modes */
gboolean hex_mode; /* Hexview or Hexedit */
gboolean hexedit_mode; /* Hexedit */

18
src/viewer/Makefile.am Обычный файл
Просмотреть файл

@ -0,0 +1,18 @@
noinst_LTLIBRARIES = libmcviewer.la
libmcviewer_la_SOURCES = \
actions_cmd.c \
dialogs.c \
hex.c \
internal.h \
lib.c \
mcviewer.c \
mcviewer.h \
nroff.c \
plain.c
libmcviewer_la_CFLAGS=-I../ -I$(top_srcdir)/src \
$(GLIB_CFLAGS) \
-DDATADIR=\""$(pkgdatadir)/"\" -DLOCALEDIR=\""$(localedir)"\"

55
src/viewer/actions_cmd.c Обычный файл
Просмотреть файл

@ -0,0 +1,55 @@
/*
Internal file viewer for the Midnight Commander
Callback function for some actions (hotkeys, menu)
Copyright (C) 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003,
2004, 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
Written by: 1994, 1995, 1998 Miguel de Icaza
1994, 1995 Janne Kukonlehto
1995 Jakub Jelinek
1996 Joseph M. Hinkle
1997 Norbert Warmuth
1998 Pavel Machek
2004 Roland Illig <roland.illig@gmx.de>
2005 Roland Illig <roland.illig@gmx.de>
2009 Slava Zanko <slavazanko@google.com>
2009 Andrew Borodin <aborodin@vmail.ru>
2009 Ilia Maslakov <il.smind@gmail.com>
This file is part of the Midnight Commander.
The Midnight Commander is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Midnight Commander 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
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA.
*/
#include <config.h>
#include "../src/global.h"
#include "../src/viewer/internal.h"
/*** global variables ****************************************************************************/
/*** file scope macro definitions ****************************************************************/
/*** file scope type declarations ****************************************************************/
/*** file scope variables ************************************************************************/
/*** file scope functions ************************************************************************/
/*** public functions ****************************************************************************/
/* --------------------------------------------------------------------------------------------- */

55
src/viewer/dialogs.c Обычный файл
Просмотреть файл

@ -0,0 +1,55 @@
/*
Internal file viewer for the Midnight Commander
Function for paint dialogs
Copyright (C) 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003,
2004, 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
Written by: 1994, 1995, 1998 Miguel de Icaza
1994, 1995 Janne Kukonlehto
1995 Jakub Jelinek
1996 Joseph M. Hinkle
1997 Norbert Warmuth
1998 Pavel Machek
2004 Roland Illig <roland.illig@gmx.de>
2005 Roland Illig <roland.illig@gmx.de>
2009 Slava Zanko <slavazanko@google.com>
2009 Andrew Borodin <aborodin@vmail.ru>
2009 Ilia Maslakov <il.smind@gmail.com>
This file is part of the Midnight Commander.
The Midnight Commander is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Midnight Commander 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
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA.
*/
#include <config.h>
#include "../src/global.h"
#include "../src/viewer/internal.h"
/*** global variables ****************************************************************************/
/*** file scope macro definitions ****************************************************************/
/*** file scope type declarations ****************************************************************/
/*** file scope variables ************************************************************************/
/*** file scope functions ************************************************************************/
/*** public functions ****************************************************************************/
/* --------------------------------------------------------------------------------------------- */

55
src/viewer/hex.c Обычный файл
Просмотреть файл

@ -0,0 +1,55 @@
/*
Internal file viewer for the Midnight Commander
Function for hex view
Copyright (C) 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003,
2004, 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
Written by: 1994, 1995, 1998 Miguel de Icaza
1994, 1995 Janne Kukonlehto
1995 Jakub Jelinek
1996 Joseph M. Hinkle
1997 Norbert Warmuth
1998 Pavel Machek
2004 Roland Illig <roland.illig@gmx.de>
2005 Roland Illig <roland.illig@gmx.de>
2009 Slava Zanko <slavazanko@google.com>
2009 Andrew Borodin <aborodin@vmail.ru>
2009 Ilia Maslakov <il.smind@gmail.com>
This file is part of the Midnight Commander.
The Midnight Commander is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Midnight Commander 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
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA.
*/
#include <config.h>
#include "../src/global.h"
#include "../src/viewer/internal.h"
/*** global variables ****************************************************************************/
/*** file scope macro definitions ****************************************************************/
/*** file scope type declarations ****************************************************************/
/*** file scope variables ************************************************************************/
/*** file scope functions ************************************************************************/
/*** public functions ****************************************************************************/
/* --------------------------------------------------------------------------------------------- */

141
src/viewer/internal.h Обычный файл
Просмотреть файл

@ -0,0 +1,141 @@
#ifndef MC_VIEWER_INTERNAL_H
#define MC_VIEWER_INTERNAL_H
#include "../src/widget.h"
#include "../src/search/search.h"
/*** typedefs(not structures) and defined constants ********************/
typedef unsigned char byte;
/* A width or height on the screen */
typedef unsigned int screen_dimen;
/* Offset in bytes into a file */
typedef unsigned long offset_type;
/*** enums *************************************************************/
/* data sources of the view */
enum view_ds {
DS_NONE, /* No data available */
DS_STDIO_PIPE, /* Data comes from a pipe using popen/pclose */
DS_VFS_PIPE, /* Data comes from a piped-in VFS file */
DS_FILE, /* Data comes from a VFS file */
DS_STRING /* Data comes from a string in memory */
};
/*** structures declarations (and typedefs of structures)***************/
struct area {
screen_dimen top, left;
screen_dimen height, width;
};
struct WView {
Widget widget;
char *filename; /* Name of the file */
char *command; /* Command used to pipe data in */
enum view_ds datasource; /* Where the displayed data comes from */
/* stdio pipe data source */
FILE *ds_stdio_pipe; /* Output of a shell command */
/* vfs pipe data source */
int ds_vfs_pipe; /* Non-seekable vfs file descriptor */
/* vfs file data source */
int ds_file_fd; /* File with random access */
off_t ds_file_filesize; /* Size of the file */
off_t ds_file_offset; /* Offset of the currently loaded data */
byte *ds_file_data; /* Currently loaded data */
size_t ds_file_datalen; /* Number of valid bytes in file_data */
size_t ds_file_datasize; /* Number of allocated bytes in file_data */
/* string data source */
byte *ds_string_data; /* The characters of the string */
size_t ds_string_len; /* The length of the string */
/* Growing buffers information */
gboolean growbuf_in_use; /* Use the growing buffers? */
byte **growbuf_blockptr; /* Pointer to the block pointers */
size_t growbuf_blocks; /* The number of blocks in *block_ptr */
size_t growbuf_lastindex; /* Number of bytes in the last page of the
growing buffer */
gboolean growbuf_finished; /* TRUE when all data has been read. */
/* Editor modes */
gboolean hex_mode; /* Hexview or Hexedit */
gboolean hexedit_mode; /* Hexedit */
gboolean hexview_in_text; /* Is the hexview cursor in the text area? */
gboolean text_nroff_mode; /* Nroff-style highlighting */
gboolean text_wrap_mode; /* Wrap text lines to fit them on the screen */
gboolean magic_mode; /* Preprocess the file using external programs */
/* Additional editor state */
gboolean hexedit_lownibble; /* Are we editing the last significant nibble? */
GArray *coord_cache; /* Cache for mapping offsets to cursor positions */
/* Display information */
screen_dimen dpy_frame_size;/* Size of the frame surrounding the real viewer */
offset_type dpy_start; /* Offset of the displayed data */
offset_type dpy_end; /* Offset after the displayed data */
offset_type dpy_text_column;/* Number of skipped columns in non-wrap
* text mode */
offset_type hex_cursor; /* Hexview cursor position in file */
screen_dimen cursor_col; /* Cursor column */
screen_dimen cursor_row; /* Cursor row */
struct hexedit_change_node *change_list; /* Linked list of changes */
struct area status_area; /* Where the status line is displayed */
struct area ruler_area; /* Where the ruler is displayed */
struct area data_area; /* Where the data is displayed */
int dirty; /* Number of skipped updates */
gboolean dpy_bbar_dirty; /* Does the button bar need to be updated? */
/* Mode variables */
int bytes_per_line; /* Number of bytes per line in hex mode */
/* Search variables */
offset_type search_start; /* First character to start searching from */
offset_type search_end; /* Length of found string or 0 if none was found */
/* Pointer to the last search command */
gboolean want_to_quit; /* Prepare for cleanup ... */
/* Markers */
int marker; /* mark to use */
offset_type marks [10]; /* 10 marks: 0..9 */
int move_dir; /* return value from widget:
* 0 do nothing
* -1 view previous file
* 1 view next file
*/
offset_type update_steps; /* The number of bytes between percent
* increments */
offset_type update_activate;/* Last point where we updated the status */
/* converter for translation of text */
GIConv converter;
/* handle of search engine */
mc_search_t *search;
gchar *last_search_string;
mc_search_type_t search_type;
gboolean search_all_codepages;
gboolean search_case;
gboolean search_backwards;
int search_numNeedSkipChar;
};
/*** global variables defined in .c file *******************************/
/*** declarations of public functions **********************************/
#endif

55
src/viewer/lib.c Обычный файл
Просмотреть файл

@ -0,0 +1,55 @@
/*
Internal file viewer for the Midnight Commander
Common finctions (used from some other mcviewer functions)
Copyright (C) 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003,
2004, 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
Written by: 1994, 1995, 1998 Miguel de Icaza
1994, 1995 Janne Kukonlehto
1995 Jakub Jelinek
1996 Joseph M. Hinkle
1997 Norbert Warmuth
1998 Pavel Machek
2004 Roland Illig <roland.illig@gmx.de>
2005 Roland Illig <roland.illig@gmx.de>
2009 Slava Zanko <slavazanko@google.com>
2009 Andrew Borodin <aborodin@vmail.ru>
2009 Ilia Maslakov <il.smind@gmail.com>
This file is part of the Midnight Commander.
The Midnight Commander is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Midnight Commander 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
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA.
*/
#include <config.h>
#include "../src/global.h"
#include "../src/viewer/internal.h"
/*** global variables ****************************************************************************/
/*** file scope macro definitions ****************************************************************/
/*** file scope type declarations ****************************************************************/
/*** file scope variables ************************************************************************/
/*** file scope functions ************************************************************************/
/*** public functions ****************************************************************************/
/* --------------------------------------------------------------------------------------------- */

55
src/viewer/mcviewer.c Обычный файл
Просмотреть файл

@ -0,0 +1,55 @@
/*
Internal file viewer for the Midnight Commander
Interface functions
Copyright (C) 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003,
2004, 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
Written by: 1994, 1995, 1998 Miguel de Icaza
1994, 1995 Janne Kukonlehto
1995 Jakub Jelinek
1996 Joseph M. Hinkle
1997 Norbert Warmuth
1998 Pavel Machek
2004 Roland Illig <roland.illig@gmx.de>
2005 Roland Illig <roland.illig@gmx.de>
2009 Slava Zanko <slavazanko@google.com>
2009 Andrew Borodin <aborodin@vmail.ru>
2009 Ilia Maslakov <il.smind@gmail.com>
This file is part of the Midnight Commander.
The Midnight Commander is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Midnight Commander 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
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA.
*/
#include <config.h>
#include "../src/global.h"
#include "../src/viewer/internal.h"
/*** global variables ****************************************************************************/
/*** file scope macro definitions ****************************************************************/
/*** file scope type declarations ****************************************************************/
/*** file scope variables ************************************************************************/
/*** file scope functions ************************************************************************/
/*** public functions ****************************************************************************/
/* --------------------------------------------------------------------------------------------- */

25
src/viewer/mcviewer.h Обычный файл
Просмотреть файл

@ -0,0 +1,25 @@
/** \file view.h
* \brief Header: internal file viewer
*/
#ifndef MC_VIEWER_H
#define MC_VIEWER_H
/*** typedefs(not structures) and defined constants ********************/
typedef struct WView WView; /* Can be cast to Widget */
/*** enums *************************************************************/
/*** structures declarations (and typedefs of structures)***************/
/*** global variables defined in .c file *******************************/
/*** declarations of public functions **********************************/
/* Creates a new WView object with the given properties. Caveat: the
* origin is in y-x order, while the extent is in x-y order. */
extern WView *view_new (int y, int x, int cols, int lines, int is_panel);
#endif

55
src/viewer/nroff.c Обычный файл
Просмотреть файл

@ -0,0 +1,55 @@
/*
Internal file viewer for the Midnight Commander
Function for nroff-like view
Copyright (C) 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003,
2004, 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
Written by: 1994, 1995, 1998 Miguel de Icaza
1994, 1995 Janne Kukonlehto
1995 Jakub Jelinek
1996 Joseph M. Hinkle
1997 Norbert Warmuth
1998 Pavel Machek
2004 Roland Illig <roland.illig@gmx.de>
2005 Roland Illig <roland.illig@gmx.de>
2009 Slava Zanko <slavazanko@google.com>
2009 Andrew Borodin <aborodin@vmail.ru>
2009 Ilia Maslakov <il.smind@gmail.com>
This file is part of the Midnight Commander.
The Midnight Commander is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Midnight Commander 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
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA.
*/
#include <config.h>
#include "../src/global.h"
#include "../src/viewer/internal.h"
/*** global variables ****************************************************************************/
/*** file scope macro definitions ****************************************************************/
/*** file scope type declarations ****************************************************************/
/*** file scope variables ************************************************************************/
/*** file scope functions ************************************************************************/
/*** public functions ****************************************************************************/
/* --------------------------------------------------------------------------------------------- */

55
src/viewer/plain.c Обычный файл
Просмотреть файл

@ -0,0 +1,55 @@
/*
Internal file viewer for the Midnight Commander
Function for plain view
Copyright (C) 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003,
2004, 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
Written by: 1994, 1995, 1998 Miguel de Icaza
1994, 1995 Janne Kukonlehto
1995 Jakub Jelinek
1996 Joseph M. Hinkle
1997 Norbert Warmuth
1998 Pavel Machek
2004 Roland Illig <roland.illig@gmx.de>
2005 Roland Illig <roland.illig@gmx.de>
2009 Slava Zanko <slavazanko@google.com>
2009 Andrew Borodin <aborodin@vmail.ru>
2009 Ilia Maslakov <il.smind@gmail.com>
This file is part of the Midnight Commander.
The Midnight Commander is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Midnight Commander 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
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA.
*/
#include <config.h>
#include "../src/global.h"
#include "../src/viewer/internal.h"
/*** global variables ****************************************************************************/
/*** file scope macro definitions ****************************************************************/
/*** file scope type declarations ****************************************************************/
/*** file scope variables ************************************************************************/
/*** file scope functions ************************************************************************/
/*** public functions ****************************************************************************/
/* --------------------------------------------------------------------------------------------- */