Prog = 0 for first page, 1 for middle pages, 2 for last page
341358
def Screens(self, text, prog, screen, clock):
        """"""
        # Initialize the screen class
        BaseScreen.__init__(self, self.size, self.background)

        # Determine the mid position of the given screen size and the
        # y button height
        xmid = self.size[0]//2

        # Create the header text
        Linesoftext(text, (xmid, 40), xmid=True, surface=self.image,
                    fontsize=30)

        # Create the buttons
        self.buttonlist = []
        if prog == 0:
            self.buttonlist += [self.nextbutton]

        elif prog == 1:
            self.buttonlist += [self.nextbutton]
            self.buttonlist += [self.backbutton]

        elif prog == 2:
            self.buttonlist += [self.lastbutton]
            self.buttonlist += [self.backbutton]

        # Draw the buttons to the screen
        for i in self.buttonlist:
            self.image.blit(*i.blitinfo)

        # Use the menu update method to run the screen and process button clicks
        return Menu.update(self, screen, clock)
1371354
def previous_page(params = {}, opts = {})
      first_id = data.first.id

      params = filters.merge(ending_before: first_id).merge(params)

      list(params, opts)
    end
855351
protected function pages_prepare_middle(){
		$pm_left=2;
		$pm_right=2;
		//Add first page, if we are somewhere in middle of pages...
		if($this->page_active>$pm_left){
			$url=$this->generateurl(0);
			$this->pages[]=(object)array(
				'name'=>'1',
				'url'=>$url,
				'active'=>false,
				'disabled'=>false
				);
			$this->pages[]=(object)array(
				'name'=>'...',
				'url'=>'',
				'active'=>false,
				'disabled'=>true
				);
			}
		//Get Min and max middle pages
		$pm_min=$this->page_active-$pm_left;
		if($pm_min<0){
			$pm_min=0;
			}
		$pm_max=$this->page_active+$pm_right;
		if($pm_max>$this->pages_count){
			$pm_max=$this->pages_count;
			}
		//Add current page and some prev and next page nums
		for($i=$pm_min;$i<=$pm_max;$i++){
			$url=$this->generateurl($i);
			$this->pages[]=(object)array(
				'name'=>$i+1,
				'url'=>$url,
				'active'=>($i==$this->page_active),
				'disabled'=>false
				);
			}
		//Add last page, if we are somewhere in middle of pages
		if($this->page_active<($this->pages_count-$pm_right)){
			$this->pages[]=(object)array(
				'name'=>'...',
				'url'=>'',
				'active'=>false,
				'disabled'=>true
				);
			$url=$this->generateurl($this->pages_count);
			$this->pages[]=(object)array(
				'name'=>$this->pages_count+1,
				'url'=>$url,
				'active'=>false,
				'disabled'=>false
				);
			}

		}
51529
def pages(self, limit=0):
        """"""
        if limit > 0:
            self.iterator.limit = limit
        return self.iterator
360212
def page(content, pagecallback=prompt):
    
    width = getwidth()
    height = getheight()
    pagenum = 1

    try:
        try:
            line = content.next().rstrip("\r\n")
        except AttributeError:
            # Python 3 compatibility
            line = content.__next__().rstrip("\r\n")
    except StopIteration:
        pagecallback(pagenum)
        return

    while True:     # page cycle
        linesleft = height-1 # leave the last line for the prompt callback
        while linesleft:
            linelist = [line[i:i+width] for i in range(0, len(line), width)]
            if not linelist:
                linelist = ['']
            lines2print = min(len(linelist), linesleft)
            for i in range(lines2print):
                if WINDOWS and len(line) == width:
                    # avoid extra blank line by skipping linefeed print
                    echo(linelist[i])
                else:
                    print((linelist[i]))
            linesleft -= lines2print
            linelist = linelist[lines2print:]

            if linelist: # prepare symbols left on the line for the next iteration
                line = ''.join(linelist)
                continue
            else:
                try:
                    try:
                        line = content.next().rstrip("\r\n")
                    except AttributeError:
                        # Python 3 compatibility
                        line = content.__next__().rstrip("\r\n")
                except StopIteration:
                    pagecallback(pagenum)
                    return
        if pagecallback(pagenum) == False:
            return
        pagenum += 1
1165003
def number_of_pages(self, key, value):
    """"""
    result = maybe_int(force_single_element(value.get('a', '')))
    if result and result > 0:
        return result
115721
def flatten_pages(self, pages, level=1):
        """"""
        flattened = []

        for page in pages:
            if type(page) is list:
                flattened.append(
                             {
                                'file': page[0],
                                'title': page[1],
                                'level': level,
                             })
            if type(page) is dict:
                if type(list(page.values())[0]) is str:
                    flattened.append(
                            {
                                'file': list(page.values())[0],
                                'title': list(page.keys())[0],
                                'level': level,
                             })
                if type(list(page.values())[0]) is list:
                    flattened.extend(
                            self.flatten_pages(
                                list(page.values())[0],
                                level + 1)
                            )


        return flattened
1343823
private void setCurrentPage(int page) {
        if (page >= totalPages) {
            this.currentPage = totalPages;
        } else if (page <= 1) {
            this.currentPage = 1;
        } else {
            this.currentPage = page;
        }

        // now work out where the sub-list should start and end
        startingIndex = pageSize * (currentPage -1);
        if (startingIndex < 0) {
            startingIndex = 0;
        }
        endingIndex = startingIndex + pageSize;
        if (endingIndex > list.size()) {
            endingIndex = list.size();
        }
    }
649770
function(currentPage, totalPages) {
			this.writeDebug('_paginationOutput',arguments);

			currentPage = parseFloat(currentPage);
			var output = '';
			var nextPage = currentPage + 1;
			var prevPage = currentPage - 1;

			// Previous page
			if ( currentPage > 0 ) {
				output += '<li class="bh-sl-next-prev" data-page="' + prevPage + '">' + this.settings.prevPage + '</li>';
			}

			// Add the numbers
			for (var p = 0; p < Math.ceil(totalPages); p++) {
				var n = p + 1;

				if (p === currentPage) {
					output += '<li class="bh-sl-current" data-page="' + p + '">' + n + '</li>';
				}
				else {
					output += '<li data-page="' + p + '">' + n + '</li>';
				}
			}

			// Next page
			if ( nextPage < totalPages ) {
				output += '<li class="bh-sl-next-prev" data-page="' + nextPage + '">' + this.settings.nextPage + '</li>';
			}

			return output;
		}
575442
def pages(self):
        """"""
        if self.per_page == 0 or self.total is None:
            pages = 0
        else:
            pages = int(ceil(self.total / float(self.per_page)))
        return pages
1371874
def get_pagination_context(
    page, pages_to_show=11, url=None, size=None, extra=None, parameter_name="page"
):
    
    pages_to_show = int(pages_to_show)
    if pages_to_show < 1:
        raise ValueError(
            "Pagination pages_to_show should be a positive integer, you specified {pages}".format(
                pages=pages_to_show
            )
        )
    num_pages = page.paginator.num_pages
    current_page = page.number
    half_page_num = int(floor(pages_to_show / 2))
    if half_page_num < 0:
        half_page_num = 0
    first_page = current_page - half_page_num
    if first_page <= 1:
        first_page = 1
    if first_page > 1:
        pages_back = first_page - half_page_num
        if pages_back < 1:
            pages_back = 1
    else:
        pages_back = None
    last_page = first_page + pages_to_show - 1
    if pages_back is None:
        last_page += 1
    if last_page > num_pages:
        last_page = num_pages
    if last_page < num_pages:
        pages_forward = last_page + half_page_num
        if pages_forward > num_pages:
            pages_forward = num_pages
    else:
        pages_forward = None
        if first_page > 1:
            first_page -= 1
        if pages_back is not None and pages_back > 1:
            pages_back -= 1
        else:
            pages_back = None
    pages_shown = []
    for i in range(first_page, last_page + 1):
        pages_shown.append(i)
        # Append proper character to url
    if url:
        # Remove existing page GET parameters
        url = force_text(url)
        url = re.sub(r"\?{0}\=[^\&]+".format(parameter_name), "?", url)
        url = re.sub(r"\&{0}\=[^\&]+".format(parameter_name), "", url)
        # Append proper separator
        if "?" in url:
            url += "&"
        else:
            url += "?"
            # Append extra string to url
    if extra:
        if not url:
            url = "?"
        url += force_text(extra) + "&"
    if url:
        url = url.replace("?&", "?")
    # Set CSS classes, see http://getbootstrap.com/components/#pagination
    pagination_css_classes = ["pagination"]
    if size == "small":
        pagination_css_classes.append("pagination-sm")
    elif size == "large":
        pagination_css_classes.append("pagination-lg")
        # Build context object
    return {
        "bootstrap_pagination_url": url,
        "num_pages": num_pages,
        "current_page": current_page,
        "first_page": first_page,
        "last_page": last_page,
        "pages_shown": pages_shown,
        "pages_back": pages_back,
        "pages_forward": pages_forward,
        "pagination_css_classes": " ".join(pagination_css_classes),
        "parameter_name": parameter_name,
    }
395238
def limit_page page = nil, options = {}
      if page.is_a?( Hash )
        options = page
      else
        options[:page] = page.to_i
      end

      options[:page] = options[:page].to_i > 0 ? options[:page] : DataMapper::Paginator.default[:page]
      options[:limit] = options[:limit].to_i || DataMapper::Paginator.default[:limit]
      options[:offset] = options[:limit] * ( options[:page] - 1 )
      options[:order] = options[:order] || DataMapper::Paginator.default[:order]
      limit options
    end
1180070
def accel_prev(self, *args):
        
        if self.get_notebook().get_current_page() == 0:
            self.get_notebook().set_current_page(self.get_notebook().get_n_pages() - 1)
        else:
            self.get_notebook().prev_page()
        return True
118308
def page_to_offset(params):
    

    if 'page' not in params:
        return

    page = params['page']
    del params['page']

    # 'per_page' je len alias za 'limit'
    if 'per_page' in params:
        per_page = params.get('per_page')
        del params['per_page']
    else:
        per_page = params.get('limit', 10)

    params['offset'] = int(per_page) * (int(page) - 1)
    params['limit'] = per_page
691468
def prev_page(self):
        
        if self.history.position > self.lines and self.history.top:
            mid = min(len(self.history.top),
                      int(math.ceil(self.lines * self.history.ratio)))

            self.history.bottom.extendleft(
                self.buffer[y]
                for y in range(self.lines - 1, self.lines - mid - 1, -1))
            self.history = self.history \
                ._replace(position=self.history.position - mid)

            for y in range(self.lines - 1, mid - 1, -1):
                self.buffer[y] = self.buffer[y - mid]
            for y in range(mid - 1, -1, -1):
                self.buffer[y] = self.history.top.pop()

            self.dirty = set(range(self.lines))
1023778
def next_page(self):
        """"""
        if self.history.position < self.history.size and self.history.bottom:
            mid = min(len(self.history.bottom),
                      int(math.ceil(self.lines * self.history.ratio)))

            self.history.top.extend(self.buffer[y] for y in range(mid))
            self.history = self.history \
                ._replace(position=self.history.position + mid)

            for y in range(self.lines - mid):
                self.buffer[y] = self.buffer[y + mid]
            for y in range(self.lines - mid, self.lines):
                self.buffer[y] = self.history.bottom.popleft()

            self.dirty = set(range(self.lines))
249456
def _get_link_pages(page, per_page, count, page_url):
    # type: (int, int, int, str) -> Dict[str, str]
    
    current_page = _page_arg(page)
    links = {}
    end = page * per_page

    if page > 1:
        links['prev'] = page_url.replace(current_page, _page_arg(page - 1))

    if end < count:
        links['next'] = page_url.replace(current_page, _page_arg(page + 1))

    if per_page < count:
        links['first'] = page_url.replace(current_page, _page_arg(1))
        links['last'] = page_url.replace(current_page, _page_arg((count + per_page - 1) // per_page))

    return links