You are not logged in.
Yeah thanks! Today I only commit to other statements
When I read Runiq's post I realized zathura has become my viewer of choice without me even recognizing it. Tried xpdf and apvlv before and stuck to xpdf until i (passively) discovered how to invert X
Now zathura isn't even a question. za<Tab> is what to do to open a pdf!
Offline
Hello,
Thanks for the commendation. I added some new functionality to the git version: If the document changes in the background (e.g.: If you write a tex document and rebuild it), zathura reloads the file automatically and refreshes the page.
Best regards
pwmt.org : programs with movie titles
Offline
If you write a tex document and rebuild it), zathura reloads the file automatically and refreshes the page.
wow, i was just thinking "maybe i'll rewrite my resume with latex as a project to learn latex", then i thought "how might i get some sort of live pdf previewing out of vim?"
i do believe you've solved it for me. so i went to update -git and get going (had zathura installed from post #2 but haven't used it in forever only b/c i don't view pdf's all that often...)
there's just one problem...
//blue/0/~/ aurget zathura-git
resolving dependencies...
searching AUR...
Targets (1): zathura-git-VERSION-1
Proceed with installation? [Y/n] y
...
==> Finished making: zathura-git 20100308-1 x86_64 (Mon Mar 8 16:30:33 EST 2010)
loading package data...
checking dependencies...
(1/1) checking for file conflicts [###############################################] 100%
(1/1) upgrading zathura-git [###############################################] 100%
//blue/0/~/ which zathura
which: no zathura in (/bin:/usr/bin:/sbin:/usr/sbin:/usr/bin/perlbin/site:/usr/bin/perlbin/vendor:/usr/bin/perlbin/core:/home/patrick/.bin)
//blue/1/~/ pacman -Q zathura-git
zathura-git 20100308-1
//blue/0/~/ pacman -Ql zathura-git
zathura-git /usr/
zathura-git /usr/bin/
zathura-git /usr/share/
zathura-git /usr/share/licenses/
zathura-git /usr/share/licenses/zathura-git/
zathura-git /usr/share/licenses/zathura-git/LICENSE
zathura-git /usr/share/man/
zathura-git /usr/share/man/man1/
zathura-git /usr/share/man/man1/zathura.1.gz
no binary? what'd i do?
Last edited by brisbin33 (2010-03-08 21:36:55)
//github/
Offline
Hello,
It just works fine here:
packer -S zathura-git
Proceed with installation? [Y/n] y
Edit zathura-git PKGBUILD with $EDITOR? [Y/n] y
==> Determining latest git revision...
-> Version found: 20100308
...
==> Finished making: zathura-git 20100308-1 x86_64 (Mon Mar 8 22:38:31 CET 2010)
which zathura
/usr/bin/zathura
pacman -Ql zathura-git
zathura-git /usr/
zathura-git /usr/bin/
zathura-git /usr/bin/zathura
zathura-git /usr/share/
zathura-git /usr/share/licenses/
zathura-git /usr/share/licenses/zathura-git/
zathura-git /usr/share/licenses/zathura-git/LICENSE
zathura-git /usr/share/man/
zathura-git /usr/share/man/man1/
zathura-git /usr/share/man/man1/zathura.1.gz
Have you changed something in the PKGBUILD?
Best regards
pwmt.org : programs with movie titles
Offline
nope, aurget pulls the same PKGBUILD packer does.
//blue/0/~/ aurget -p zathura-git
# Maintainer: Michael Walker <mike@barrucadu.co.uk>
pkgname=zathura-git
pkgver=VERSION
pkgrel=1
pkgdesc="a PDF viewer"
arch=('i686' 'x86_64')
url="http://zathura.pwmt.org"
license=('custom')
depends=('poppler-glib>=0.12.3' 'gtk2>=2.18.6' 'cairo>=1.8.8')
makedepends=('git')
conflicts=('zathura')
replaces=('zathura')
provides=('zathura')
_gitroot='git://pwmt.org/zathura.git'
_gitname='zathura'
build() {
cd $srcdir
msg "Retrieving current revision."
if [ -d $startdir/src/$_gitname ] ; then
cd $_gitname && git-pull origin
msg "The local files are updated."
else
git clone $_gitroot
cd $_gitname
fi
make
install -D -m775 zathura "$pkgdir/usr/bin/zathura"
install -D -m664 zathura.1 "$pkgdir/usr/share/man/man1/zathura.1"
install -D -m664 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}
this is a bit strange... i'll try it the manual way and see what happens...
edit... aha; i wasn't watching makepkg output closely enough...
...
/home/patrick/zathura/PKGBUILD: line 26: git-pull: command not found
...
i have git installed, man git says git-pull is valid... oh well, off to troubleshoot that issue.
thanks for you patience .
Last edited by brisbin33 (2010-03-08 22:31:32)
//github/
Offline
@brisbin33 try with "git pull" instead of "git-pull"
@neldoreth a feature request: is it possible to add support for djvu files using libdjvu?
Offline
@neldoreth a feature request: is it possible to add support for djvu files using libdjvu?
++ for that.
Evince does support djvu, so maybe can look at their code
This silver ladybug at line 28...
Offline
is it possible to add autorefresh? I would love that for tex-files. I don't like having my tex-files compile to dvi just for live-preview
Offline
@x0rg
I added some new functionality to the git version: If the document changes in the background (e.g.: If you write a tex document and rebuild it), zathura reloads the file automatically and refreshes the page.
//github/
Offline
omg, I knew it was stupid to post a feature request before updating zathura... thanks
Last edited by x0rg (2010-03-16 18:34:55)
Offline
Hi, I leave you here a patch that I made to modify the invert function. Now in the config.h you have two extra colors, recolor_rakcolor and recolor_lightcolor. The invert function replaces the black in the pdf file with the recolor_darkcolor, the white with the recolor_lightcolor and in between. Here you have a screenshot to see an example of what I'm talking about.
If anyone wonders why I modified the invert function instead of adding a new one, well, I think this renders the invert function useless, at least for me, plus it was easier and less code to add . Futhermore, with recolor_darkcolor = "#FFFFFF" and recolor_lightcolor = "#000000" you can get the same behavior as with the original invert function.
It should be noted that the algorithm to recolor the image isn't my invention, it was based on the code from the Blitz::flatten() function of the qimageblitz library (http://sourceforge.net/projects/qimageblitz/). That's also why there is a commented out block of code. That code is included in the qimageblitz function. However, I don't see the point of it with hard-coded values of min = 0x00 and max = 0xFF. It would make sense if the range of colors to replace (min to max) wasn't white to black. I included it anyways for the sake of completeness and in case someone realizes that it is actually needed or in case someone wants to try playing around with different values of min and max.
Hope you find it useful.
PD. Since I could not find an attach option, I'll put the patch in the code tag. In case there is a better way of posting it, please tell me.
From 1ca269cdfa8520def8e12681683f20b3ec9455c3 Mon Sep 17 00:00:00 2001
From: fedcer <fedcer@gmail.com>
Date: Tue, 16 Mar 2010 19:03:03 -0300
Subject: [PATCH] Changed the invert function to now do recoloring
The invert function now recolors the page,
replacing black with recolor_darkcolor,
white with recolor_lightcolor and in between.
---
config.def.h | 2 +
zathura.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++-----
2 files changed, 55 insertions(+), 6 deletions(-)
diff --git a/config.def.h b/config.def.h
index 255453b..4979b00 100644
--- a/config.def.h
+++ b/config.def.h
@@ -36,6 +36,8 @@ static const char notification_e_bgcolor[] = "#FF1212";
static const char notification_e_fgcolor[] = "#FFFFFF";
static const char notification_w_bgcolor[] = "#FFF712";
static const char notification_w_fgcolor[] = "#000000";
+static const char recolor_darkcolor[] = "#DCDCCC";
+static const char recolor_lightcolor[] = "#3F3F3F";
static const char search_highlight[] = "#9FBC00";
diff --git a/zathura.c b/zathura.c
index d3337e7..d61d4c0 100644
--- a/zathura.c
+++ b/zathura.c
@@ -172,6 +172,8 @@ struct
GdkColor notification_e_bg;
GdkColor notification_w_fg;
GdkColor notification_w_bg;
+ GdkColor recolor_darkcolor;
+ GdkColor recolor_lightcolor;
GdkColor search_highlight;
PangoFontDescription *font;
} Style;
@@ -390,6 +392,8 @@ init_zathura()
gdk_color_parse(notification_e_bgcolor, &(Zathura.Style.notification_e_bg));
gdk_color_parse(notification_w_fgcolor, &(Zathura.Style.notification_w_fg));
gdk_color_parse(notification_w_bgcolor, &(Zathura.Style.notification_w_bg));
+ gdk_color_parse(recolor_darkcolor, &(Zathura.Style.recolor_darkcolor));
+ gdk_color_parse(recolor_lightcolor, &(Zathura.Style.recolor_lightcolor));
gdk_color_parse(search_highlight, &(Zathura.Style.search_highlight));
Zathura.Style.font = pango_font_description_from_string(font);
@@ -640,12 +644,55 @@ draw(int page_id)
if(Zathura.Global.reverse_video)
{
- unsigned char* image = cairo_image_surface_get_data(Zathura.PDF.surface);
- int x, y, z = 0;
+ unsigned char* image = cairo_image_surface_get_data(Zathura.PDF.surface);
+ int x, y;
- for(x = 0; x < cairo_image_surface_get_width(Zathura.PDF.surface); x++)
- for(y = 0; y < cairo_image_surface_get_height(Zathura.PDF.surface) * 4; y++)
- image[z++] ^= 0x00FFFFFF;
+ int width = cairo_image_surface_get_width(Zathura.PDF.surface);
+ int height = cairo_image_surface_get_height(Zathura.PDF.surface);
+ int rowstride = cairo_image_surface_get_stride(Zathura.PDF.surface);
+
+ /* recolor code based on qimageblitz library flatten() function
+ (http://sourceforge.net/projects/qimageblitz/) */
+
+ int r1 = Zathura.Style.recolor_darkcolor.red / 257;
+ int g1 = Zathura.Style.recolor_darkcolor.green / 257;
+ int b1 = Zathura.Style.recolor_darkcolor.blue / 257;
+ int r2 = Zathura.Style.recolor_lightcolor.red / 257;
+ int g2 = Zathura.Style.recolor_lightcolor.green / 257;
+ int b2 = Zathura.Style.recolor_lightcolor.blue / 257;
+
+ int min = 0x00;
+ int max = 0xFF;
+ int mean;
+
+ /* not neccesary if min = 0x00 and max = 0xFF
+ for (y = 0; y < height; y++) {
+ unsigned char* ptr = image + y * rowstride;
+
+ for (x = 0; x < width; x++) {
+ mean = (ptr[0] + ptr[1] + ptr[2]) / 3;
+ min = (min < mean) ? min : mean;
+ max = (max > mean) ? max : mean;
+ ptr += 4;
+ }
+ }
+ */
+
+ float sr = ((float) r2 - r1) / (max - min);
+ float sg = ((float) g2 - g1) / (max - min);
+ float sb = ((float) b2 - b1) / (max - min);
+
+ for (y = 0; y < height; y++) {
+ unsigned char* data = image + y * rowstride;
+
+ for (x = 0; x < width; x++) {
+ mean = (data[0] + data[1] + data[2]) / 3;
+ data[2] = sr * (mean - min) + r1 + 0.5;
+ data[1] = sg * (mean - min) + g1 + 0.5;
+ data[0] = sb * (mean - min) + b1 + 0.5;
+ data += 4;
+ }
+ }
}
gtk_widget_set_size_request(Zathura.UI.drawing_area, width, height);
--
1.7.0.2
Last edited by fedcer (2010-03-17 00:51:01)
Offline
@fedcer: I like how it looks "smoother" now. Good idea, and thanks
Offline
Awesome dude!
Now you can pick up any color you want for the background and font.
Offline
@brisbin33 try with "git pull" instead of "git-pull"
sorry to not reply for a while on this. my issue is solved. here's the highlights.
found a pkgbuild on the aur comments that returns 1 if makepkg fails (this is good practice i think) the 'official' pkgbuild doesn't do this so pacman installed zathura but i had no binary... quite confusing. this pkgbuild also used git pull (no hyphen) which was in fact a good catch fauno_.
that brought my to an ld error that i started getting with more and more packages. i made a post about it and later found out that python25-libxml2 was causing the whole issue.
removed that package and i'm all set.
back to happily using zathura. thanks.
//github/
Offline
Sorry for the intrusiveness of this noob, but could someone explain how I apply the invert color patch provided? Appreciate it!
transcend to the fifth abode
Offline
Sorry for the intrusiveness of this noob, but could someone explain how I apply the invert color patch provided? Appreciate it!
Save the patch and then from the source directory run
patch -p1 < path/patchname
Or, you can use the following PKGBUILD and put the patch in a file named "invert-colors.patch" in the same directory as the PKGBUILD. If you want to change the colors, you can change the values of "recolor_darkcolor" and "recolor_darkcolor" in the patch, but then remember to run md5sum on the patch and update the value of the md5sums variable in the PKGBUILD.
PKGBUILD:
# Maintainer: Michael Walker <mike@barrucadu.co.uk>
pkgname=zathura-git
pkgver=20100319
pkgrel=1
pkgdesc="a PDF viewer"
arch=('i686' 'x86_64')
url="http://zathura.pwmt.org"
license=('custom')
depends=('poppler-glib>=0.12.3' 'gtk2>=2.18.6' 'cairo>=1.8.8')
makedepends=('git')
source=('invert-colors.patch')
md5sums=('afa248a81d80b04825f1a08a33a3ea0e')
conflicts=('zathura')
replaces=('zathura')
provides=('zathura')
_gitroot='git://pwmt.org/zathura.git'
_gitname='zathura'
build() {
cd $srcdir
msg "Retrieving current revision."
if [ -d $startdir/src/$_gitname ] ; then
cd $_gitname && git-pull origin
msg "The local files are updated."
else
git clone $_gitroot
cd $_gitname
fi
patch -p1 < $srcdir/invert-colors.patch
make
install -D -m775 zathura "$pkgdir/usr/bin/zathura"
install -D -m664 zathura.1 "$pkgdir/usr/share/man/man1/zathura.1"
install -D -m664 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}
Last edited by fedcer (2010-03-19 11:32:37)
Offline
After patching and recompiling I get:
zathura.c: In function 'init_zathura':
zathura.c:384: error: 'recolor_darkcolor' undeclared (first use in this function)
zathura.c:384: error: (Each undeclared identifier is reported only once
zathura.c:384: error: for each function it appears in.)
zathura.c:385: error: 'recolor_lightcolor' undeclared (first use in this function)
make: *** [zathura.o] Error 1
transcend to the fifth abode
Offline
After patching and recompiling I get:
zathura.c: In function 'init_zathura': zathura.c:384: error: 'recolor_darkcolor' undeclared (first use in this function) zathura.c:384: error: (Each undeclared identifier is reported only once zathura.c:384: error: for each function it appears in.) zathura.c:385: error: 'recolor_lightcolor' undeclared (first use in this function) make: *** [zathura.o] Error 1
Had you previously compiled zathura in that directory ? If so, delete the file config.h and try again. (The zathura makefile copies the config.def.h to config.h the first time you run make, but not afterwards; therefore you have the old file without the new colour definitions.)
Offline
ntness wrote:After patching and recompiling I get:
zathura.c: In function 'init_zathura': zathura.c:384: error: 'recolor_darkcolor' undeclared (first use in this function) zathura.c:384: error: (Each undeclared identifier is reported only once zathura.c:384: error: for each function it appears in.) zathura.c:385: error: 'recolor_lightcolor' undeclared (first use in this function) make: *** [zathura.o] Error 1
Had you previously compiled zathura in that directory ? If so, delete the file config.h and try again. (The zathura makefile copies the config.def.h to config.h the first time you run make, but not afterwards; therefore you have the old file without the new colour definitions.)
Wonderful! Thank you much.
transcend to the fifth abode
Offline
Just tried it today, this is a totally awesome pdf reader. Since it's C i will look into it
Offline
I'm using zathura for some days now and I'm glad that I've finally found a usable vi-like pdf-viewer.
But whenever I use the search function, the results did not get highlighted.
I think it's because the highlight_result() function is called before the set_page() function, which destroys the whole PDF surface by calling draw() and thus removes all cairo rectangles created by highlight_result().
When I change the call order, everything works fine.
Patch:
--- zathura-orig/zathura.c 2010-03-28 19:13:18.000000000 +0200
+++ zathura/zathura.c 2010-03-28 18:59:02.000000000 +0200
@@ -1042,7 +1042,7 @@ search(void* parameter)
static int direction;
static int next_page = 0;
int page_counter;
- GList* results;
+ GList* results = NULL;
GList* list;
if(argument->data)
@@ -1091,10 +1091,10 @@ search(void* parameter)
/* draw results */
if(results)
{
+ set_page(next_page);
+
for(list = results; list && list->data; list = g_list_next(list))
highlight_result(next_page, (PopplerRectangle*) list->data);
-
- set_page(next_page);
}
else
{
Offline
Hello,
Thanks for letting me know, I applied this line to the master branch. The main problem for further development on the search function is the poppler library itself and I had no time to fix it to guarantee a stable search function.
Best regards
pwmt.org : programs with movie titles
Offline
Thanks for the nice application. Don't have many pdfs to read atm, but when uni starts again, I'll probably use this a lot.
There was one thing I noticed though:
If you change the mapping "^zI$" to "^zi$", the mapping of "i" will take precedence over the "^zi$" and you will not be able to zoom in when you type "zi".
I guess it makes sense performance-wise to check for single characters first, but meh. Just mentioning. It's not intuitive imo
"hut_" or "h00th00t" in irc.freenode.net #archlinux
Ranger Mailing List: https://lists.nongnu.org/mailman/listinfo/ranger-users
Offline
After reading a lot of the source code, I get more and more concerned about the lack of memory management in zathura. There are, for instance, many (unnecessary) strdups in the code, which never get free'd afterwards.
Also, memory is allocated at the beginning of functions and then never gets free'd because these functions are often leaved in conditions using a simple return.
It would be a good idea in my opinion to clean up the code in respect of freeing memory whenever it is not needed anymore, before implementing new features.
Is it possible to join the project?
Offline
Hello,
After reading a lot of the source code, I get more and more concerned about the lack of memory management in zathura. There are, for instance, many (unnecessary) strdups in the code, which never get free'd afterwards.
Also, memory is allocated at the beginning of functions and then never gets free'd because these functions are often leaved in conditions using a simple return.
I am aware of that and its one point on the top of the TODO lists, but I had no time for any further developing.
Is it possible to join the project?
You can join #pwmt at irc.oftc.net and speak to me.
Best regards
pwmt.org : programs with movie titles
Offline