File: bm.cc

package info (click to toggle)
le 1.16.3-1
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 5,536 kB
  • ctags: 4,062
  • sloc: ansic: 24,236; cpp: 18,166; sh: 5,057; makefile: 85; perl: 82
file content (77 lines) | stat: -rw-r--r-- 1,711 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
 * Copyright (c) 2001 by Alexander V. Lukyanov (lav@yars.free.net)
 *
 * This program 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.
 *
 * This program 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., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

/* $Id: bm.cc,v 1.2 2001/05/16 14:42:28 lav Exp $ */

#include <config.h>
#include <assert.h>
#include "edit.h"
#include "bm.h"

#define N 256

static TextPoint *bm[N];
static TextPoint *bm_scrtop[N];
static num bm_scrshift[N];

void SetBookmark(int n)
{
   assert(n>=0 && n<N);
   if(bm[n])
   {
      *bm[n]=CurrentPos;
      *bm_scrtop[n]=ScreenTop;
   }
   else
   {
      bm[n]=new TextPoint(CurrentPos);
      bm_scrtop[n]=new TextPoint(ScreenTop);
   }
   bm_scrshift[n]=ScrShift;
}

void ClearBookmark(int n)
{
   assert(n>=0 && n<N);
   if(bm[n])
   {
      delete bm[n];
      bm[n]=0;
      delete bm_scrtop[n];
      bm_scrtop[n]=0;
   }
}

void GoBookmark(int n)
{
   assert(n>=0 && n<N);
   if(bm[n])
   {
      CurrentPos=*bm[n];
      SetStdCol();
      ScreenTop=*bm_scrtop[n];
      ScrShift=bm_scrshift[n];
      flag=REDISPLAY_ALL;
   }
}

void ResetBookmarks()
{
   for(int i=0; i<N; i++)
      ClearBookmark(i);
}