File: Emacs_Set_Wrap.bsh

package info (click to toggle)
jedit 5.3.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 14,252 kB
  • ctags: 11,190
  • sloc: java: 98,480; xml: 94,070; makefile: 52; sh: 42; cpp: 6; python: 6
file content (57 lines) | stat: -rw-r--r-- 1,395 bytes parent folder | download | duplicates (5)
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
/**
 * Emulates the Emacs "set-fill-column" command, except that it prompts
 * for the new fill column instead of using an Emacs-style "prefix argument."
 */

source (MiscUtilities.constructPath(dirname(scriptPath), "EmacsUtil.bsh"));

void emacsSetWrap()
{
    // Convert the buffer name into a property name.

    propName = makeBufferPropertyName ("emacs.fillColumn.");
    
    // Get a value from the user.
    
    String err = "";
    int defaultWrap = getCardinalProperty (propName, getDefaultWrap());
    for (;;)
    {
        String s = Macros.input (editPane,
                                 err +
                                 "Enter new fill column or 0 to " +
                                 "reset to default",
                                 String.valueOf (defaultWrap));
        if (s == null)
            break;

        // Try to parse it.

        try
        {
            int i = Integer.parseInt (s);

            if ((i == 0) || (i == defaultWrap))
            {
                jEdit.unsetProperty (propName);
                break;
            }

            if (i > 0)
            {
                jEdit.setIntegerProperty (propName, i);
                break;
            }

            err = "Bad fill column value. ";
       }

       catch (NumberFormatException ex)
       {
           err = "Bad fill column value. ";
       }
    }
}

emacsSetWrap();