mirror of
https://github.com/rkd77/elinks.git
synced 2025-06-30 22:19:29 -04:00
Use document->cached in the Python scripting backend
As commit 7db8abf6e7ff43f059c4496e734c17337487db2c does for Lua and the document info box, change the Python scripting backend's current_document and current_header APIs to use document->cached instead of find_in_cached so the currently displayed document will be used rather than the latest version of the document.
This commit is contained in:
parent
896cdab771
commit
e978853f63
@ -9,8 +9,9 @@
|
|||||||
#include "elinks.h"
|
#include "elinks.h"
|
||||||
|
|
||||||
#include "cache/cache.h"
|
#include "cache/cache.h"
|
||||||
|
#include "document/document.h"
|
||||||
|
#include "document/view.h"
|
||||||
#include "scripting/python/core.h"
|
#include "scripting/python/core.h"
|
||||||
#include "session/location.h"
|
|
||||||
#include "session/session.h"
|
#include "session/session.h"
|
||||||
|
|
||||||
/* Python interface to get the current document's body. */
|
/* Python interface to get the current document's body. */
|
||||||
@ -23,8 +24,9 @@ If a document is being viewed, return its body; otherwise return None.\n");
|
|||||||
static PyObject *
|
static PyObject *
|
||||||
python_current_document(PyObject *self, PyObject *args)
|
python_current_document(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
if (python_ses && have_location(python_ses)) {
|
if (python_ses && python_ses->doc_view
|
||||||
struct cache_entry *cached = find_in_cache(cur_loc(python_ses)->vs.uri);
|
&& python_ses->doc_view->document) {
|
||||||
|
struct cache_entry *cached = python_ses->doc_view->document->cached;
|
||||||
struct fragment *f = cached ? cached->frag.next : NULL;
|
struct fragment *f = cached ? cached->frag.next : NULL;
|
||||||
|
|
||||||
if (f) return PyString_FromStringAndSize(f->data, f->length);
|
if (f) return PyString_FromStringAndSize(f->data, f->length);
|
||||||
@ -45,8 +47,9 @@ otherwise return None.\n");
|
|||||||
static PyObject *
|
static PyObject *
|
||||||
python_current_header(PyObject *self, PyObject *args)
|
python_current_header(PyObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
if (python_ses && have_location(python_ses)) {
|
if (python_ses && python_ses->doc_view
|
||||||
struct cache_entry *cached = find_in_cache(cur_loc(python_ses)->vs.uri);
|
&& python_ses->doc_view->document) {
|
||||||
|
struct cache_entry *cached = python_ses->doc_view->document->cached;
|
||||||
|
|
||||||
if (cached && cached->head)
|
if (cached && cached->head)
|
||||||
return PyString_FromString(cached->head);
|
return PyString_FromString(cached->head);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user